-
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
Missing polyfills and transforms for older browsers #15756
Labels
good first issue
Easy to fix issues, good for newcomers
Milestone
Comments
I raised a similar issue a while ago #10966 Bottom line is that NextJS ships with just enough polyfills to get it running >=IE11 but you need to add polyfills for other features that you'll use in your app. |
kodiakhq bot
pushed a commit
that referenced
this issue
Aug 4, 2020
…ES2019 for browser compatibility (#15772) These changes aim to resolve most of the concerns raised in #15756. It adds missing polyfills for legacy browsers up until ES2019: - Number.{parseFloat,parseInt} - ~Math.{acosh,asinh,atanh,cbrt,clz32,cosh,expm1,fround,hypot,imul,log10p,log1p,log2,sign,sinh,tanh,trunc}~ _[Removed as these are [not widely used](https://github.com/vercel/next.js/pull/15772#discussion_r463957931)]_ - While these may seem to weigh a lot, they barely add 1 kB to the resulting bundle: <img width="492" alt="gzip: 32 kB vs. 30.9 kB, Brotli: 28.8 kB vs. 27.8 kB" src="https://user-images.githubusercontent.com/14854048/89100961-1376e600-d3fc-11ea-90fd-3e6632b70220.png"> - ~Object.fromEntries~ _[Removed as [it's rarely used in user code](https://github.com/vercel/next.js/pull/15772#discussion_r463984612)]_ Also, the following features are now supported with build-time transforms: - ~`globalThis` (gets transformed into `window` in browser environments)~ _[Removed as it [could break existing applications](https://github.com/vercel/next.js/pull/15772#discussion_r463956269)]_ - `export * as ns from 'module'` The suggested TypeScript library version has been set to ES2018, so the features below become unavailable in type-checked files (they're not evenly supported by module-compatible browsers, either): - Object.fromEntries - String.prototype.matchAll - String.prototype.replaceAll - Promise.any + AggregateError - WeakRef As for the `import.meta` support, [webpack v5 seems to fix that](webpack/webpack#11075), so it should eventually become an issue of the past. --- Fixes #15756
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. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Bug report
Describe the bug
While browsing the polyfills applied by Next.js 9.5.1, I encountered a lot of features which aren't polyfilled:
ES2015
ES2019
ES2020
ES2021
This may cause unnoticed issues in various browsers.
Missing Babel transforms
globalThis
should be transformed intowindow
in browser environmentsexport * as ns from 'module'
should be transformed with Babelimport.meta
should be supported (e.g. for standards-compilant hot module replacement)Expected behavior
The features above should be supported to avoid browser compatibility issues.
Warnings for non-polyfilled features
There are some features which cannot be polyfilled (or it's hard to do so). For those, an ESLint config or console warnings should be made:
The text was updated successfully, but these errors were encountered: