Neglected Puppy Market

    gulp-commonjs-wrapper

    1.0.10 • Public • Published

    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()

    Install

    npm i gulp-commonjs-wrapper

    DownloadsWeekly Downloads

    35

    Version

    1.0.10

    License

    MIT

    Last publish

    Collaborators

    • maxmaxmaximus