-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request: this
binds to the window rather than the exports object.
#25
Comments
In node.js modules, |
@mscdex @epeli thanks for the additional info. I am empathic to this point made by @epeli earlier
I personally wasn't even aware that I am currently working on making deamdify work with a larger set of libraries, and as you can imagine, authors who publish in AMD may not be clued in to how Browserify/Node works. |
Remember to think about the worst case too: When you actually encounter a module that uses Personally I'd say no to this request. |
This would break a lot of node code in the browser. |
Okay. I'll opt for the workaround of wrapping the amd modules with an iife. |
Okay, so how should library address window to be compatible with browserify? |
@Sudoki Just use |
I wonder if browserify-shim transform can have a configurable option to wrap such "modules" into a function which executes in window's context? /cc @thlorenz |
@substack some older libs still use @andreypopp I'd rather find a solution that works for all modules. If you think this can (and should) be solved via |
The workaround I used was:
|
Since this is very browser specific, adding it to browserify would break things in node (you can run a bundle in node). Would this problem be solved if browserify-shim would wrap modules like this? Possibly the issues appear most likely when shimming modules? |
@thlorenz yeah, that's what I mean, it would be done before being passed to browserify. |
So we'll fix it in browserify-shim then. I'd appreciate an issue with a repro case in the browserify-shim issues :) |
In the context of a module, currently
this
binds to the exports object, this is messing up scripts that are usingthis
to meanwindow
. I think make it it bind to window would allow interoperability with more scripts. The change would simply be to changem.export
towindow
on linehttps://github.com/substack/browser-pack/blob/master/prelude.js#L31
The text was updated successfully, but these errors were encountered: