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

Controlling esbuild options while transpiling script tags #52

Closed
5 of 6 tasks
segevfiner opened this issue Dec 12, 2022 · 1 comment
Closed
5 of 6 tasks

Controlling esbuild options while transpiling script tags #52

segevfiner opened this issue Dec 12, 2022 · 1 comment

Comments

@segevfiner
Copy link

Related plugins

Description

I want to be able to control the esbuild options used when transpiling SFC script tags. Vite itself provides the esbuild options key but this isn't used with vite-plugin-vue and I don't seem to have a way to make it apply to plain JS files as well unlike I can with the esbuild key. The reason is that I wanted to try and use the esbuild, supported option to get it to transpile async-await as async generators so that it works with zone.js which haven't bothered implementing a different solution for this. (They add the babel plugin which does this transform or otherwise do it themselves in project templates which need it AFAIK)

Suggested solution

Provide a way to control the esbuild option used when transpiling script tags, as well as allowing to apply esbuild to plain JS files.

Alternative

Add a plugin which does the necessary transfom or transpilation after vite-plugin-vue. But that will require an extra transpilation step which will be slower and is harder to code. The vanilla esbuild plugin of Vite doesn't work to transpile the output of plugin-vue as it doesn't know to correctly map the vue file extension of the already transpiled script to the esbuild js loader so it just errors with an unknown loader. Another option is making the builtin esbuild it know that it should load vue files as js, assuming they were output by vite-plugin-vue

Additional context

Zone.js doesn't support native async/await angular/angular#31730, and the current badly documented workaround they implemented is to set esbuild to transpile/downlevel async-await, and when async generators are used, they also use babel to transpile them as well https://github.com/angular/angular-cli/blob/25eaaa24b51af400262b97b4d4be2391ebd4a82d/packages/angular_devkit/build_angular/src/babel/presets/application.ts#L232-L233 as esbuild doesn't support that. Due to this, even if support is added for this, we will still need the additional transformation.

Validations

@sapphi-red
Copy link
Member

This is implemented by #444

@github-actions github-actions bot locked and limited conversation to collaborators Oct 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants