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
Transforming JavaScript decorators to the configured target environment ("es2019") is not supported yet #21756
Comments
This is likely an upstream nitro issue (or configuration issue). The correct way to set the nitro esbuild target here is: export default defineNuxtConfig({
nitro: {
esbuild: {
options: {
target: 'esnext'
}
},
},
}) You may also need to inject a rollup plugin in the nitro pipeline to transform the decorators, as there is another rollup plugin used by Nitro that clearly does not understand them. Maybe it might be worth adding a hook to allow manipulation of generated nitro rollup config upstream? cc: @pi0 |
The error message seems to come from esbuild (ref). The phrase,
I checked the issue referred in the commit message (unjs/nitro#189), but would be a wrong reference. @danielroe should know which issue was actual one. The below is just for your information about recent esbuild situation. esbuild author says JavaScript (native) decorators came to be supposed as of esbuild v0.18.5, but current stable Vite (v4.3.9) doesn't support the version. Vite v4.4.0-beta supports the latest esbuild and your issue might be (partially) resolved once Nuxt bumps up Vite version to the next. Currently, Nuxt uses v4.3.9 (ref). I'm not sure about when inversify package will support JavaScript native decorators. |
I saw this issue go by and figured I'd add a comment. The problem is likely that |
|
This was fixed in For those who encounter the same issue:
export default defineNuxtConfig({
nitro: {
esbuild: {
options: {
tsconfigRaw: {
compilerOptions: {
experimentalDecorators: true
}
}
}
}
}
}) @danielroe @NozomuIkuta @evanw Thank you so much for helping to solve this problem! <3 |
Same here |
Update here, adding
to the |
Transforming JavaScript decorators to the configured target environment ("es2019") is not supported yet I use typeorm to prompt for this. How should I solve it? |
#21756 (comment)
Additionally, configure in the nuxt.config.ts file:
Option 2:
@danielroe @NozomuIkuta @productdevbook Why is it necessary to configure both tsconfig.json and nuxt.config.ts files in Option 1? Why doesn't esbuild automatically use the relevant configurations from the tsconfig.json file? After all, the configuration part in the nuxt.config.ts file, tsconfigRaw: {}, is empty, indicating that nothing is specified, and it seems that the final configurations are still read from the tsconfig.json file. I wonder if there is room for optimization in this aspect for Nuxt. |
Environment
Linux
v16.20.0
3.6.0
2.5.1
npm@9.4.2
vite
alias, nitro
-
-
Reproduction
https://stackblitz.com/edit/github-jr6tha?file=server%2Fcontrollers%2Fdocument.controller.ts
Describe the bug
im experiencing an issue where the TypeScript compiler cant transform JavaScript decorators to the "es2019" target environment, despite correctly setting up the tsconfig.json with experimental decorators enabled. This problem just started recently, while the project was previously working fine.
Additional context
The following configuration in
nuxt.config.ts
also doesnt work and begins to terminate the build with an error:RollupError: Unexpected character '@' (Note that you need plugins to import files that are not JavaScript).
Logs
The text was updated successfully, but these errors were encountered: