@vizejs/vite-plugin 0.669.0 → 0.671.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.
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as VizeInspectorLintPlanProvider, b as VizeConfig, c as VizeCompatibilityOptions, d as LoadConfigOptions, f as ResolvedVizeConfig, h as VueOptionsEntry, i as VizeVueFeatures, l as VizeVueVersion, m as VueOptions, n as CompiledModule, o as VizeInspectorLintPlanRequest, p as UserConfigExport, r as MacroArtifact, s as VizeInspectorOptions, t as VizeOptions, u as ConfigEnv } from "./types-mem20MPI.mjs";
1
+ import { a as VizeInspectorLintPlanProvider, b as VizeConfig, c as VizeCompatibilityOptions, d as LoadConfigOptions, f as ResolvedVizeConfig, h as VueOptionsEntry, i as VizeVueFeatures, l as VizeVueVersion, m as VueOptions, n as CompiledModule, o as VizeInspectorLintPlanRequest, p as UserConfigExport, r as MacroArtifact, s as VizeInspectorOptions, t as VizeOptions, u as ConfigEnv } from "./types-gYK-MbLv.mjs";
2
2
  import { Plugin } from "vite";
3
3
 
4
4
  //#region src/plugin/compiler-config.d.ts
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { t as vize } from "./plugin-tuM13VgA.mjs";
1
+ import { t as vize } from "./plugin-BRR28jru.mjs";
2
2
  import { u as rewriteStaticAssetUrls } from "./vue-version-BFh0eI6J.mjs";
3
3
  import { a as resolveViteConfigExport, i as resolveConfigExport, n as defineConfig, o as vizeConfigStore, r as loadConfig, t as VIZE_CONFIG_FILE_ENV } from "./config-LlMZcDZI.mjs";
4
4
  //#region src/index.ts
@@ -1,4 +1,4 @@
1
- import { f as ResolvedVizeConfig } from "../types-mem20MPI.mjs";
1
+ import { f as ResolvedVizeConfig } from "../types-gYK-MbLv.mjs";
2
2
  import { ResolvedConfig } from "vite";
3
3
 
4
4
  //#region src/internal/config-bridge.d.ts
@@ -0,0 +1,2 @@
1
+ import { t as vize } from "./plugin-BRR28jru.mjs";
2
+ export { vize };
@@ -88,10 +88,34 @@ function styleFingerprint(module) {
88
88
  });
89
89
  }
90
90
  //#endregion
91
+ //#region ../shared/native-shape.ts
92
+ function utf16Offset(bytes, offset) {
93
+ if (offset == null || offset < 0 || !Number.isInteger(offset)) throw new Error("[vize] Missing native component export geometry.");
94
+ if (offset > bytes.length || offset < bytes.length && (bytes[offset] & 192) === 128) throw new Error("[vize] Invalid native component export geometry.");
95
+ return bytes.subarray(0, offset).toString("utf8").length;
96
+ }
97
+ /**
98
+ * Rewrite `export default X` to `const name = X` at the span the native
99
+ * compiler reported, converting its UTF-8 byte offsets against `module.code`.
100
+ * The span must still spell `export default` there, so a UTF-16 index or a span
101
+ * made stale by an earlier edit throws instead of corrupting the module.
102
+ */
103
+ function bindDefaultExport(module, shape, name) {
104
+ const bytes = Buffer.from(module.code);
105
+ const start = utf16Offset(bytes, shape.defaultExportStart);
106
+ const end = utf16Offset(bytes, shape.defaultExportKeywordEnd);
107
+ if (!/^export\s+default$/.test(module.code.slice(start, end))) throw new Error("[vize] Native component export geometry does not describe this module.");
108
+ module.replace(start, end, `const ${name} =`);
109
+ }
110
+ //#endregion
91
111
  //#region src/utils/module-output.ts
92
112
  const OUTPUT_PARSE_ID = "vize-output.tsx";
93
113
  const SFC_MAIN_NAME = "_sfc_main";
94
114
  const EXPORT_DEFAULT = "export default";
115
+ /** oxc and string indices count UTF-16 units; the native shape counts UTF-8 bytes. */
116
+ function byteOffset(code, index) {
117
+ return index == null ? null : Buffer.byteLength(code.slice(0, index));
118
+ }
95
119
  function isNode(value) {
96
120
  return value != null && typeof value === "object" && typeof value.type === "string";
97
121
  }
@@ -163,8 +187,8 @@ function analyzeFastDefaultOutput(code) {
163
187
  hasSfcMainDefined: false,
164
188
  hasNamedRenderExport: false,
165
189
  hasNamedSsrRenderExport: false,
166
- defaultExportStart,
167
- defaultExportKeywordEnd: defaultExportStart + 14,
190
+ defaultExportStart: byteOffset(code, defaultExportStart),
191
+ defaultExportKeywordEnd: byteOffset(code, defaultExportStart + 14),
168
192
  defaultExportEnd: null,
169
193
  defaultExportIsSfcMain: false
170
194
  };
@@ -191,36 +215,12 @@ function analyzeModuleOutput(code) {
191
215
  }),
192
216
  hasNamedRenderExport: exportedNames.includes("render"),
193
217
  hasNamedSsrRenderExport: exportedNames.includes("ssrRender"),
194
- defaultExportKeywordEnd,
195
- defaultExportStart,
196
- defaultExportEnd: getNodeEnd(defaultExport),
218
+ defaultExportKeywordEnd: byteOffset(code, defaultExportKeywordEnd),
219
+ defaultExportStart: byteOffset(code, defaultExportStart),
220
+ defaultExportEnd: byteOffset(code, getNodeEnd(defaultExport)),
197
221
  defaultExportIsSfcMain: isSfcMainDefaultExport(defaultExport)
198
222
  };
199
223
  }
200
- function rewriteDefaultExportToSfcMain(code, moduleInfo = {
201
- defaultExportKeywordEnd: null,
202
- defaultExportStart: null
203
- }) {
204
- let exportStart = moduleInfo.defaultExportStart;
205
- let keywordEnd = moduleInfo.defaultExportKeywordEnd;
206
- if (exportStart == null || keywordEnd == null) {
207
- const defaultExport = findDefaultExport(parseProgram(code));
208
- exportStart = getNodeStart(defaultExport);
209
- keywordEnd = defaultExport ? getExportDefaultKeywordEnd(code, defaultExport) : null;
210
- }
211
- if (exportStart == null || keywordEnd == null) return code;
212
- return `${code.slice(0, exportStart)}const ${SFC_MAIN_NAME} =${code.slice(keywordEnd)}`;
213
- }
214
- /**
215
- * Insert `insertion` before `export default _sfc_main`. `moduleInfo` must
216
- * describe `code` exactly (offsets are used verbatim), so the module is never
217
- * parsed again (#3425).
218
- */
219
- function insertBeforeSfcMainDefaultExport(code, insertion, moduleInfo) {
220
- const exportStart = moduleInfo.defaultExportStart;
221
- if (!moduleInfo.defaultExportIsSfcMain || exportStart == null) return code;
222
- return `${code.slice(0, exportStart)}${insertion}\n${code.slice(exportStart)}`;
223
- }
224
224
  //#endregion
225
225
  //#region ../shared/source-map.ts
226
226
  function isSourceMapV3(value) {
@@ -297,9 +297,9 @@ function prependMappedJsxCode(code, mapJson, prefix) {
297
297
  *
298
298
  * The native compiler returns a map for the module it emitted. `generateOutput`
299
299
  * then rewrites that module: it prepends a `<style>` injection, splices style
300
- * imports in after the last static import, inserts CSS-module wiring before the
301
- * default export, rewrites `export default` to `const _sfc_main =`, and appends
302
- * `__scopeId`/HMR code. All of those are whole-line insertions or same-line
300
+ * imports in after the last static import, rewrites `export default` to
301
+ * `const _sfc_main =`, and appends `__scopeId`, CSS-module wiring and HMR
302
+ * code. All of those are whole-line insertions or same-line
303
303
  * substitutions, which is exactly the class of edit a v3 `mappings` string can
304
304
  * absorb without being decoded:
305
305
  *
@@ -356,6 +356,10 @@ var MappedModule = class {
356
356
  const startsAtLineStart = prefix === 0 || previous.charCodeAt(prefix - 1) === 10;
357
357
  this.map = shiftMappedLines(this.map, startsAtLineStart ? editLine : editLine + 1, addedLines);
358
358
  }
359
+ /** Replace `code[start, end)`, in UTF-16 indices. */
360
+ replace(start, end, text) {
361
+ this.edit(`${this.code.slice(0, start)}${text}${this.code.slice(end)}`);
362
+ }
359
363
  };
360
364
  //#endregion
361
365
  //#region src/utils/component-output.ts
@@ -369,12 +373,12 @@ function assembleComponentOutput(compiled) {
369
373
  const hasSfcMainDefined = moduleInfo.hasSfcMainDefined;
370
374
  let exportsSfcMain = true;
371
375
  if (hasExportDefault && !hasSfcMainDefined) {
372
- emitted.edit(rewriteDefaultExportToSfcMain(emitted.code, moduleInfo));
376
+ bindDefaultExport(emitted, moduleInfo, "_sfc_main");
373
377
  if (compiled.hasScoped && compiled.scopeId) emitted.edit(`${emitted.code}\n_sfc_main.__scopeId = "data-v-${compiled.scopeId}";`);
374
378
  emitted.edit(`${emitted.code}\nexport default _sfc_main;`);
375
379
  } else if (hasExportDefault && hasSfcMainDefined) {
376
380
  exportsSfcMain = moduleInfo.defaultExportIsSfcMain;
377
- if (compiled.hasScoped && compiled.scopeId) emitted.edit(insertBeforeSfcMainDefaultExport(emitted.code, `_sfc_main.__scopeId = "data-v-${compiled.scopeId}";`, moduleInfo));
381
+ if (exportsSfcMain && compiled.hasScoped && compiled.scopeId) emitted.edit(`${emitted.code}\n_sfc_main.__scopeId = "data-v-${compiled.scopeId}";`);
378
382
  } else if (!hasExportDefault && !hasSfcMainDefined && hasNamedRenderExport) {
379
383
  const scope = compiled.hasScoped && compiled.scopeId ? `, __scopeId: "data-v-${compiled.scopeId}"` : "";
380
384
  emitted.edit(`${emitted.code}\nconst _sfc_main = { render${scope} };\nexport default _sfc_main;`);
@@ -728,7 +732,10 @@ function generateOutputWithMap(compiled, options) {
728
732
  params.set("index", String(block.index));
729
733
  if (block.scoped) params.set("scoped", `data-v-${compiled.scopeId}`);
730
734
  params.set("lang", lang);
731
- if (customElement) {
735
+ if (block.external) {
736
+ if (customElement) throw new Error(`<style src="${block.src}"> resolved to an external module, so it cannot be inlined into a custom element`);
737
+ styleImports.push(`import ${JSON.stringify(block.src)};`);
738
+ } else if (customElement) {
732
739
  if (isCssModule(block)) throw new Error("<style module> is not supported in custom element mode");
733
740
  params.set("inline", "");
734
741
  const bindingName = `_style_${block.index}`;
@@ -1076,11 +1083,11 @@ function ownersOfDependency(cache, resolvedDependency) {
1076
1083
  function isRelativeSfcSrc(src) {
1077
1084
  return src.startsWith("./") || src.startsWith("../");
1078
1085
  }
1079
- /** The file a block `src` names: next to the SFC, or where the bundler resolved it. */
1080
- function sfcSrcFile(importer, tag, src, resolutions) {
1081
- if (isRelativeSfcSrc(src)) return path.resolve(path.dirname(importer), src);
1082
- const file = resolutions?.get(src);
1083
- if (file !== void 0) return file;
1086
+ /** Where a block `src` points: next to the SFC, or where the bundler resolved it. */
1087
+ function sfcSrcTarget(importer, tag, src, resolutions) {
1088
+ if (isRelativeSfcSrc(src)) return { file: path.resolve(path.dirname(importer), src) };
1089
+ const resolution = resolutions?.get(src);
1090
+ if (resolution !== void 0) return resolution;
1084
1091
  throw new Error(`[vize] <${tag} src="${src}"> not found: the bundler resolved no file for this module request from ${importer}`);
1085
1092
  }
1086
1093
  /** Resolve an SFC's `src` module requests with the bundler's own resolver. */
@@ -1088,8 +1095,14 @@ async function resolveSfcSrcRequests(importer, requests, resolve) {
1088
1095
  const resolutions = /* @__PURE__ */ new Map();
1089
1096
  for (const request of new Set(requests)) {
1090
1097
  if (isRelativeSfcSrc(request)) continue;
1091
- const file = (await resolve(request, importer))?.replace(/[?#].*$/, "");
1092
- if (file && path.isAbsolute(file)) resolutions.set(request, file);
1098
+ const resolved = await resolve(request, importer);
1099
+ if (!resolved) continue;
1100
+ if (resolved.external) {
1101
+ resolutions.set(request, { external: true });
1102
+ continue;
1103
+ }
1104
+ const file = resolved.id.replace(/[?#].*$/, "");
1105
+ if (path.isAbsolute(file)) resolutions.set(request, { file });
1093
1106
  }
1094
1107
  return resolutions;
1095
1108
  }
@@ -1115,6 +1128,14 @@ function splitSrcAttribute(tag, openTag) {
1115
1128
  openTag: `${head}${rest}>`
1116
1129
  };
1117
1130
  }
1131
+ function needsContents(kind, block) {
1132
+ const compiled = "is compiled into the component, so vize needs its contents";
1133
+ if (kind === "template") return `the template ${compiled}`;
1134
+ if (kind === "script setup") return `<script setup> ${compiled}`;
1135
+ if (block.scoped) return "a scoped style needs its contents";
1136
+ if (block.module) return "a CSS module needs its contents";
1137
+ return null;
1138
+ }
1118
1139
  /** The `src` blocks the native parser finds, so `src` text in scripts or comments is not one. */
1119
1140
  function collectSrcBlocks(parseSfc, filePath, bytes, source) {
1120
1141
  let parsed;
@@ -1126,7 +1147,7 @@ function collectSrcBlocks(parseSfc, filePath, bytes, source) {
1126
1147
  const blocks = [
1127
1148
  ["template", parsed.template],
1128
1149
  ["script", parsed.script],
1129
- ["script", parsed.scriptSetup],
1150
+ ["script setup", parsed.scriptSetup],
1130
1151
  ...parsed.styles.map((style, index) => [
1131
1152
  "style",
1132
1153
  style,
@@ -1134,16 +1155,19 @@ function collectSrcBlocks(parseSfc, filePath, bytes, source) {
1134
1155
  ])
1135
1156
  ];
1136
1157
  const found = [];
1137
- for (const [tag, block, styleIndex] of blocks) {
1158
+ for (const [kind, block, styleIndex] of blocks) {
1138
1159
  if (!block) continue;
1160
+ const tag = kind === "script setup" ? "script" : kind;
1139
1161
  const { start, tagStart, tagEnd } = block.loc;
1140
1162
  const split = splitSrcAttribute(tag, bytes.subarray(tagStart, start).toString("utf8"));
1141
1163
  if (split) found.push({
1164
+ kind,
1142
1165
  tag,
1143
1166
  ...split,
1144
1167
  tagStart,
1145
1168
  tagEnd,
1146
- styleIndex
1169
+ styleIndex,
1170
+ needsContents: needsContents(kind, block)
1147
1171
  });
1148
1172
  }
1149
1173
  return found;
@@ -1153,46 +1177,66 @@ function listSfcSrcRequests(parseSfc, filePath, source) {
1153
1177
  if (!SRC_BLOCK_HINT.test(source)) return [];
1154
1178
  return collectSrcBlocks(parseSfc, filePath, Buffer.from(source), source).map((block) => block.src).filter((src) => !isRelativeSfcSrc(src));
1155
1179
  }
1156
- function readSrcBlock(filePath, tag, src, resolutions) {
1157
- const resolved = sfcSrcFile(filePath, tag, src, resolutions);
1180
+ function readSrcFile(filePath, tag, src, file) {
1158
1181
  try {
1159
- return {
1160
- path: resolved,
1161
- content: fs.readFileSync(resolved, "utf8")
1162
- };
1182
+ return fs.readFileSync(file, "utf8");
1163
1183
  } catch {
1164
- throw new Error(`[vize] <${tag} src="${src}"> not found (resolved: ${resolved}) in ${filePath}`);
1184
+ throw new Error(`[vize] <${tag} src="${src}"> not found (resolved: ${file}) in ${filePath}`);
1185
+ }
1186
+ }
1187
+ /**
1188
+ * The block for an external module, as `@vitejs/plugin-vue` keeps it: a style
1189
+ * stays in place for the output to import (`null`), a script imports it.
1190
+ */
1191
+ function externalSrcBlock(filePath, block) {
1192
+ if (block.needsContents) {
1193
+ const tag = `${block.openTag.slice(0, -1)} src="${block.src}">`;
1194
+ throw new Error(`[vize] ${tag} resolved to an external module; ${block.needsContents}. Let the bundler bundle "${block.src}" (in ${filePath})`);
1165
1195
  }
1196
+ if (block.kind === "style") return null;
1197
+ const request = JSON.stringify(block.src);
1198
+ return `${block.openTag}\nimport __vize_src_main__ from ${request};\nexport * from ${request};\nexport default __vize_src_main__;\n<\/script>`;
1166
1199
  }
1167
1200
  /**
1168
1201
  * Inline `<template src>`, `<script src>` and `<style src>` files into the SFC
1169
1202
  * source. Blocks are located by the native parser. Module requests come from
1170
- * the bundler's `resolutions` (see {@link sfcSrcFile}).
1203
+ * the bundler's `resolutions`; an external one stays an import.
1171
1204
  */
1172
1205
  function inlineSfcSrcBlocks(parseSfc, filePath, source, resolutions) {
1173
1206
  const styleSrcs = /* @__PURE__ */ new Map();
1174
1207
  if (!SRC_BLOCK_HINT.test(source)) return {
1175
1208
  source,
1176
1209
  dependencies: [],
1177
- styleSrcs
1210
+ styleSrcs,
1211
+ imports: []
1178
1212
  };
1179
1213
  const bytes = Buffer.from(source);
1180
1214
  const edits = [];
1181
1215
  const dependencies = [];
1216
+ const imports = [];
1182
1217
  for (const block of collectSrcBlocks(parseSfc, filePath, bytes, source)) {
1183
- const file = readSrcBlock(filePath, block.tag, block.src, resolutions);
1184
- dependencies.push(file.path);
1185
- if (block.styleIndex !== void 0) styleSrcs.set(block.styleIndex, file.path);
1186
- edits.push({
1218
+ const target = sfcSrcTarget(filePath, block.tag, block.src, resolutions);
1219
+ let text;
1220
+ if ("external" in target) {
1221
+ text = externalSrcBlock(filePath, block);
1222
+ if (text === null) imports.push(block.src);
1223
+ } else {
1224
+ const content = readSrcFile(filePath, block.tag, block.src, target.file);
1225
+ dependencies.push(target.file);
1226
+ if (block.styleIndex !== void 0) styleSrcs.set(block.styleIndex, target.file);
1227
+ text = `${block.openTag}\n${content}\n</${block.tag}>`;
1228
+ }
1229
+ if (text !== null) edits.push({
1187
1230
  start: block.tagStart,
1188
1231
  end: block.tagEnd,
1189
- text: `${block.openTag}\n${file.content}\n</${block.tag}>`
1232
+ text
1190
1233
  });
1191
1234
  }
1192
1235
  if (edits.length === 0) return {
1193
1236
  source,
1194
1237
  dependencies,
1195
- styleSrcs
1238
+ styleSrcs,
1239
+ imports
1196
1240
  };
1197
1241
  edits.sort((a, b) => a.start - b.start);
1198
1242
  const parts = [];
@@ -1205,9 +1249,20 @@ function inlineSfcSrcBlocks(parseSfc, filePath, source, resolutions) {
1205
1249
  return {
1206
1250
  source: Buffer.concat(parts).toString("utf8"),
1207
1251
  dependencies,
1208
- styleSrcs
1252
+ styleSrcs,
1253
+ imports
1209
1254
  };
1210
1255
  }
1256
+ /**
1257
+ * A `<style src>` the compiler still sees was not inlined. Only an external one
1258
+ * may stay, as an import; any other was written in a form the inliner cannot read.
1259
+ */
1260
+ function assertSfcStyleSrcImports(filePath, styles, imports = []) {
1261
+ for (const style of styles) {
1262
+ if (style.src == null || imports.includes(style.src)) continue;
1263
+ throw new Error(`[vize] ${filePath}: <style src=${JSON.stringify(style.src)}> could not be inlined. Write it as <style src="./file.css"> with a quoted path.`);
1264
+ }
1265
+ }
1211
1266
  //#endregion
1212
1267
  //#region src/compile-options.ts
1213
1268
  function buildCompileFileOptions(filePath, options, scopeId = generateScopeId(filePath, options.root, options.isProd ?? false)) {
@@ -1288,11 +1343,12 @@ var VizeSfcCompileError = class extends Error {
1288
1343
  function formatCompileErrorMessage(filePath, diagnostics) {
1289
1344
  return `[vize] Compilation failed in ${filePath}:\n${diagnostics.map((diagnostic) => ` - ${diagnostic}`).join("\n")}`;
1290
1345
  }
1291
- function normalizeStyleBlocks(styles, styleSrcs) {
1346
+ function normalizeStyleBlocks(styles, inlined) {
1292
1347
  if (!styles) return [];
1293
1348
  return styles.map((block) => ({
1294
1349
  content: block.content,
1295
- src: styleSrcs?.get(block.index) ?? block.src ?? null,
1350
+ src: inlined?.styleSrcs.get(block.index) ?? block.src ?? null,
1351
+ ...block.src != null && inlined?.imports.includes(block.src) ? { external: true } : {},
1296
1352
  lang: block.lang ?? null,
1297
1353
  scoped: block.scoped,
1298
1354
  module: block.module ? block.moduleName ?? true : false,
@@ -1305,6 +1361,7 @@ function compileFile(filePath, cache, options, source, diagnostics) {
1305
1361
  const scopeId = generateScopeId(filePath, options.root, options.isProd ?? false, content);
1306
1362
  const result = compileSfc(resolved.source, buildCompileFileOptions(filePath, options, scopeId));
1307
1363
  if (result.errors.length > 0) throw new VizeSfcCompileError(filePath, result.errors);
1364
+ assertSfcStyleSrcImports(filePath, result.styles ?? [], resolved.imports);
1308
1365
  if (result.warnings.length > 0 && (diagnostics?.logWarnings ?? true)) result.warnings.forEach((warning) => {
1309
1366
  console.warn(`[vize] Warning in ${filePath}: ${warning}`);
1310
1367
  });
@@ -1318,7 +1375,7 @@ function compileFile(filePath, cache, options, source, diagnostics) {
1318
1375
  styleHash: result.styleHash,
1319
1376
  scriptHash: result.scriptHash,
1320
1377
  macroArtifacts: result.macroArtifacts ?? [],
1321
- styles: normalizeStyleBlocks(result.styles, resolved.styleSrcs),
1378
+ styles: normalizeStyleBlocks(result.styles, resolved),
1322
1379
  dependencies: [...resolved.dependencies, ...result.dependencies ?? []]
1323
1380
  };
1324
1381
  cache.set(filePath, compiled);
@@ -1362,12 +1419,10 @@ function compileJsxModule(filePath, source, options = {}) {
1362
1419
  * Returns per-file results with content hashes for HMR.
1363
1420
  */
1364
1421
  function compileBatch(files, cache, options) {
1365
- const dependenciesByPath = /* @__PURE__ */ new Map();
1366
- const styleSrcsByPath = /* @__PURE__ */ new Map();
1422
+ const inlinedByPath = /* @__PURE__ */ new Map();
1367
1423
  const resolvedFiles = files.map((file) => {
1368
1424
  const resolved = inlineSfcSrcBlocks(native.parseSfc, file.path, file.source, options.srcResolutions?.get(file.path));
1369
- dependenciesByPath.set(file.path, resolved.dependencies);
1370
- styleSrcsByPath.set(file.path, resolved.styleSrcs);
1425
+ inlinedByPath.set(file.path, resolved);
1371
1426
  return {
1372
1427
  path: file.path,
1373
1428
  source: resolved.source,
@@ -1393,6 +1448,11 @@ function compileBatch(files, cache, options) {
1393
1448
  if (fallback.macroArtifacts !== void 0) fileResult.macroArtifacts = fallback.macroArtifacts;
1394
1449
  delete fileResult.moduleShape;
1395
1450
  }
1451
+ for (const fileResult of result.results) {
1452
+ if (fileResult.errors.length > 0) continue;
1453
+ const imports = inlinedByPath.get(fileResult.path)?.imports;
1454
+ assertSfcStyleSrcImports(fileResult.path, fileResult.styles ?? [], imports);
1455
+ }
1396
1456
  for (const fileResult of result.results) {
1397
1457
  if (fileResult.errors.length === 0) cache.set(fileResult.path, {
1398
1458
  code: fileResult.code,
@@ -1404,8 +1464,8 @@ function compileBatch(files, cache, options) {
1404
1464
  styleHash: fileResult.styleHash,
1405
1465
  scriptHash: fileResult.scriptHash,
1406
1466
  macroArtifacts: fileResult.macroArtifacts ?? [],
1407
- styles: normalizeStyleBlocks(fileResult.styles, styleSrcsByPath.get(fileResult.path)),
1408
- dependencies: [...dependenciesByPath.get(fileResult.path) ?? [], ...fileResult.dependencies ?? []]
1467
+ styles: normalizeStyleBlocks(fileResult.styles, inlinedByPath.get(fileResult.path)),
1468
+ dependencies: [...inlinedByPath.get(fileResult.path)?.dependencies ?? [], ...fileResult.dependencies ?? []]
1409
1469
  });
1410
1470
  if (fileResult.errors.length > 0) console.error(formatCompileErrorMessage(fileResult.path, fileResult.errors));
1411
1471
  if (fileResult.warnings.length > 0) fileResult.warnings.forEach((warning) => {
@@ -1916,13 +1976,6 @@ function shouldLoadCompiledVueSfcPath(state, realPath, hasNuxtComponentQuery = f
1916
1976
  }
1917
1977
  //#endregion
1918
1978
  //#region src/plugin/src-requests.ts
1919
- /** Vite's own resolver (aliases, packages, every `resolveId` plugin). */
1920
- function viteHostResolve(resolve) {
1921
- return async (request, importer) => {
1922
- const result = await resolve(request, importer);
1923
- return result && !result.external ? result.id : null;
1924
- };
1925
- }
1926
1979
  /**
1927
1980
  * Resolve one SFC's `src` module requests before the synchronous compile reads
1928
1981
  * them from `state.srcResolutions`. A request left unresolved fails that compile.
@@ -3691,7 +3744,7 @@ async function handleHotUpdateEnvironmentHook(state, environment, options) {
3691
3744
  }, {
3692
3745
  ensureAcceptingClientModule: (vueFile) => environment.moduleGraph.ensureEntryFromUrl(toPluginVisibleVirtualId(vueFile), false),
3693
3746
  requireAcceptingClientModule: true,
3694
- resolve: viteHostResolve((request, importer) => environment.pluginContainer.resolveId(request, importer)),
3747
+ resolve: (request, importer) => environment.pluginContainer.resolveId(request, importer),
3695
3748
  onRecompileError: () => {
3696
3749
  recompileFailed = true;
3697
3750
  }
@@ -3945,7 +3998,7 @@ function createPostTransformPlugin(state) {
3945
3998
  try {
3946
3999
  const isSsr = !!transformOptions?.ssr;
3947
4000
  const extractCss = shouldExtractCssForRequest(state, isSsr);
3948
- await prepareSfcSrcRequests(state, viteHostResolve((request, importer) => this.resolve(request, importer, { skipSelf: true })), id, source);
4001
+ await prepareSfcSrcRequests(state, (request, importer) => this.resolve(request, importer, { skipSelf: true }), id, source);
3949
4002
  const compiled = compileFile(id, getEnvironmentCache(state, isSsr), getCompileOptionsForRequest(state, isSsr, id), source);
3950
4003
  syncCollectedCssForFile({
3951
4004
  ...state,
@@ -4775,7 +4828,7 @@ function vize(options = {}, compilerDefaults = {}, hostContext) {
4775
4828
  await compileAll({
4776
4829
  ...state,
4777
4830
  extractCss: shouldExtractCssForBuild(state, this)
4778
- }, precompileInputOwners(this, precompileConfig), viteHostResolve((request, importer) => this.resolve(request, importer, { skipSelf: true })));
4831
+ }, precompileInputOwners(this, precompileConfig), (request, importer) => this.resolve(request, importer, { skipSelf: true }));
4779
4832
  } catch (error) {
4780
4833
  if (!(error instanceof PrecompileDiagnosticsError)) throw error;
4781
4834
  state.logger.warn(`${error.message}\nStartup scan diagnostics are deferred until import.`);
@@ -4789,7 +4842,7 @@ function vize(options = {}, compilerDefaults = {}, hostContext) {
4789
4842
  });
4790
4843
  },
4791
4844
  async load(id, loadOptions) {
4792
- const sfcSource = await prepareLoadSrcRequests(state, viteHostResolve((request, importer) => this.resolve(request, importer, { skipSelf: true })), id);
4845
+ const sfcSource = await prepareLoadSrcRequests(state, (request, importer) => this.resolve(request, importer, { skipSelf: true }), id);
4793
4846
  return loadHook(state, id, {
4794
4847
  ...loadOptions,
4795
4848
  ssr: resolveHookSsr(this, loadOptions),
@@ -4811,7 +4864,7 @@ function vize(options = {}, compilerDefaults = {}, hostContext) {
4811
4864
  },
4812
4865
  async handleHotUpdate(ctx) {
4813
4866
  const container = ctx.server.environments?.client?.pluginContainer ?? ctx.server.pluginContainer;
4814
- return handleHotUpdateHook(state, ctx, { resolve: viteHostResolve((request, importer) => container.resolveId(request, importer)) });
4867
+ return handleHotUpdateHook(state, ctx, { resolve: (request, importer) => container.resolveId(request, importer) });
4815
4868
  },
4816
4869
  generateBundle(_, bundle) {
4817
4870
  handleGenerateBundleHook({
@@ -1138,6 +1138,7 @@ interface VizeVueFeatures {
1138
1138
  }
1139
1139
  //#endregion
1140
1140
  //#region src/utils/module-output.d.ts
1141
+ /** The native `moduleShape`: offsets are UTF-8 bytes into the module. */
1141
1142
  type ModuleOutputInfo = {
1142
1143
  hasDefaultExport: boolean;
1143
1144
  hasSfcMainDefined: boolean;
@@ -1145,11 +1146,7 @@ type ModuleOutputInfo = {
1145
1146
  hasNamedSsrRenderExport: boolean;
1146
1147
  defaultExportKeywordEnd: number | null;
1147
1148
  defaultExportStart: number | null; /** End offset of the whole `export default ...` statement, or `null`. */
1148
- defaultExportEnd: number | null;
1149
- /**
1150
- * Whether the default export's declaration is exactly the `_sfc_main`
1151
- * identifier -- the only shape {@link insertBeforeSfcMainDefaultExport} acts on.
1152
- */
1149
+ defaultExportEnd: number | null; /** Whether the default export's declaration is exactly the `_sfc_main` identifier. */
1153
1150
  defaultExportIsSfcMain: boolean;
1154
1151
  };
1155
1152
  //#endregion
@@ -1,4 +1,4 @@
1
- import { _ as FormatterConfig, g as CompilerConfig, h as VueOptionsEntry, m as VueOptions, p as UserConfigExport, t as VizeOptions, v as LinterConfig, y as TypeCheckerConfig } from "./types-mem20MPI.mjs";
1
+ import { _ as FormatterConfig, g as CompilerConfig, h as VueOptionsEntry, m as VueOptions, p as UserConfigExport, t as VizeOptions, v as LinterConfig, y as TypeCheckerConfig } from "./types-gYK-MbLv.mjs";
2
2
  import { ConfigEnv, UserConfig, defineConfig as defineConfig$1 } from "vite-plus";
3
3
 
4
4
  //#region src/vite-plus/types.d.ts
@@ -400,7 +400,7 @@ function defineConfig(config = {}, integration = {}) {
400
400
  const legacy = compiler !== false && (await import("./vue-version-DOjZaMiI.mjs")).isLegacyVueCompatibilityMode(compiler);
401
401
  const plugins = compiler === false || legacy ? [...vp.plugins ?? []] : await withoutVueCompiler(vp.plugins ?? []);
402
402
  if (compiler !== false) {
403
- const { vize } = await import("./plugin-CFfuvH8O.mjs");
403
+ const { vize } = await import("./plugin-B4z8Tx1Z.mjs");
404
404
  plugins.push(vize({
405
405
  ...plugin,
406
406
  configMode: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizejs/vite-plugin",
3
- "version": "0.669.0",
3
+ "version": "0.671.0",
4
4
  "description": "High-performance native Vite plugin for Vue SFC compilation powered by Vize",
5
5
  "keywords": [
6
6
  "compiler",
@@ -51,13 +51,13 @@
51
51
  "access": "public"
52
52
  },
53
53
  "dependencies": {
54
- "@vizejs/native": "0.669.0",
55
- "@vizejs/unplugin": "0.669.0",
54
+ "@vizejs/native": "0.671.0",
55
+ "@vizejs/unplugin": "0.671.0",
56
56
  "jsonc-parser": "^3.3.1",
57
57
  "oxc-parser": "0.144.0",
58
58
  "picomatch": "4.0.5",
59
59
  "tinyglobby": "0.2.17",
60
- "vize": "0.669.0"
60
+ "vize": "0.671.0"
61
61
  },
62
62
  "devDependencies": {
63
63
  "@types/node": "25.9.2",
@@ -1,2 +0,0 @@
1
- import { t as vize } from "./plugin-tuM13VgA.mjs";
2
- export { vize };