-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 ("es2015") is not supported yet #3482
Comments
There're 2 kinds of decorators, one is defined by TypeScript as a tsconfig field To enable it, you should add this config to your tsconfig.json: {
"compilerOptions": {
"experimentalDecorators": true
}
} |
Thanks, that works like a charm. The only problem I have now is that I get the following error in the browser:
I'm not sure if this has something to do with ESBuild or with ESM.sh... Should I open a separate issue for this? |
I guess you just import your bundled js into HTML via the
|
Many thanks for the support. It was because I had not set |
Hey so I am running into this issue with a JavaScript file that uses decorators...how can we overcome this? Shouldn't esbuild be able to treat decorators in a JavaScript file as TypeScript experimental decorators? |
Decorators in JavaScript files have been supported since version 0.21.0, which came out in May. It implements the JavaScript decorator proposal, which is different than the TypeScript experimental decorator proposal. So likely all you need to do is update your version of esbuild to the latest one and set your target correctly, and decorators should start working in JavaScript files (I'm assuming your problem is that you're using an old version of esbuild). The JavaScript decorator proposal is going to be the way decorators work going forward while the TypeScript experimental decorator proposal is only around for legacy reasons and will never be the way decorators work going forward, so I recommend using JavaScript decorators. But if you need to force esbuild to use TypeScript decorators in JavaScript files for some reason, then you can force esbuild to parse JavaScript files as TypeScript using something like |
Hey I'm currently trying to bundle a new project (Lit Framework) with ESBuild. The TypeScript version of the Lit Framework uses
@decorator
, how can I bundle it with ESBuild for the browser? If I use the--target=es5
or--target=es6
flag I get an error and if I do not use the flag then I get a syntax error in the browser.Perhaps I have also set a setting of ESBuild incorrectly! I hope that someone can help me with this.
CLI command used:
Error output:
How to reproduce:
Use this Components overview section from the original Lit website or any other code example where
@decorator
is used and try to bundle this code using the CLI command from above.The text was updated successfully, but these errors were encountered: