Package Exports
- mcjs
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (mcjs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
MCJS

Merge Common JS modules into a single module.
MCJS produces a single module with all inner requirements merged into a single scope with resolved names conflicts. That way it gains maximum compressability and minimum overhead.
Some stats
Compare minified sources (via closure compiler):
| Package | Browserify | Webpack | Component | MCJS | |
|---|---|---|---|---|---|
| color-space | 5kb | 4.4kb | 12% |
Usage
Install
$ npm install -g mcjs
Build
dep.js:
var z = 123;
module.exports = z;index.js:
var a = require('./dep');
module.exports = a;Pass index.js to mcjs and it will produce the result:
$ mcjs index.js > bundle.js
or
$ cat index.js | mcjs > bundle.js
Resulting bundle.js:
var m_a, m_index;
var z = 123;
m_a = z;
var a = m_a;
module.exports = a;Post-process
You can wrap bundle.js with umd for standalone build:
$ cat bundle.js | umd stansalone_name -c > bundle.jsAlso you can minify with closurecompiler for maximum compression:
$ ccjs bundle.js --language_in=ECMASCRIPT5 > bundle.min.jsMotivation
As far closure compiler can expand any objects, if to merge modules into a single scope, which means to resolve global vars conflict and to replace all module.exports and require calls, then you get one-scoped bundle, which closure compiler compresses the way better than separated by scopes browserified/compiled bundle.
Mcjs does the same task as a ClosureCompiler with --process_commonjs_modules flag, but avoids creating of goog.provide's and makes variables more human-readable.
