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

Svelte 5: compileModule #250

Closed
Tracked by #234
yolk opened this issue Oct 11, 2024 · 3 comments
Closed
Tracked by #234

Svelte 5: compileModule #250

yolk opened this issue Oct 11, 2024 · 3 comments
Labels
enhancement New feature or request
Milestone

Comments

@yolk
Copy link

yolk commented Oct 11, 2024

esbuild-svelte ignores *.svelte.js and *.svelte.ts files containing runes from svelte 5.

To compile them, we would need to:

  1. Alter the default value of the include option (something like /\.svelte(\.ts|\.js)?$/)
  2. Detect module files before compilation and instead of calling the compile function call compileModule from 'svelte/compiler'.

This would solve the problem for 'svelte.js' files, but not for 'svelte.ts', because sveltePreprocess only compiles svelte components. Maybe we could compile/preprocess them with esbuild before calling compileModule?

Thx!

@EMH333 EMH333 added the enhancement New feature or request label Oct 12, 2024
@EMH333
Copy link
Owner

EMH333 commented Oct 12, 2024

This is interesting, thank you for bringing this to my attention.

I agree with your prognosis, supporting *.svelte.js files will be straightforward. Supporting TS svelte modules will be less straightforward, however using esbuild to transform TS into JS seems like the best path.

Update: Svelte 5 appears to natively support basic TS syntax. I'm debating whether the added complexity is worth it to compile module files down to JS before running through compileModule or do we rely on folks not wanting to use any of the unsupported native features.

@woutdp
Copy link

woutdp commented Nov 1, 2024

Super excited for this! Since you mentioned TS modules might be tricky, consider supporting .svelte.js without .svelte.ts for a first iteration as that would allow some usage of esbuild-svelte with Svelte 5.

@EMH333
Copy link
Owner

EMH333 commented Nov 9, 2024

Support has been released in v0.9.0

@EMH333 EMH333 closed this as completed Nov 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants