Closed andersekdahl closed 6 months ago
Repository seems to be private.
@brunnerh Wops! Sorry, fixed now.
Thanks for the bug report! I'm running into the same issue
This is tricky. The strip happens in @sveltejs/package
because historically Svelte was then free of code needing to be preprocessed. But now that Svelte handles TypeScript in the template, just running a TypeScript preprocessor on the code will remove the TS code in the script tag but not in the template. The solution is to
lang="ts"
tag so that the Svelte parser can recognize TypeScript code, and take the hit of a needless script TypeScript preprocessingsvelte/compiler
, like transpile
preprocess
automatically, not sureI prefer the second or third option, because the first option would mean consumers of the library would be required to install TypeScript and set up the preprocessor for it.
We decided to make this a special-case in @sveltejs/package
: lang="ts"
will be preserved in it so that the Svelte parser knows how to handle it. As a follow-up we can likely omit preprocessing TypeScript inside Svelte entirely; Svelte itself can handle that now.
Describe the bug
TypeScript types like these: https://github.com/andersekdahl/svelte5-snippet-repro/blob/main/src/lib/MyComponent.svelte#L4
Are not removed when building, as seen here: https://github.com/andersekdahl/svelte5-snippet-repro/blob/main/dist/MyComponent.svelte#L3
Reproduction
Created a new library project using sveltekit with the latest svelte 5 release here: https://github.com/andersekdahl/svelte5-snippet-repro
Running
npm run package
will build the code and the issue is visible in the dist folder which I also commited to make it easier to spot the problem.Logs
No response
System Info
Severity
blocking an upgrade