sveltejs/vite-plugin-svelte

Repository tracker

Pull requests

chore(docs): restructure docs so they can be ingested by svelte.dev

#1201
yesterday • Aug 18, 2025
This moves the docs markdown files into a structure parsable by svelte.dev generator and adds symlinks in the old places so that existing links keep working.

feat: enable optimizer for server environments during dev

#1185
20 days ago • Jul 30, 2025
No description provided

Issues

prevent modification of internal api/config

#1173
20 days ago • Jul 30, 2025
Describe the problem see https://github.com/sveltejs/vite-plugin-svelte/pull/1172 due to a bug it was possible that other plugins modified internal configuration. Technically it is equally possible that other plugins grab our api from vite-plugin-svelte:config. This can produce hard to track bugs Describe the proposed solution Use deepFreeze or a proxy with throw in set to prevent modifications. Currently options.server is used to keep a reference to the vite devserver. This must not be frozen so we have to skip it somehow or move it out of our api for this to work. Alternatives considered leave it as is, check our codebase that we don't expose more through vites config hooks. Also see with vite why their config logic just took the array ref we gave it instead of pulling out the elements. Importance would make my life easier

Optimizing for server environments

#1181
20 days ago • Jul 30, 2025
Describe the problem When combined with @cloudflare/vite-plugin, most deps are prebundled before they are loaded by the workerd runtime during development. This means that the esbuild optimizer plugin should generate server code in these cases instead of always generating client code. https://github.com/sveltejs/vite-plugin-svelte/blob/3119a4b53f36835a5a8d28b19cfb7c47abb8bbbd/packages/vite-plugin-svelte/src/plugins/setup-optimizer.js#L199 This is important to enable SvelteKit to work with the Cloudflare Vite plugin in development, which currently receives client Svelte code when performing SSR. Describe the proposed solution The Svelte compiler generates client/server code depending on the Vite environment when optimizing dependencies. EDIT: sapphi mentioned it's possible to set a different esbuild plugin during the configureEnvironment hook Alternatives considered If we waited for Rolldown to officially replace esbuild, we wouldn't need to bother with tweaking the esbuild plugin. But I think that might still be a long time from now. We could also probably workaround this by ensuring SvelteKit doesn't get optimized during development. Importance I cannot use vite-plugin-svelte without it

known issues with rolldown-vite and svelte

#1143
Jul 2, 2025
[!NOTE] This is a meta-issue, content below is updated but not guaranteed to be up2date or complete. Please comment if something is fixed or an issue comes up that isn't listed here. Issues mentioning svelte in rolldown-vite and rolldown build [!CAUTION] the issues mentioned below can lead to larger build output and broken applications, do not deploy in production. fails to remove dead code code paths using if(condition) from `esm-env' are not removed when the condition is false https://github.com/rolldown/rolldown/issues/4786 https://github.com/rolldown/rolldown/issues/4258 https://github.com/vitejs/rolldown-vite/issues/229 This leads to larger output (eg development errorhandling is kept), but the app should still work as expected server output can contain code that should only be added to client https://github.com/rolldown/rolldown/issues/3403 This can lead to much larger output for server bundles, including broken apps. Example: svelte exports onMount as a noop ()=>{} unless the 'browser' exports condition is active so code like onMount(()=>doClientThings()) should not lead to any output for the server If doClientThings imported a large library that expects browser globals to be available, it'll crash the server. Even if the app keeps working it can put large client only libraries into the server bundle which can be very bad on edge deployments. emits empty css chunks empty CSS chunks are emitted for each Svelte file and they're also not in the Vite manifest, causing read errors when sveltekit traverses CSS imports for mapping/inlining https://github.com/vitejs/rolldown-vite/issues/267 dev currently no known issues for vite dev enableNativePlugins css is not applied https://github.com/vitejs/rolldown-vite/issues/213

support loading css first

#1032
Mar 12, 2025
Describe the problem Currently css is cached and returned as a virtual module when .svelte files are imported as js module. But with vite ?direct or ?inline query urls, it is possible that the first request is not for the js module but the css. Describe the proposed solution In case the cache is empty when css is requested, compile. Alternatives considered keep current behavior, styles might not be needed before the js module Importance nice to have

Can't inspect disabled elements

#997
Nov 1, 2024
Describe the bug if i have something like <button disabled> or <input disabled> it seems i can't inspect it Reproduction URL some other time, sorry Reproduction No response Logs No response System Info next

Docs on svelte.dev

#942
Jul 11, 2024
Describe the problem There's a desire to put docs for all the projects into the omnisite. vite-plugin-svelte doesn't really have a docs index page currently. There's the readme, but we might put different content on svelte.dev than what's there. There also isn't a clear order the docs pages should be displayed in the lefthand nav Describe the proposed solution Prefix the existing docs with 10-, 20-, etc. to provide an ordering that can be used in the lefthand nav. The docs with the smallest prefix should include some introductory material Alternatives considered it may be helpful to update the directory structure of various repos to align with each other, but I think that isn't strictly necessary and we can maintain a mapping of where docs live in each repo Importance i cannot use vite-plugin-svelte without it

svelte/internal import guard

#861
Feb 21, 2024
Describe the problem access to svelte/internal should be limited to blessed code (mostly compiler output). But for technical reasons it is exported from the svelte package and can be imported by anyone, and a lot of code does: https://github.com/search?q=%22svelte%2Finternal%22+&type=code Describe the proposed solution add a guard in resolveId that logs a warning or throws an error upon encountering such an import. Alternatives considered maybe eslint-plugin-svelte would also be able to flag these Importance nice to have