Easily build a umd package from a project of CommonJS (node.js style) modules that can be loaded via require.js or as a traditional browser global loaded in a <script> tag. Has an option to "watch" the source files and rebuild the package on the fly.
This uses webpack under the hood.
npm install build-modules
var build =var emitter =emitteremitteremitter
build-modulesover Browserify and Webpack?
If you just want to easily support people using require.js and traditional script inclusion, but don't need anything complicated, this module is for you. It also exposes the "watcher" ability from webpack (which browserify doesn't have).
filepath- The absolute path to the module file.
options- An object with optional parameters. Can contain the following members:
watch- If true, sets up a watcher that rebuilds the bundle whenever relevant source files change (keeps running until the process closes)
name- The name of the global variable in the case the UMD package is loaded without a module system (defaults to
header- A string to put at the top of the build bundle.
output- An object with the members:
path- Where to put the bundle file (defaults to the entrypoint directory)
name- What to name the output bundle (defaults to options.name+'.umd.js')
alias- Webpack alias option.
plugins- Additional webpack plugins to add.
jsonpFunction- The name of the jsonp function name (defaults to webpack's default).
minify- If false, this doesn't minify and also adds pathinfo to modules in the bundle. Default: true.
Outputs the following files:
When build is called with the watch option, 'done' is emitted twice in a row on the first run. After that, you just get the expected 1 per build.
Released under the MIT license: http://opensource.org/licenses/MIT