add basic compatiblity with browserify#2
add basic compatiblity with browserify#2calvinmetcalf wants to merge 4 commits intokrisnye:masterfrom
Conversation
|
Shouldn't it use this instead of self? |
|
I'm not sure that will work in strict mode
|
|
so what browserify does is |
|
self is not defined in node though, and these shimmed files should work in both node and the browser. 'this' works in both. If you change self to this then it will be fine. I actually recommend just including a file on the browser that shims for node properties you need right before you include the require.js something like global.js: This way, you can provide whatever you need without having to continually extend the output of each module. |
|
that won't work in strict mode (will break if somebody enables global strict) and also messes with the global scope which many people don't like, updated this to more accurately tell if you're in a browser, and accurately get the right global object. |
|
If you wrap it in a function call then it won't violate strict: If you want compatibility with the node environment in the browser, then both 'global' and 'process' should be defined as global variables, not as locally scoped variables. That's exactly how they are provided in nodejs. The only variables that are locally scoped in nodejs are module, exports and require which is exactly what we provide. |
one last commit, should work the same in node if it has the wrapper or not |
adds basic compatibility with some browserify idioms, process.browser to check if we are in the browser or not, and global as a shortcut to whatever the global object happens to be