-
-
Notifications
You must be signed in to change notification settings - Fork 6.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
vite:dep-scan transformations can cause syntax errors confusingly reported by esbuild #2528
Comments
It would be ideal to avoid incurring the cost of full AST parses here. It seems this edge case is easy to fix though. |
That's a nice (and simple) fix. Thanks! |
It seems like this problem also applies to the use of for await loops to;
In this case await is still replaced with void and is causing an syntax error
|
@rangoy are you experiencing this error in development? you might need to force esbuild to higher version as it seems there have been a for loop code generation fix in this version https://github.com/evanw/esbuild/releases/tag/v0.12.2 |
@Niputi, I'm experiencing this in development when running I haven't traced the to the core but what I see is that it is related to the same replace; I can use one of the following workarounds to get it working now;
|
I'm not sure if I get the reason why these replaces has to be done but I guess adding a new replace before the one changed in cbfc3e9 could solve the issue Something like (untested)
|
This issue has been locked since it has been closed for more than 14 days. If you have found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest Vite version. If you have any other comments you should join the chat at Vite Land or create a new discussion. |
For example, if you write the code (notice
await
in a comment):The code here:
vite/packages/vite/src/node/optimizer/scan.ts
Lines 221 to 223 in d3142cf
will produce the following code to get sent to esbuild:
User will just see this error:
Does a proper parse need to happen to not secretly cause these issues or would a naive 'in comment' or 'in string' heuristic be good enough? At the very least it would maybe be nice to see what the code esbuild errored on but that seems non-trivial given it is just provided entries and then communicates back progress asynchronously?
The text was updated successfully, but these errors were encountered: