Broccoli plugin that compiles ES6 modules along with npm dependencies into a single UMD bundle using Browserify. The plugin looks for the
jsnext:main property in your package.json, compiles any ES6 modules to CommonJS modules, browserifies them, and saves the whole thing as single file based on the
main property of the package.json.
For importing npm modules in your ES6 code, use the
npm: prefix. For instance, if you wanted to use the RSVP promise library, you would import it like so:
;// Use regular syntax for local modules;
This prefix, as well as the entire plugin, was inspired by ember-browserify.
Let's say your package.json looks something like this:
Now just add this to your Brocfile:
//Brocfile.jsvar compileEs6 = ;var options =globalName: 'MyLibrary'amdModuleId: 'MyLibrary';var outputTree = ;
Yea, it's that simple. Using
lib/index.js as the root ES6 module, the plugin will bundle your ES6 code into a file named
my-module.js in the dist output folder when you run Broccoli.
globalName - Name of global module variable exported via UMD. In other words, window[globalName]. Defaults to
amdModuleId - Module ID of exported AMD module. If undefined, AMD module will be anonymous.