I run browserify with "--exports require", would this be what you need?
browserify entry.js --exports require -o br.js
Question
I'm working with a couple of node.js modules that I require on the client:
index.js:
var sync = require('../lib/sync');
So I figured browserify might be the best choice. Bundling the files works great, however, browserify wraps everything in a (function(){my code here})();
which cause the Can't find variable: require
error. How can I prevent that behaviour?
When I remove the wrap, everything works as expected without errors.
La solution
I run browserify with "--exports require", would this be what you need?
browserify entry.js --exports require -o br.js
Autres conseils
You can pass parameters to the IIFE like this:
(function (require) {
var sync = require('../lib/sync');
}(requre));