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
Regression: bumping Next version from 11 to 12, generated js files are builded ignoring browserlist #33985
Comments
Hi, could you test |
Hi @balazsorban44, The transpiled code of this function: const callAll = async function () {
console.log("OK HELLO!");
} is this one: var f = function () {
var n, t = (n = e().
mark((function n () {
return e().
wrap((function (n) {
for (; ;) switch (n.prev = n.next) {
case 0:
console.log('OK HELLO!')
case 1:
case'end':
return n.stop()
}
}), n)
})), function () {
var t = this, r = arguments
return new Promise((function (o, e) {
var u = n.apply(t, r)
function c (n) {i(u, o, e, c, f, 'next', n)}
function f (n) {i(u, o, e, c, f, 'throw', n)}
c(void 0)
}))
})
return function () {return t.apply(this, arguments)}
}() |
I did some digging, this is because we don't currently pass the Browserslist config to SWC (default compiler over Babel since Next 12), only to PostCSS. So CSS will be correctly targeted, while JS won't. This is planned to land when this RFC goes out: #33227 So please follow that for further information. Thanks for reporting! 🙏 |
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
You can now add browserslist when enabling an experimental flag: #33227 (comment) |
Run
next info
(available from version 12.0.8 and up)What version of Next.js are you using?
12.0.8
What version of Node.js are you using?
16.13.0
What browser are you using?
Chrome, Safari
What operating system are you using?
macOS
How are you deploying your application?
Other platform
Describe the Bug
Updating our application from Next 11 to Next 12 we noticed that generated js assets are generated ignoring the browserlist.
For instance, starting from this code:
Building using Next 11 (minified version)
Building using Next 12 (minified version)
Expected Behavior
should respect browserslist.
We discovered that the regression is due to replacing babel in favor of swc.
Forcing the use of babel, adding .babelrc file at the project root, the output files are converted as expected:
To Reproduce
The text was updated successfully, but these errors were encountered: