sveltejs/vite-plugin-svelte

Repository tracker

Pull requests

refactor: modular plugins

#1145
today • Jul 1, 2025
this grew rather large but sharing for better discussion goals: split into multiple plugins with clear responsibilities separate plugins for preprocess and compile fully embrace/adopt environment api improve filter use to ensure less work is done in rolldown-vite move plugins out of "pre" phase where possible Todo: Documentation about the preprocess/compile change and how to use it to transform preprocessor output with a vite plugin before compile deprecate api.sveltePreprocess with link to above docs discuss removing custom query support. lots of code/complication for no usage

Issues

known issues with rolldown-vite and svelte

#1143
8 days ago • Jun 23, 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

improve support for environment api

#1137
20 days ago • Jun 11, 2025
Describe the problem currently vite-plugin-svelte still uses the ssr flag passed to hooks, this only works due to vites fallback support. Describe the proposed solution switch to this.environment information and also see what we can do with the compile cache and possibly handleHotUpdate (ssr module invalidation) Alternatives considered keep as is, but it might lead to less optimal usage with environment api Importance would make my life easier

Split preprocessing and compiling into separate plugins

#729
26 days ago • Jun 5, 2025
Describe the problem I'd like to use https://github.com/antfu/vite-plugin-inspect to see the result of preprocessing. It shows the result of each Vite plugin. Since preprocessing and compiling currently happen in the same plugin it shows them occurring as a single step Describe the proposed solution Split preprocessing and compiling into separate plugins. I took a quick stab splitting them into separate methods (but still within a single plugin) here: https://github.com/benmccann/vite-plugin-svelte/tree/split-preprocessing. It seems I broke the tests with my attempt. It'd probably be better for someone more familiar with the codebase to do it Alternatives considered We could split each preprocessor into its own plugin. I think this would be more trouble than it's worth though. E.g. right now Svelte combines the source maps from all the preprocessors. We'd have to do the same and ensure we were giving the same results as Svelte. I think it'd be a lot easier to handle all preprocessors together in a single plugin and that will still provide a lot of value. Importance nice to have

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