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

can you use svelte plugin and have typescript support? #1746

Closed
jeberly opened this issue Nov 4, 2021 · 1 comment
Closed

can you use svelte plugin and have typescript support? #1746

jeberly opened this issue Nov 4, 2021 · 1 comment

Comments

@jeberly
Copy link

jeberly commented Nov 4, 2021

I almost don't want to ask, because it seems Svelte's compilation weirdness has been tricky to work with but here goes...

Is it possible to use the svelte plugin https://esbuild.github.io/plugins/#svelte-plugin and have typescript enabled and used in Svelte? Including using it with watch and having it output proper error line/columns in the original svelte source code?

Thanks again the effort put into esbuild! I appreciate the scope of the project. I have managed to get something cobbled together using esbuild w/ watch, svelte-preprocess-esbuild and esbuild-svelte but line numbers on errors are not accurate.

Thanks in advance!

@evanw
Copy link
Owner

evanw commented Nov 4, 2021

I’m not sure, sorry. I don’t know anything about Svelte. The Svelte plugin in the documentation is just a quick example of doing a single source code transformation with source maps. It’s not meant to be a production quality plugin.

At a high level, you would have to transform the code with source map aware tools at each step. For example if the Svelte compiler has a hook to transform TypeScript strings contained within it, the Svelte compiler would need to pass a source map to the TypeScript transformer, the TypeScript transformer would need to transform the source map along with the source, and then the Svelte compiler would need to accept the source map from the TypeScript transformer and transform it again along with the Svelte compilation.

You could check the existing plugin list to see if someone has already figured this out and/or work with them to add this feature: https://github.com/esbuild/community-plugins. Otherwise you could try to build it yourself.

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

No branches or pull requests

2 participants