-
Notifications
You must be signed in to change notification settings - Fork 27.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
Custom polyfills sometimes do not work in IE11 #10794
Comments
the workaround that worked for us - webpack: (config) => {
const originalEntry = config.entry;
config.entry = async () => {
const entries = await originalEntry();
// add custom polyfills into specific next.js bundle
// https://github.com/zeit/next.js/issues/10794
const nextPolyfillPath = 'static/runtime/polyfills.js';
const nextPolyfills = entries[nextPolyfillPath];
if (nextPolyfills) {
entries[nextPolyfillPath] = [nextPolyfills, './scripts/polyfills.js'];
}
return entries;
};
} |
FWIW the polyfills you're showing:
Will not be needed when 9.3 is out (or if you use next@canary currently). As all needed polyfills are included. |
Also, you're relying on a internal Next.js implementation detail that may change at any time—this is not covered by semver: // This is reserved for Next.js use only
const nextPolyfillPath = 'static/runtime/polyfills.js'; |
@Timer, yes it's not the best way but unfortunately we couldn't find a better one. Is it possible to introduce a custom webpack entry in
@timneutkens that's good but we actually encountered another issue. You're forcing polyfills to be always It means that if we put our own polyfills inside Next.js polyfill (e.g. This leads to very ugly solutions like extending the NextScript and overwriting getPolyfillScripts function 😬 |
This is because you're using a private Next.js API and not the suggested method that the To clarify my previous comment, do not edit the |
Next.js 9.3 will mostly solve this, and the default recommendation for polyfill inclusion will be to import in the top of Can you try upgrading to |
@Timer I've explained the problem with in short - when custom polyfill is part of
|
Yup, the recommendation is still to use the Figuring out why the Frameworks bundle being evaluated before the Main bundle having an effect is what needs investigated (this is speculation, right?). Rendering should still be suspended until |
We have multiple production integration tests that ensures Next.js works in IE11. Can you please provide a fully reproducible demo so we can help debug this? |
I will prepare something |
just a note that this problem - #10794 (comment) was not the case in Next.js |
To second this, I had issues polyfilling for IE11 with the I also attempted to upgrade to I was able to make it work by downgrading to |
None of the polyfills outlined here: https://github.com/mattclough1/next-ie11-polyfill-test/blob/master/client/polyfills.js are needed if you upgrade to next@canary, Next.js will correctly provide them (and every other polyfill needed for IE11). |
@timneutkens Hey Tim, I just updated the example by removing next config and polyfills script, and updating to next@canary and I'm getting the same result in IE11. |
@timneutkens, I also tried @mattclough1's repo with v9.3.0 and got the same result. |
@mattclough1 same here. |
Closing this issue as it's no longer relevant for a Next.js 9.3+ world and our docs now explain how to polyfill with a warning for this added to |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
In IE11 our custom
scripts/polyfills.js
sometimes do not work.Desciption
Here's contents of
scripts/polyfills.js
:Here's contents of
next.config.js
:Error example -
Scripts in html look like this -
Our custom polyfill is part of
main.js
which is loaded afterframeworks.js
bundle (the place where React is). If you can see both scripts areasync
meaning that sporadicallyframeworks.js
loads first which ends in error.If we include
<script src="https://cdn.polyfill.io/v2/polyfill.min.js" />
in the head of the page error disappears.Question - what's the new way to use custom polyfills with Next.js 9.2.2 and granular chunks built-in?
Thanks in advance!
System information
Additional context
Is this still up to date - https://github.com/zeit/next.js/tree/canary/examples/with-polyfills ?
The text was updated successfully, but these errors were encountered: