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
Minifying the code in 3 passes leads to a syntax error #3051
Comments
It's because terser moves the |
This is not vite bug,is |
@ygj6 They are not the same. In your reproduction, the result contains the following code:
The output of terser is valid JavaScript. But in the original issue, it's
It results in a syntax error. The syntax error is caused by the text replacement of the import analysis plugin: vite/packages/vite/src/node/plugins/importAnalysisBuild.ts Lines 267 to 275 in 5c177db
|
@sodatea Promise.all(t.map((e=>{ compress.passes:3 output:
compress.passes:2 output:
|
@sodatea Learned it, thank you. So I don’t know if it should output |
@sodatea |
|
thx, I will do it right now. |
Describe the bug
If set up terser with
passes
>=3
The application does not load, you may see an error in the console:
The cause of the problem is the minification of the code using a terser. It occurs if 3 or more passes are configured.
I thought this was a problem with the terser and tried for a long time to reproduce the error in REPL. But no matter what I do, everything works as expected and it happens only when the code is optimized through the Vite.
Reproduction
Reproduction repo: cawa-93/vite-terser-issue
git clone git@github.com:cawa-93/vite-terser-issue.git
cd ./vite-terser-issue
npm ci
npm run build && npm run sevce
System Info
Used package manager: npm
Before submitting the issue, please make sure you do the following
The text was updated successfully, but these errors were encountered: