@sveltejs/vite-plugin-svelte 7.1.1 → 7.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/vite-plugin-svelte",
3
- "version": "7.1.1",
3
+ "version": "7.1.2",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "src",
@@ -39,18 +39,24 @@ export function loadCompiledCss(api) {
39
39
  if (!svelteRequest) {
40
40
  return;
41
41
  }
42
- // we need to re-resolve the ID in case the dep has been optimised by Vite
43
- // since it would now have a ?v=... query string suffix
44
- const resolvedId = await this.resolve(svelteRequest.filename);
45
- const moduleId = resolvedId?.id ?? svelteRequest.filename;
46
- let cachedCss = this.getModuleInfo(moduleId)?.meta.svelte?.css;
42
+
43
+ let cachedCss = this.getModuleInfo(svelteRequest.filename)?.meta.svelte?.css;
44
+ if (!cachedCss) {
45
+ // some module IDs have a ?v=... query string suffix in addition to the
46
+ // filename. We can retrieve this by running resolve again
47
+ const resolvedId = await this.resolve(svelteRequest.filename);
48
+ if (resolvedId?.id) {
49
+ cachedCss = this.getModuleInfo(resolvedId.id)?.meta.svelte?.css;
50
+ }
51
+ }
52
+
47
53
  // in `build --watch` or dev ssr reloads getModuleInfo only returns changed module data.
48
54
  // To ensure virtual css is loaded unchanged, we cache it here separately
49
55
  if (useLocalCache) {
50
56
  if (cachedCss) {
51
- buildWatchCssCache.set(moduleId, cachedCss);
57
+ buildWatchCssCache.set(svelteRequest.filename, cachedCss);
52
58
  } else {
53
- cachedCss = buildWatchCssCache.get(moduleId);
59
+ cachedCss = buildWatchCssCache.get(svelteRequest.filename);
54
60
  }
55
61
  }
56
62