@vizejs/vite-plugin 0.153.0 → 0.154.0

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.
Files changed (2) hide show
  1. package/dist/index.mjs +15 -3
  2. package/package.json +3 -3
package/dist/index.mjs CHANGED
@@ -94,6 +94,12 @@ function hasDelegatedStyles(compiled) {
94
94
  function supportsTemplateOnlyHmr(output) {
95
95
  return /(?:^|\n)(?:_sfc_main|__sfc__)\.render\s*=\s*render\b/m.test(output);
96
96
  }
97
+ function insertAfterStaticImports(output, imports) {
98
+ let insertAt = 0;
99
+ for (const match of output.matchAll(/^import\b[^\n]*(?:\r?\n|$)/gm)) insertAt = (match.index ?? 0) + match[0].length;
100
+ if (insertAt === 0) return `${imports}\n${output}`;
101
+ return `${output.slice(0, insertAt)}${imports}\n${output.slice(insertAt)}`;
102
+ }
97
103
  function generateScopeId(filename) {
98
104
  return createHash("sha256").update(filename).digest("hex").slice(0, 8);
99
105
  }
@@ -153,7 +159,7 @@ function generateOutput(compiled, options) {
153
159
  }
154
160
  }
155
161
  const allImports = [...styleImports, ...cssModuleImports].join("\n");
156
- if (allImports) output = allImports + "\n" + output;
162
+ if (allImports) output = insertAfterStaticImports(output, allImports);
157
163
  if (cssModuleImports.length > 0) {
158
164
  const moduleBindings = [];
159
165
  for (const block of compiled.styles) if (isCssModule(block)) {
@@ -963,7 +969,8 @@ function loadHook(state, id, loadOptions) {
963
969
  if (id.startsWith("\0") && id.includes("?vue")) styleId = id.slice(1).replace(/\.module\.\w+$/, "").replace(/\.\w+$/, "");
964
970
  const styleRequest = classifyVitePluginRequest(styleId);
965
971
  if (styleRequest.isVueStyleQuery) {
966
- const realPath = classifyVitePluginRequest(styleRequest.path).vizeVirtualPath ?? styleRequest.path;
972
+ const sourceRequest = classifyVitePluginRequest(styleRequest.path);
973
+ const realPath = sourceRequest.vizeVirtualPath ?? sourceRequest.normalizedFsId ?? sourceRequest.normalizedVuePath ?? styleRequest.path;
967
974
  const lang = styleRequest.styleLang ?? null;
968
975
  const scoped = styleRequest.styleScoped ?? null;
969
976
  const fallbackCompiled = state.cache.get(realPath) ?? state.ssrCache.get(realPath);
@@ -1288,9 +1295,14 @@ function patchCssModuleGenerateScopedName(userConfig) {
1288
1295
  if (!cssModules || typeof cssModules.generateScopedName !== "function") return;
1289
1296
  const origFn = cssModules.generateScopedName;
1290
1297
  cssModules.generateScopedName = function(name, filename, css) {
1291
- return origFn.call(this, name, normalizeViteCssModuleFilename(filename), css);
1298
+ return origFn.call(this, name, normalizeCssModuleFilename(filename), css);
1292
1299
  };
1293
1300
  }
1301
+ function normalizeCssModuleFilename(filename) {
1302
+ const normalized = normalizeViteCssModuleFilename(filename);
1303
+ if (normalized.startsWith("/@fs/")) return normalized.slice(4);
1304
+ return normalized;
1305
+ }
1294
1306
  //#endregion
1295
1307
  //#region src/plugin/dev-middleware.ts
1296
1308
  function installVirtualAssetMiddleware(devServer, state) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizejs/vite-plugin",
3
- "version": "0.153.0",
3
+ "version": "0.154.0",
4
4
  "description": "High-performance native Vite plugin for Vue SFC compilation powered by Vize",
5
5
  "keywords": [
6
6
  "compiler",
@@ -39,9 +39,9 @@
39
39
  "access": "public"
40
40
  },
41
41
  "dependencies": {
42
- "@vizejs/native": "0.153.0",
42
+ "@vizejs/native": "0.154.0",
43
43
  "tinyglobby": "0.2.16",
44
- "vize": "0.153.0"
44
+ "vize": "0.154.0"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@types/node": "25.7.0",