-
Notifications
You must be signed in to change notification settings - Fork 286
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
Prevent Illegal invocation Error in webpack #20
Conversation
Thanks. This was happening to me with browserify and babel in Chrome (but not Firefox) too. This was my workaround:
My |
Thank you! Just ran into the same problem. Npm package should be updated ASAP |
Thanks! -rocky
|
Thanks! |
Life saver 👍 |
just import the library and let it pollute the global/window namespace. wrong: no error: |
My experience and workaround on this is simple: don't use import/require for polyfills. new webpack.ProvidePlugin({
"fetch": "isomorphic-fetch",
}); |
Just been bitten by this. It'd be great to get it merged @matthew-andrews 😄 |
@matthew-andrews this one can be closed due to #27 being merged 😄 |
Released in v2.1.1. |
I am using ES6 modules with webpack and I ran into an issue. My code was something like this:
which raised an Illegal invocation Error. This is the same error that happens when you do something like this:
I looked at the compiled code and it looked like this:
which is the problem because now the fetch function is called with a this value of the _fetch2 module. It is similar to doing the following:
So I just made sure that fetch was bound to the window object on importing. This of course assumes that Function.bind exists or was polyfilled.