A generator for Yeoman that lets you write JavaScript modules in plain Node.js, and transpile them into every permutation you (or anyone else) might need.
The purpose of this generator is not to end up with a complete web application, but rather a modular component that could be used in any application.
WORK IN PROGRESS: I'm still experimenting a bit and things might change. I welcome feedback and suggestions; I'd like this to be genuinely useful in the end.
combo-module generates a complete skeleton for developing in Node.js, testing, optimizing, versioning, and transpiling to all of the internet's favorite module formats. You end up with a publishable npm module for use on the server, AMD (RequireJS), CommonJS (Browserify), UMD, and/or a standalone script to use in the browser.
The transpile process is a source-to-source translation, generating a separate build
tree for each module flavor. This intermediary step is useful not only for debugging in the browser, but also for reducing bloat by defering bundling/minifying to the web application. This way only the parts needed by the app will be wrappled into the final bundle. But if all you want is a single optimized file that works everywhere, you get that too.
Bits and Pieces:
- npm: Package manager/registry
- Bower: Browser package manger/registry
- Yeoman: Makes web dev easy
- Grunt: Build/task runner
- Jasmine: Behavior-driven (BDD) tests
- Karma: Test runner
- PhantomJS: Headless browser (for test)
- Browserify: CJS optimizer/loader
- RequireJS: AMD optimizer/loader
- uRequire: Transpiler/converter
- npm (comes with Node.js)
Make sure you have Yeoman installed:
$ npm install -g yo
...
Install this generator (like a plug-in for Yeoman) from npm:
$ npm install -g generator-combo-module
Create a directory for the project, and cd into it:
$ mkdir ~/dev/fancy-new-module && cd $_
Finally, initiate the generator:
$ yo combo-module
The generator will prompt you for several config settings before generating the project files. Where possible, all settings are saved in the project's package.json
under the config
hash, and any time an npm lifecycle script or Grunt task is run it will look there first for config values. So you'll be able to make changes to the config if you change your mind later.
- Transpile
- Node.js to AMD/UMD
- to combined.js
- optimized/minified w/wo dependencies
- Test
- Node.js
- browser (RequireJS, Browserify, globals)
- publishing (npm)