Closed AgarwalPragy closed 9 months ago
@dominikg I believe this is something that needs to happen at the bundler plugin level, right?
Temporary workaround provided by @dominikg via discord
with vite-plugin-svelte you can use
dynamicCompileOptions
to change it by file. https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/config.md#dynamiccompileoptions for vite 5/vite-plugin-svelte 3// svelte.config.js export default { //... vitePlugin:{ dynamicCompileOptions({filename}){ if(filename.includes('node_modules'){ return {runes: undefined} // or false, check what works } } } }
for sveltekit you have to add it as
vitePlugin.experimental.dynamicCompileOptions
This is working as expected. The dynamicCompileOptions
solution isn't a temporary workaround, it's explicitly the mechanism for having different compile options for different files
@Rich-Harris Setting dynamicCompileOptions
correctly to handle various libraries (svelte-4 and svelte-5) would be non-trivial for the users.
@dominikg mentioned the following via Discord.
workaround, we'll have to think about how this is supposed to work, there will be libraries for svelte4, svelte5 and both, and in the svelte5 case some might use runes while others might not. Optimal case is we have a declaration or heuristic so the bundler plugin knows which mode to use.
we may be able to pass more info into dynamicCompileOptions too. hopefully this is just needed for a transition period until libraries have been updated to support 5
Describe the bug
Non backwards-compatible Runes mode can be enabled via
compilerOptions
insvelte.config.js
https://svelte-5-preview.vercel.app/docs/runes#how-to-opt-inHowever, doing this enforces the runes mode even for external libraries. This means that any libraries written in svelte-4.x cannot be imported.
Ideally, runes mode should only be enforced for the current app and not the external libaries
Reproduction
https://github.com/AgarwalPragy/svelte-issue-9632
src/routes/+page.svelte
Logs
System Info
Severity
blocking an upgrade