Huh, care to expand on why you shouldn't `require` React? Just doesn't play nicely with Browserify?
I also didn't give the main reason for using the NODE_PATH method. Browserify doesn't resolve duplicate relative paths so if you have a structure like this:
/src
main.js
components/a.js
components/foo/b.js
components/foo/c.js
and a.js requires c.js via relative paths: require('./foo/c.js')
and b.js also requires c.js via require('./c.js')
then c.js is included twice in your bundled code since Browserify uses the pure string path as the key. If instead you put /src in your NODE_PATH you can do this in a.js: require('components/foo/c.js')
and this in b.js require('components/foo/c.js')
and c.js will only be bundled once since it has the same path.Also, if you're requiring large files that you know won't need processing by browserify (like react), you can use the 'noparse' option to prevent the performance hit during bundling. (Of course a cdn is potentially a better option.)
window.$ = jQuery
Global variables are a bad thing until they're a really convenient thing.