Skip to content

plugin-vue-jsx: Allow esbuild to perform typescript transformation #556

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

Open
5 of 6 tasks
madeofsun opened this issue Mar 27, 2025 · 0 comments
Open
5 of 6 tasks

Comments

@madeofsun
Copy link

madeofsun commented Mar 27, 2025

Related plugins

Description

In the current implementation of plugin-vue-jsx typescript transformation for ".tsx" files is done by the babel plugin instead of esbuild.

The main problem with such approach is that the same non-jsx code in "ts" and "tsx" may behave differently since transformation by '@babel/plugin-transform-typescript' does not take into account tsconfig options like esbuild does.
Moreover the transformation may require additional babelPlugins like babel-plugin-proposal-decorators or babel-plugin-transform-class-properties and they are not fully equivalent to what is expected in typescript (example).

As I see it, the proper behaviour is that plugin-vue-jsx transforms only the jsx syntax and all other typescript syntax is handled by esbuild.

Suggested solution

Proposed solution:

  • The changes are enabled by a new tsTransform: 'esbuild' | 'babel' option with value 'esbuild'. By default 'babel' is used to prevent breakage.
  • '@babel/plugin-syntax-typescript' should be used instead of '@babel/plugin-transform-typescript' - it does not perform any transformations.
  • esbuild.include should not be overriden in the "config" hook
  • "transform" hook should have an order: 'pre' to run before esbuild transformation
  • If plugin-vue-jsx consumers would like to enable support for decorators or other opt-in syntax, they should pass corresponding "syntax" (that affect parser only) plugins to babelPlugins

If the concept of solution is OK, I can try to implement it (if you are OK with it).

Alternative

No response

Additional context

No response

Validations

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

No branches or pull requests

1 participant