-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Using the fetch polyfill #1066
Comments
While you could edit the entry like the docs suggest, it's a little tricky to do this in Webpacker with the way it abstracts Webpack configuration. It's not really necessary either. I would just import the package near the top of
// application.js
import 'babel-polyfill'
import 'whatwg-fetch'
// rest of the bundle below ... |
+1 Thanks @rossta! |
Thanks @rossta I’ll try that.
Btw. I thought babel-polyfills are required by default out of the box. Do I need to do this require for that to work also?
…--
Regards
Steve Robinson
On 06-Dec-2017, at 3:44 AM, Javan Makhmali ***@***.***> wrote:
+1
Thanks @rossta!
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Yes, and then when babel compiles it will replace this import with appropriate polyfills specific to required browsers. |
If you are using multiple packs/pages i.e. application.js isn't only the main bundle, then consider creating a // packs/polyfills.js
import 'babel-polyfill'
import 'whatwg-fetch'
//... rest of the polyfills if any add it in your layout <%= javascript_pack_tag 'polyfills' %>
# ... other packs |
@gauravtiwari Thanks... I tried this.. But, still my exception tracker is seeing My
Does this have anything to do with this? how do I reliably test something like this. |
Did you include that bundle in the view? |
Yes I do.. |
Ahh right I see, so that's one bundle you are trying to render. Could you share more info on how you are rendering your components? Don't know how react on rails works currently. |
How about if you make one polyfill pack just for polyfills and do the component registry in separate component? |
<%= react_component("BrowseEvent",
props: {
...
},
prerender: false)
%> Like this.. |
I'll try that. Thanks for your quick response @gauravtiwari :) |
No worries, make sure it's placed in the head (application layout file) before other JS packs/react components. |
@gauravtiwari I have my JavaScript requires at the bottom of my layout, but the polyfill pack has been required above the rest. That should be fine right? |
Yep should be fine but safe to place it in the head since we want browser to parse that first before anything else :) |
@gauravtiwari alright :) This is in production now and I'm seeing if there are any occurrences of the issue. So far so good in the last 15 mins :) |
@gauravtiwari It does not seem to be fixed man... UA - Haha, this is like a zombie |
@steverob Please place in the head. |
polyfills file |
@gauravtiwari okay |
@gauravtiwari awesome man. No issues so far :) :) Thanks a ton. |
@gauravtiwari, how would you do this with the new |
@brentdodell What webpackER calls a "pack", vanilla webpack calls an "entry point".
What you would need to do is put Ref: |
Thanks @jakeNiemiec! |
I'm trying to use the
fetch
polyfill - https://github.com/github/fetch. Their documentation mentions that to use with webpack, one needs to add it to the entries.How do I do this with webpacker. I'm a total newbie to webpack :)
The text was updated successfully, but these errors were encountered: