Skip to content

mathisonian/gulp-browserify-protect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gulp-browserify-protect

protect your browserify bundle from other module loaders using the global namespace

Getting Started

Install the module with: npm install --save-dev gulp-browserify-protect

var browserifyProtect = require('gulp-browserify-protect');

gulp.task('browserify', function() {

    return gulp.src(srcDir + 'js/app.js')
        .pipe(browserify())
        .pipe(browserifyProtect())
        .pipe(gulp.dest('./public/js/'))
        .pipe( livereload( server ));
});

This adds

window._require = window.require;
window.require = undefined;
window._define = window.define;
window.define = undefined;

// browersified bundle goes here

window.require = window._require;
window.define = window._define;

to your browserify bundle.

why?

I have found this useful for embedding code on a page that uses a legacy module loader such as require.js

License

Copyright (c) 2014 Matthew Conlen. Licensed under the MIT license.

About

Hide window.require and window.define from browserify modules

Resources

License

Stars

Watchers

Forks

Packages

No packages published