-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
Error [SyntaxError]: Unexpected token: punc (.), During Build, when using optional chaining in the code #565
Comments
Please upgrade rollup version and it already support optional chaining.See rollup/rollup#3582 |
@underfin this should not be closed. I am not using a separate roll-up build but vite to build the prod bundle. While it may be supported by roll-up its not supported by Terser which is the default minifier for vite:build. |
Hmmm. I realize it is not a bug for vite.... |
Making the esbuild target configurable would be great. @underfin would a PR be welcome? |
Yeah I think that would make sense. |
#155 fixed this until 893eeff#diff-1526d74dec8e3f18e0222b9a56b98254 reverted the change. |
There is actually currently no way to fix it in Vite because:
Basically, the way We have two options:
/cc @evanw |
There are other possible |
I tried |
@evanw thanks for the suggestion! |
🥳 Cool. Thanks. Do you make a rc2 from this one or do you want to wait fo more to come? |
Has this been solved? I also had problems when I was building. |
Describe the bug
When using
terser
minification (Which is the default), and one has some optional chaining in the code. Thebuild
fails with the error:Error [SyntaxError]: Unexpected token: punc (.)
This is because,
terser
does not supportoptional chaining
and a few otheres2020
features.Reproduction
This is because we chaged
esbuildservice.ts
https://github.com/vitejs/vite/blob/master/src/node/esbuildService.ts#L72
to always target
es2020
which is not always correct. We should either make it configurable, or read it from thetsconfig
file.System Info
vite
version: 1.0.0-beta.12Logs (Optional if provided reproduction)
The text was updated successfully, but these errors were encountered: