-
Notifications
You must be signed in to change notification settings - Fork 200
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
unfetch/polyfill doesn’t work in webpack 2 #31
Comments
that is why i saying for years to not use single dot |
Ah good catch - @sapegin @tunnckoCore, are we good just to change |
That should be the same, so probably to |
Hm - but if someone is using this via webpack 2 the entrypoint would actually be I just re-read the story here and I actually think we're fine with if (!window.fetch) {
window.fetch = (require('unfetch').default || require('unfetch'));
} Seem reasonable? alternatively: if (!window.fetch) {
window.fetch = (function(a){ return a.default || a })(require('unfetch'));
} |
Yeah, that should work too. Will send a PR. |
What do you guys do about |
Nevermind. I think my comment is unrelated because I'm talking about server bundling with |
@enapupe indeed - for that case, are you able to use |
Since I don't actually want to polyfill it on node, I ended up doing my own
version of `polyfill.js`:
https://github.com/CheesecakeLabs/fetch/blob/unfetch/src/utils/polyfill.js
It does nothing if window isn't defined.
This works for me because on node I mock fetch with webpack define plugin
at a global level, not as a window prop. And I don't really run `fetch`
calls on ssr as it doesn't really waits for them to complete before
returning the template code. So I just `noop` it.
Thanks for your suggestion anyway.
|
When I do:
I see this error in Safari 10:
Because
fetch
is actually a ES module wrapper:I suppose it’s because you have
require('.')
inpolyfll.js
and webpack 2 resolves it toindex.es.js
. So this code works for me:I’d be happy to submit a PR but not sure what would be the right fix for this.
The text was updated successfully, but these errors were encountered: