npm install grunt-coffee-build
|23||downloads in the last day|
|67||downloads in the last week|
|116||downloads in the last month|
|Version||1.4.12 last updated 5 months ago|
|Keywords||gruntplugin, commonjs, build, grunt, browserify|
|Dependencies (6)||source-map, coffee-script, uglify-js, handlebars, lexical-scope, browserify|
npm install grunt-coffee-build --save-dev
The fastest way of getting started with this task:
npm install -g grunt-init # if you dont have git clone git://github.com/tarruda/grunt-init-umd-commonjs-coffee ~/.grunt-init/umd-commonjs-coffee mkdir project_name cd project_name grunt-init umd-commonjs-coffee # answer questions npm install # install dev dependencies
This task will take care of compiling, merging and generating source maps for your .coffee/.js files. If merging, the resulting source map will contain information about each individual file so they can be debugged separately.
The task will parse all require calls for relative paths, concatenate files in dependency order while wrapping each file into a commonjs-like module. All require calls are replaced by a module identifier generated from the file path (This is how google-traceur compiler handles imports when merging files)
When compiling the project to a single file, the task will wrap everything into umd, and the result runs anywhere a umd module would run.
The task will also cache individual file builds, so only modified files will need to be reprocessed again.
Node/npm modules will be bundled if the browserify option is set and external libraries may be included using the 'include' option. Browserify builds will also be cached, but only in memory(useful with grunt-contrib-watch).
This is an example adapted from a real project (vm.js) that runs on browser or node.js. It depends on the 'esprima' parser, so third party library handling is also illustrated:
The combined source maps generated by this task work flawless(at least in my tests). Debugging with node-inspector(0.3.2) or google chrome should just work.