montagejs/mr — pull request #41 by kriskowal (2013-08-26 04:04:47+00:00)
Title: Build boot.js script using a build script

:warning: This includes backward incompatible changes that impact Montage and Mop. Changes to those packages in the corresponding `build` branch must be coordinated and released in a future, backward-incompatible release. Some care will be needed to ensure that `mop` in particular depends on compatible versions of `mr` and `montage`.

This introduces a program, `mrs`, that can create stand-alone scripts from modules that only need the ability to produce and consume CommonJS modules with `require` and `exports` or `module.exports`, and depend only on a static working set. The resulting script has very little overhead and is based on the build products of Browserify.

`mrs` is sufficient to build `mr/boot.js` (previously `bootstrap.js`)from the CommonJS modules in the `boot` directory. Run `npm run build`to produce a new revision of `boot.js` and `boot/preload-boilerplate.js`.

This aleviates the need to perform script injection in the bootstrapping process, at the expense of introducing a build step for the bootstrapper. This change also allows a greater level of code reuse between Mr and Montage in their bootstrapping processes. This also obviates the need to embed UMD boilerplate in these modules, since they will always be used as CommonJS modules, either as sources for the build or as instruments of Node.js.

Since `mrs` embeds the entirety of `boot.js`'s dependencies, it is no longer necessary to use a subrepository for these dependencies and no longer necessary to use hard-coded relative locations for these dependencies in `package.json`. These dependencies may now be installed by NPM and the maintainers of Mr and its dependencies no longer need to coordinate or hard-code their dependency trees. This is important because Q will soon be breaking up into smaller modules and packages.

The `mini-url` module may now be a CommonJS module shared by Montage and Mr. Within Montage and Mr, it may be required by the name `url`. A mapping in `package.json` directs the module loader to use `mini-url.js` instead. On the Node.js side, where `mini-url.js` would not work, we fall back to Node.js's `url` module, which has an API that is a strict super-set of `mini-url.js`'s.