-
-
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
Using vite 4.4.0 or 4.4.1 breaks Typescript decorator support in some projects #13736
Comments
Start a new pull request in StackBlitz Codeflow. |
I've read through the breaking changes in esbuild (https://github.com/evanw/esbuild/blob/main/CHANGELOG.md#0180:~:text=Prefer%20.js%20over%20.ts%20within%20node_modules%20(%233019)) and can just assume that something there affects this case... |
me too |
Same here. Here's the reproduction - https://codesandbox.io/p/sandbox/typescript-playground-export-forked-x2lj66?file=%2Fpackage.json%3A6%2C19; Steps to reproduce If you change the resolution of |
Specifying |
No solution to the problem. |
Likely related to #13525, maybe we need to set |
starting esbuild 0.18.5 ECMA |
|
We also had |
same as you, we already set it in tsconfig.json, still throw err |
Another way to make sure if export default {
esbuild: {
tsconfigRaw: {
compilerOptions: {
experimentalDecorators: true,
},
},
},
} It could be that your tsconfig isn't |
Same issue here, tsconfig is correct. I also tried with the suggestion above adding it to vite.config.js without luck |
The error doesnt happen when the package comes from npm - but it does reproduce with the package installed via a local file path |
Can confirm this same issue in Aurelia projects. Enabling experimental decorators via tsconfig does not fix the problem. |
Not working here either.
Already got |
This comment was marked as duplicate.
This comment was marked as duplicate.
Can anyone share a repro? There's only one (#13736 (comment)) and that worked when I set |
https://stackblitz.com/edit/au2-conventions-qvwece?file=tsconfig.json |
I just had a case where decorators silently failed for fields (no invocation of the decorator function!) Took me a while to find this since I didnt get any errors |
@CollinHerber Thanks! I was able to track down another spot to fix, will handle that in the PR too. As a workaround, you can set this in your optimizeDeps: {
esbuildOptions: {
tsconfigRaw: {
compilerOptions: {
experimentalDecorators: true
}
}
}
} |
In my case, Vite 4.4.x fails with the following declaration (but Vite 3.3.9 succeeds):
The error is: I do have Update Setting Update 2 Instead of setting
And it works. |
As a workaround I found that if you're using Nuxt 3 you can give some tsconfig to esbuild which is used internally inside nitro. export default defineNuxtConfig({
nitro: {
esbuild: {
options: {
target: "esnext",
tsconfigRaw: {
compilerOptions: {
experimentalDecorators: true,
emitDecoratorMetadata: true,
},
},
},
},
},
}); |
Describe the bug
I'm a bit at a loss at what's going on - in a project I have using vite 4.4.0 or 4.4.1 breaks decorators in TypeScript, but going back to 4.3.9 fixes the issue.
All I'm getting on 4.4.0 is
SyntaxError: Invalid character: '@'
(on some code on our end that uses decorators), while in 4.3.9 everything works.What is extra weird is that I can't reproduce the issue on StackBlitz even with the same setup / configs in place. I've included my tests so far nonetheless, as I can 100% reproduce the issue locally by switching between vite 4.4.0 and 4.3.9 as dependency.
Discord discussion: https://discord.com/channels/804011606160703521/804011606160703524/1126556878676168784
Reproduction
Tried to repro here but no luck so far: https://stackblitz.com/edit/vitejs-vite-ojnmgf?file=myPackage%2FmyCode.ts
Steps to reproduce
No response
System Info
Used Package Manager
npm
Logs
Click to expand!
SyntaxError: Invalid character: '@'
Validations
The text was updated successfully, but these errors were encountered: