-
-
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
The results of code compiled with vite and code compiled directly with esbuild are inconsistent,Decorators related issues #18105
Comments
Start a new pull request in StackBlitz Codeflow. |
Related issues This problem is also caused by the decorator,Decorators related issues |
https://esbuild.github.io/content-types/#tsconfig-json If I use a decorator This rule is too hidden, and it does not use the configuration in tsconfig.json, so additional configuration is required.
This problem makes me sad. Can this rule be made better? For example, tsconfigRaw will replace compilerOptions with the configuration in tsconfig.json by default |
Vite should automatically read user's One caveat is that, when you don't have |
Feel your reply That's because esbuild in your vite.config.ts contains target:es2020. If you delete target:es2020, the execution error occurs because this code in your vite sets useDefineForClassFields to false when both target and useDefineForClassFields do not exist. It does not read the configuration of tsconfig.json. |
@alamhubb Right, I was merely suggesting that you can move I experimented with tsc and esbuild on my own https://github.com/hi-ogawa/reproductions/tree/main/vite-18105-decorator-useDefineForClassFields and this might be still considered as esbuild's issue. |
I understand why deleting es2020 will cause an execution error. Because deleting es2020 will cause esbuild's default{target:esnext}. Esnext is based on the tc39 decorator specification and does not support automatic conversion of decorators, while es2020 does. Therefore, even if |
I think tsc is wrong, and esbuild is right. According to my understanding, when It should only be a property of DecClass when esbuild does this, while tsc ignores I looked up the relevant documentation of ts and did not find any explanation for this part |
Thank you very much. I understand the problem. Vite can read the configuration in the tsconfig.json file correctly. The problem is vite:vue vitejs/vite-plugin-vue#444 , not vite. There is a problem with my previous test method. I did not correctly distinguish vite from vite:vue. Thank you for your answer. |
Describe the bug
The execution results of vite and esbuild are consistent
Reproduction
https://stackblitz.com/edit/vitejs-vite-zmqkuj?file=vite.config.ts,index.html,package.json&terminal=dev
Steps to reproduce
You can get the compiled main.ts from the developer tools at https://stackblitz.com/edit/vitejs-vite-zmqkuj?file=vite.config.ts,index.html,package.json&terminal=dev
Use esbuild (0.21.5) to execute locally
npx esbuild main.ts --target=es2020 --outfile=out.js; node out.js
The resulting file is
The result of code execution is
The correct result was 666
The result obtained in
https://stackblitz.com/edit/vitejs-vite-zmqkuj?file=vite.config.ts,index.html,package.json&terminal=dev
is
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: