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
swcMinify: true
does not produce an usable build with v12.1.5
#36127
Comments
This comment was marked as off-topic.
This comment was marked as off-topic.
same here /**
* Create a code check from a regex.
*
* @param {RegExp} regex
* @returns {(code: Code) => code is number}
*/
function regexCheck(regex) {
return check
/**
* Check whether a code matches the bound regex.
*
* @param {Code} code Character code
* @returns {code is number} Whether the character code matches the bound regex
*/
function check(code) {
return code !== null && regex.test(String.fromCharCode(code))
}
} Code above will not work fine. |
I fixed the issue reported by @powerfulyang (swc-project/swc#4338), but not sure if this issue is related to this issue. |
I'm not sure how can I test the fix Seems like you are invoking next.js in docker, right? If so, |
@kdy1 Can you add this change swc-project/swc#4250 in nextjs to fix infinite loops? |
@smitpatel1010 Of course, I included it in #36187 |
Oh great. Thanks 🙂 |
@ribeaud looking at your reproduction, it seems a bit complicated. Could you please try to create a more minimal one that's focusing on the issue? I recommend removing any pages/components/technologies that do not contribute to the bug you are experiencing (eg. I'm sure Docker and most of the stuff in the repo are not contributing to the issue here). This will help us verify and fix any bugs much faster. 👍 |
This PR updates swc crates to swc-project/swc@b8d9a58 - Closes #35811 - Closes #34811 - I tested with https://github.com/balazsorban44/issue-34811 <img width="1840" alt="image" src="https://user-images.githubusercontent.com/29931815/163574875-d7392c4c-b1f1-4503-aac1-35a26c9d7ec2.png"> - Closes #34715 - I tested with https://github.com/cungminh2710/nextjs-swc-mapbox <img width="1840" alt="image" src="https://user-images.githubusercontent.com/29931815/163574677-9733dd69-9938-4e3e-b2f1-bfbd6db9e20c.png"> - This fixes the bug reported in the comment (#36127 (comment)), but I didn't test the issue itself.
1. react@18 下 font-optimization 有 BUG, Temporary fix: optimizeFonts: false; vercel/next.js#35835 (comment) 2. next@12.1.5 swcMinify 有 BUG, 12.1.4 还是好的, Temporary fix: swcMinify: false; vercel/next.js#36127 (comment) 3. 当前 next@12.1.5 和 @sentry/nextjs@6.19.6 的情况有 BUG, 不会上传 sourcemap 不知道以前是否是好; getsentry/sentry-javascript#3579 (comment)
1. react@18 下 font-optimization 有 BUG, Temporary fix: optimizeFonts: false; vercel/next.js#35835 (comment) 2. next@12.1.5 swcMinify 有 BUG, 12.1.4 还是好的, Temporary fix: swcMinify: false; vercel/next.js#36127 (comment) 3. 当前 next@12.1.5 和 @sentry/nextjs@6.19.6 的情况有 BUG, 新发现仅仅 Windows 有问题, 不会上传 sourcemap 不知道以前是否是好; getsentry/sentry-javascript#3579 (comment)
@balazsorban44 makes perfectly sense. However I am not sure being able to do it before coming week-end. What I definitely can do is to test any canary release you want. |
@ribeaud no rush on providing the code but we can't investigate it further for your particular case without it. Can you try the latest canary version? A bunch of changes to the minifier were applied. |
|
@arnovanstaden can you provide a reproduction for your case? We've generally found that comments on these issues tend to be completely different minifier bugs that have to be investigated separately. |
Same issue here with The issue can be reproduced by running the few simple commands listed for production on https://github.com/Luukuton/shingetsu-blog/tree/main/frontend with the following as
Remember the change the Errors:
|
!!! Set productionBrowserSourceMaps true in next.config.js can get full error trace. |
We have been running into this issue in one of our apps as well (even on the latest canary). In our case, the following error is thrown:
After some process of elimination, the culprit turned out to be some code that was using import { isString } from 'util'; And removing that code makes the error goes away. I pushed up a simple reproduction here in hopes it helps get to the root cause of the issue (this form of it anyway): https://github.com/seanparmelee/nextjs-36127-reproduction
|
It will be fixed by #36351 (I used my own script to replace |
I tried release https://github.com/vercel/next.js/releases/tag/v12.1.6-canary.13 that should contain fix from #36351 |
@VeronikaSergiyenko I think it will be fixed by #36535 React now uses google closure compiler as their minifier, and it triggered a bug of swc minifier. |
I just want to add to this, that I ran into a similar issue whereupon deployment I receive invariant 138 saying "Maximum depth exceeded", and disabling swcMinify solves the issue for now. https://reactjs.org/docs/error-decoder.html/?invariant=185 |
@Rafcin Did you try the latest canary? If so, can you provide a repro? |
@kdy1 I just tested a deployment with 12.1.7-canary.16 and it threw the same issue. The repo is private, but if you need anything specific let me know! |
Is the solution just to downgrade to 12.10.0? Our build was working with 12.1.6. Migrated to Material UI 5 . And part of the codebase that's unrelated to the MUI started breaking after minify |
@terryli0095 You can provide more information, like repro case, so I can fix it |
@kdy1 I can reproduce this error using a dependency as example: next.config.js
package.json{
"name": "swc-test",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@codemirror/text": "^0.19.6",
"next": "12.1.6",
"react": "18.2.0",
"react-dom": "18.2.0"
},
"devDependencies": {
"@types/node": "18.0.0",
"@types/react": "18.0.14",
"@types/react-dom": "18.0.5",
"eslint": "8.18.0",
"eslint-config-next": "12.1.6",
"typescript": "4.7.4"
}
}
index.tsximport type { NextPage } from "next";
import { Text } from "@codemirror/text";
const Home: NextPage = () => {
const length = Text.of(["Hello World"]).length;
return <p>{length}</p>;
};
export default Home; The variable value should always return // Wrong
swcMinify: true,
// @codemirror/text
constructor(a, b=function(a) {
for (let b of a)
b.length;
return -1
}
// Correct
swcMinify: false,
// @codemirror/text
constructor(a, b=function(a) {
let e = -1
for (let b of a)
e += b.length + 1;
return e
} Hope it helps Edit: it has been fixed on Canary |
let e = -1
for (let b of a)
e + b.length + 1;
return e Is this typo? |
@danilowoz swc-project/swc#5013 I checked it and it was already fixed long time ago. What's your next.js version? |
It's |
@danilowoz Can you try canary? |
Yep, I can confirm that it has been fixed on canary. Thanks, @kdy1 |
Any progress on this? I want to disable it to debug a bug that doesn't happen in local development mode for some reason |
@OskarD All debuggable issues are fixed. Others did not provide any information. |
I'm probably doing something wrong, but with 12.2.3 and this config:
I'm getting this kind of error:
Is there something I'm missing here? |
Is it really related to swc minifier?
Is this typo? |
Sorry, I thought this thread was for disabling minifying. I'm using Webpack so my problem is not related, my apologies |
Hi. Just this short notice to let you know that, after many unsuccessful releases, I was able to reactivate I do not know what exactly solves it though: whether we changed something relevant on our side, or whether it is due to some changes on your side. Anyway, let's appreciate this momentum and let me tell you thank you! |
Should I close it? |
Nice! I think we can close this issue for now. |
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. |
Verify canary release
Provide environment information
$ npx --no-install next info Operating System: Platform: darwin Arch: x64 Version: Darwin Kernel Version 21.4.0: Fri Mar 18 00:45:05 PDT 2022; root:xnu-8020.101.4~15/RELEASE_X86_64 Binaries: Node: 16.13.1 npm: 8.1.2 Yarn: 1.22.18 pnpm: N/A Relevant packages: next: 12.1.5 react: 17.0.2 react-dom: 17.0.2
What browser are you using? (if relevant)
Not relevant
How are you deploying your application? (if relevant)
next start
after anext build
Describe the Bug
Locally (running the application locally, in my IDE), everything looks good. Our tests are green as well. Only the PROD artefact is somehow rubbish.
When accessing the homepage, this is what we get in the console:
When clicking on one of the links displayed, this is what I get:
Expected Behavior
No error messages in the console, application is running properly and swcMinify is set to
true
, like it used to be for v12.1.0 (application was NOT working with the releases from v12.1.1 to v12.1.4).The expected behavior could be achieved if I set swcMinify to
false
in the configuration file.To Reproduce
Kindly follow instructions given in the README.md, Production-like local deployment.
More info on the problem could be found here and there.
Please, let me know if you have questions, or whether I should deeply investigate in a given direction, or if I can do anything here to help.
Thanks in advance for your time and investigation.
The text was updated successfully, but these errors were encountered: