@sveltejs/vite-plugin-svelte 6.1.0 → 6.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": "6.1.
|
|
3
|
+
"version": "6.1.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "dominikg",
|
|
6
6
|
"files": [
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"homepage": "https://github.com/sveltejs/vite-plugin-svelte#readme",
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@sveltejs/vite-plugin-svelte-inspector": "^5.0.0
|
|
37
|
+
"@sveltejs/vite-plugin-svelte-inspector": "^5.0.0",
|
|
38
38
|
"debug": "^4.4.1",
|
|
39
39
|
"deepmerge": "^4.3.1",
|
|
40
40
|
"kleur": "^4.1.5",
|
|
@@ -47,9 +47,9 @@
|
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@types/debug": "^4.1.12",
|
|
50
|
-
"sass": "^1.
|
|
51
|
-
"svelte": "^5.
|
|
52
|
-
"vite": "^7.
|
|
50
|
+
"sass": "^1.90.0",
|
|
51
|
+
"svelte": "^5.38.0",
|
|
52
|
+
"vite": "^7.1.1"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"check:publint": "publint --strict",
|
|
@@ -8,9 +8,19 @@ const filter = { id: SVELTE_VIRTUAL_STYLE_ID_REGEX };
|
|
|
8
8
|
* @returns {import('vite').Plugin}
|
|
9
9
|
*/
|
|
10
10
|
export function loadCompiledCss(api) {
|
|
11
|
+
let useLocalCache = false;
|
|
12
|
+
|
|
13
|
+
/** @type{Map<string,any>} */
|
|
14
|
+
const buildWatchCssCache = new Map();
|
|
11
15
|
return {
|
|
12
16
|
name: 'vite-plugin-svelte:load-compiled-css',
|
|
13
17
|
|
|
18
|
+
configResolved(c) {
|
|
19
|
+
const isDev = c.command === 'serve';
|
|
20
|
+
const isBuildWatch = !!c.build?.watch;
|
|
21
|
+
useLocalCache = isDev || isBuildWatch;
|
|
22
|
+
},
|
|
23
|
+
|
|
14
24
|
resolveId: {
|
|
15
25
|
filter, // same filter in load to ensure minimal work
|
|
16
26
|
handler(id) {
|
|
@@ -26,7 +36,17 @@ export function loadCompiledCss(api) {
|
|
|
26
36
|
if (!svelteRequest) {
|
|
27
37
|
return;
|
|
28
38
|
}
|
|
29
|
-
|
|
39
|
+
let cachedCss = this.getModuleInfo(svelteRequest.filename)?.meta.svelte?.css;
|
|
40
|
+
// in `build --watch` or dev ssr reloads getModuleInfo only returns changed module data.
|
|
41
|
+
// To ensure virtual css is loaded unchanged, we cache it here separately
|
|
42
|
+
if (useLocalCache) {
|
|
43
|
+
if (cachedCss) {
|
|
44
|
+
buildWatchCssCache.set(svelteRequest.filename, cachedCss);
|
|
45
|
+
} else {
|
|
46
|
+
cachedCss = buildWatchCssCache.get(svelteRequest.filename);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
30
50
|
if (cachedCss) {
|
|
31
51
|
const { hasGlobal, ...css } = cachedCss;
|
|
32
52
|
if (hasGlobal === false) {
|
|
@@ -37,6 +57,8 @@ export function loadCompiledCss(api) {
|
|
|
37
57
|
}
|
|
38
58
|
css.moduleType = 'css';
|
|
39
59
|
return css;
|
|
60
|
+
} else {
|
|
61
|
+
log.warn(`failed to load virtual css module ${id}`, undefined, 'load');
|
|
40
62
|
}
|
|
41
63
|
}
|
|
42
64
|
}
|