Grunt task for compiling client-side CommonJS modules into one file.
It takes only required files, not everything.
npm install grunt-commonjs-compiler
Also you can add --save or --save-dev to save this dependency in package.json:
npm install grunt-commonjs-compiler --save-dev
grunt-commonjs-compiler uses Closure Compiler to compile and optimize CommonJS modules.
You can obtain it here
To see it in action without smoking too much of documentation:
git clone .npm installcurl | tar zx
grunt-commonjs-compiler will build a CommonJS module tree starting from test/client/main.js and write the compiled code to test/build.js
Notice that the compiled build doesn't include test/client/unused.js as no module requires it.