@sveltejs/vite-plugin-svelte 4.0.0-next.4 → 4.0.0-next.5

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": "4.0.0-next.4",
3
+ "version": "4.0.0-next.5",
4
4
  "license": "MIT",
5
5
  "author": "dominikg",
6
6
  "files": [
@@ -37,7 +37,7 @@
37
37
  "homepage": "https://github.com/sveltejs/vite-plugin-svelte#readme",
38
38
  "dependencies": {
39
39
  "@sveltejs/vite-plugin-svelte-inspector": "^3.0.0-next.0||^3.0.0",
40
- "debug": "^4.3.5",
40
+ "debug": "^4.3.6",
41
41
  "deepmerge": "^4.3.1",
42
42
  "kleur": "^4.1.5",
43
43
  "magic-string": "^0.30.10",
@@ -50,9 +50,9 @@
50
50
  "devDependencies": {
51
51
  "@types/debug": "^4.1.12",
52
52
  "esbuild": "^0.23.0",
53
- "sass": "^1.77.6",
54
- "svelte": "^5.0.0-next.178",
55
- "vite": "^5.3.3"
53
+ "sass": "^1.77.8",
54
+ "svelte": "^5.0.0-next.200",
55
+ "vite": "^5.3.5"
56
56
  },
57
57
  "scripts": {
58
58
  "check:publint": "publint --strict",
@@ -2,6 +2,8 @@ import { readFileSync } from 'node:fs';
2
2
  import * as svelte from 'svelte/compiler';
3
3
  import { log } from './log.js';
4
4
  import { toESBuildError } from './error.js';
5
+ import { safeBase64Hash } from './hash.js';
6
+ import { normalize } from './id.js';
5
7
 
6
8
  /**
7
9
  * @typedef {NonNullable<import('vite').DepOptimizationOptions['esbuildOptions']>} EsbuildOptions
@@ -49,7 +51,7 @@ export function esbuildSveltePlugin(options) {
49
51
 
50
52
  /**
51
53
  * @param {import('../types/options.d.ts').ResolvedOptions} options
52
- * @param {{ filename: string; code: string }} input
54
+ * @param {{ filename: string, code: string }} input
53
55
  * @param {import('../types/vite-plugin-svelte-stats.d.ts').StatCollection} [statsCollection]
54
56
  * @returns {Promise<string>}
55
57
  */
@@ -68,6 +70,14 @@ async function compileSvelte(options, { filename, code }, statsCollection) {
68
70
  generate: 'client'
69
71
  };
70
72
 
73
+ if (compileOptions.hmr) {
74
+ if (options.emitCss) {
75
+ const hash = `s-${safeBase64Hash(normalize(filename, options.root))}`;
76
+ compileOptions.cssHash = () => hash;
77
+ }
78
+ compileOptions.hmr = false;
79
+ }
80
+
71
81
  let preprocessed;
72
82
 
73
83
  if (options.preprocess) {
package/src/utils/id.js CHANGED
@@ -133,7 +133,7 @@ function parseRequestQuery(rawQuery) {
133
133
  * @param {string} normalizedRoot
134
134
  * @returns {string}
135
135
  */
136
- function normalize(filename, normalizedRoot) {
136
+ export function normalize(filename, normalizedRoot) {
137
137
  return stripRoot(normalizePath(filename), normalizedRoot);
138
138
  }
139
139
 
@@ -61,7 +61,7 @@ export async function loadSvelteConfig(viteConfig, inlineOptions) {
61
61
  try {
62
62
  // identify which require function to use (esm and cjs mode)
63
63
  const _require = import.meta.url
64
- ? esmRequire ?? (esmRequire = createRequire(import.meta.url))
64
+ ? (esmRequire ?? (esmRequire = createRequire(import.meta.url)))
65
65
  : // eslint-disable-next-line no-undef
66
66
  require;
67
67