Replies: 7 comments 24 replies
-
|
did u find solution |
Beta Was this translation helpful? Give feedback.
-
|
Any update on this topic? it has been open for like >1 year at this point 👀 |
Beta Was this translation helpful? Give feedback.
-
|
no answer here ? .... |
Beta Was this translation helpful? Give feedback.
-
|
Same interest here. In bundle I see import with polyfills from |
Beta Was this translation helpful? Give feedback.
-
|
You are correct that Next.js includes some legacy JavaScript polyfills to ensure compatibility across a wide range of browsers. This can trigger Lighthouse warnings even if you are targeting modern browsers.
"browserslist": [
"last 2 Chrome versions",
"last 2 Firefox versions",
"last 2 Safari versions",
"last 2 Edge versions"
]
const nextConfig = {
experimental: {
modern: true,
polyfillsOptimization: true
}
}
module.exports = nextConfig;
By tightening your Browserslist targets, enabling Next.js modern builds, and auditing dependencies, you can reduce or eliminate legacy JS polyfills, satisfying Lighthouse requirements while maintaining compatibility for modern browsers. |
Beta Was this translation helpful? Give feedback.
-
|
So I ran into what I suspect is the same error but I do note that Currently I see it complain about the functions contained in /packages/next-polyfill-module/src/index.js. When using turbopack you can resolve the issue by adding the following settings in your import path from 'path';
import os from 'os';
const nextConfig = {
transpilePackages: ['next'],
turbopack: {
resolveAlias: {
'../build/polyfills/polyfill-module': path.relative(os.devNull, __dirname)
},
}
};This causes turbopack to transpile the WarningsYou probably want to think twice about using this in production. It relies on next internals that are allowed to change at any time. On top of which nulling out a package like this doesn't have great support in turbopack, which is why there is the I also have no idea if transpiling next has other consequences. I would be kind of surprised if it didn't with everything involved in the build process. AlternativeRight now it seems like only the |
Beta Was this translation helpful? Give feedback.
-
|
Any update on this? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
When I run Lighthouse on my application I get a warning to avoid serving legacy JS in modern browsers. Looking into the details I see the code references polyfills to
Object.entries()and the@babel/plugin-transform-classesis used.I'd tried to set a custom browserlist configuration to point to more up to date browser's versions and after running CWV I still get the same warning.
Is it possible to remove that polyfills?
Additional information
No response
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions