gulp-commonjs-wrapper
v1.0.10
Published
wrap files to CommonJS modules
Downloads
12
Maintainers
Readme
You need a require.register function in the scope where you add the wrapped files. It's recommended to use commonjs-require for this purpose.
gulpfile.js
var commonjsWrapper = require('gulp-commonjs-wrapper');
gulp.src('src/**/*.{js,coffee}')
.pipe(commonjsWrapper())
.pipe(gulp.dest('build/'))
its compile from:
src/sub/Cat.js
module.exports = function(){
alert('cat');
};
src/Main.coffee
Cat = require 'sub/Cat'
module.exports = ->
Cat()
to:
build/sub/Cat.js
require.register('sub/Cat', function (exports, require, module) {
module.exports = function(){
alert('cat');
};
});
build/Main.coffee
require.register 'Main', (exports, require, module)->
Cat = require 'sub/Cat'
module.exports = ->
Cat()