-
Notifications
You must be signed in to change notification settings - Fork 27.2k
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
nextjs 13.4.13 is not transpiling code to browser old versions even with browserslist option in package.json #53821
Comments
I've tried older versions and seems like it doesn't work there either. EDIT: I think this works it's just that Try using this to figure out which dependency/package or sub dependency contains the new syntax and att that to the list. module.exports = {
webpack: (config) => {
config.optimization.minimize = false;
return config;
},
} A feature request would be if Next.js could validate if
|
My problem was https://nextjs.org/docs/app/api-reference/next-config-js/transpilePackages next.config.js module.expoorts = {
// ...
transpilePackages: [
'react-hook-form',
]
} .babelrc {
"presets": ["next/babel"],
"plugins": []
} |
@EloB yes the repo that I posted here is a app generated using the next-create-app CLI, without any dependency and the error looks like is inside nextjs core |
@yanv1991 Have you tried babel? It might be a SWC issue. |
yes actually the repo uses babel.config |
hey @EloB I tried adding |
@yanv1991 Does |
Have you tried if this works with SWC? I really don't want to use babel. |
yes, take a look to the error, this is running in chromium 48: |
it worked even with swc, as long as I keep |
This bug sames occur after v13.2.0, use v13.2.0 the main-**.js is ok, but when you import third part package in the project the file in dist chunks folder still have es6 syntax even you config browserslist. |
@woshiqiang1 for 3rd parties you need transpilePackages option |
@yanv1991 I add the package in transpilePackages option, but the dist chunks folder still have es6 syntax |
@woshiqiang1 The easiest way to find with package it was is: module.exports = {
webpack: (config) => {
config.optimization.minimize = false;
return config;
},
} Sometimes it might be a sub dependency of a dependency. When you do like that you still have the comments left with package names and discovered that sub packages contained ES6 code. Than I just added them too. I got this working for both babel and swc. Don't forget to set the |
@EloB Thanks I try the way you said above and it works !! but it's really not a very elegant and convenient way hope Next.js optimize this DX someday. |
I also ran into issues after upgrading to Next 13.5.2, the build would generate non-ES5 syntax (that I check with the es-check package I also found that the output chunk contained some Next.js router code that had I also fixed it by adding /** @type {import('next').NextConfig} */
const nextConfig = {
transpilePackages: ['next'],
}
module.exports = nextConfig |
13.5.6 same issue. Adding next breaks the build
Error tail
|
I conducted an experiment on a pure next.js project with these basic settings. It seems that the settings for browserslist inside package.json have no effect on the size of the bundle and have a very strange effect on the size of the .next folder. clean project (npx create-next-app@latest)
"browserslist": ["last 2 Chrome versions"] (package.json)
"browserslist": ["last 2 Chrome versions"] (package.json) + transpilePackages: ['react', 'react-dom', 'next'] (next.config.mjs)
Can one of the developers look at this problem (possibly - @timneutkens @Timer @leerob)? |
I also noticed an extremely strange effect.
|
I tried adding next to my transpilePackages config. /** @type {import('next').NextConfig} */
const nextConfig = {
transpilePackages: ['next'],
}
module.exports = nextConfig But there are still private properties in my js. Is it possible to transpile private properties? |
Verify canary release
Provide environment information
Operating System: Platform: darwin Arch: x64 Version: Darwin Kernel Version 20.6.0: Thu Mar 9 20:39:26 PST 2023; root:xnu-7195.141.49.700.6~1/RELEASE_X86_64 Binaries: Node: 16.14.2 npm: 8.5.0 Yarn: 1.22.19 pnpm: N/A Relevant Packages: next: 13.4.14-canary.1 eslint-config-next: 13.4.13 react: 18.2.0 react-dom: 18.2.0 typescript: 5.1.6 Next.js Config: output: N/A
Which area(s) of Next.js are affected? (leave empty if unsure)
No response
Link to the code that reproduces this issue or a replay of the bug
https://github.com/yanv1991/test-2017
To Reproduce
run
yarn build
and thenyarn start
note: webpack custom config was added to disable minimizer
look for the
.next
folder inside themain-xxxxx
file you will see non es5 syntax like:Describe the Bug
when adding
browserslist
option in package.json with a value like this:>0.3%, defaults, supports es5
the next bundle is still generating modern syntax.Expected Behavior
if browserslist with es5 target is configured the bundle should not generate modern syntax like
let, const
....Which browser are you using? (if relevant)
Chrome 48.0.2527.0
How are you deploying your application? (if relevant)
local
The text was updated successfully, but these errors were encountered: