Skip to content
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

Feature request: configure swc's target property #141

Closed
mbeckem opened this issue Aug 22, 2023 · 2 comments · Fixed by #149
Closed

Feature request: configure swc's target property #141

mbeckem opened this issue Aug 22, 2023 · 2 comments · Fixed by #149

Comments

@mbeckem
Copy link

mbeckem commented Aug 22, 2023

Hi,

during developement this plugin currently applies target: "es2020" to swc's JscTarget with no way to change the language level.

In our case this results in JavaScript's private fields being transpiled into WeakMaps, even though all major browser support this feature by now (this makes debugging classes using private fields very unpleasant).

It would help a lot if the plugin would support a target option, e.g.

react({ target: "2022" });

Alternatively, the default target could simply be raised.

Just out of curiosity, why does the plugin's transform hook run on "plain" .ts files (no JSX)?

Thanks!

@ArnaudBarre
Copy link
Member

Related: #138

I think the problem is to be solved at the core level. I need to investigate but I might push it in the next major coming in September.

The reason I used 2020 is to avoid having your dev env working in one browser but not another just because you use a new syntax. If the problem is not solved in core, I will bump it in this package to what Safari 15 as implemented at this time.

In the meantime I think using a one line patch is the best solution (using pnpm or patch-package)

It's enabled on TS to allow to disable esbuild completely, otherwise esbuild will run on SWC output for TSX. It's also expected for people using plugins.

@mbeckem
Copy link
Author

mbeckem commented Aug 22, 2023

Thank you for the explanation. A patch via pnpm is exactly what we're doing in the meantime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants