Deferred from PR #237. The 6.0.4 release would let us drop the local --legacy-peer-deps workaround (it widens peerOptional typescript to ^5.0.0 || ^6.0.0), but the same release rewrote the TypeScript processor's dynamic import in a way that breaks vite-plugin-svelte's preprocess step.
Symptom
npm run build fails on every .svelte file with a <script lang="ts"> block:
[plugin vite-plugin-svelte:preprocess] /.../src/routes/(marketing)/+layout.svelte
RolldownError: Cannot find module '/.../node_modules/svelte-preprocess/dist/transformers/typescript'
imported from /.../node_modules/svelte-preprocess/dist/autoProcess.js
Root cause
dist/processors/typescript.js changed between 6.0.3 and 6.0.4:
-const { transformer } = await Promise.resolve().then(() => __importStar(require('../transformers/typescript')))
+const { transformer } = await import('../transformers/typescript.js')
The new dynamic ESM-style import() in a CJS package ("type": "commonjs") isn't resolving correctly when invoked through vite-plugin-svelte's preprocess pipeline — the error path strips the .js suffix at resolution time. Likely an upstream bug in svelte-preprocess.
What to do
- Wait for a 6.0.5 release that either reverts the dynamic-import change or fixes the resolution path.
- When retrying, run
npm install svelte-preprocess@<v>, drop the manifest pin, and verify npm run build succeeds on a clean checkout before pushing.
- If/when this lands, the repo can also drop the
--legacy-peer-deps install workaround (6.0.4+ accepts typescript ^6).
Upstream
No issue filed at sveltejs/svelte-preprocess yet — worth a search before reproducing.
Deferred from PR #237. The 6.0.4 release would let us drop the local
--legacy-peer-depsworkaround (it widenspeerOptional typescriptto^5.0.0 || ^6.0.0), but the same release rewrote the TypeScript processor's dynamic import in a way that breaksvite-plugin-svelte's preprocess step.Symptom
npm run buildfails on every.sveltefile with a<script lang="ts">block:Root cause
dist/processors/typescript.jschanged between 6.0.3 and 6.0.4:The new dynamic ESM-style
import()in a CJS package ("type": "commonjs") isn't resolving correctly when invoked through vite-plugin-svelte's preprocess pipeline — the error path strips the.jssuffix at resolution time. Likely an upstream bug in svelte-preprocess.What to do
npm install svelte-preprocess@<v>, drop the manifest pin, and verifynpm run buildsucceeds on a clean checkout before pushing.--legacy-peer-depsinstall workaround (6.0.4+ accepts typescript ^6).Upstream
No issue filed at sveltejs/svelte-preprocess yet — worth a search before reproducing.