@vizejs/unplugin 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/README.md CHANGED
@@ -116,7 +116,7 @@ TypeScript/JSX transforms in the pipeline if your SFC scripts use those syntaxes
116
116
 
117
117
  - Vite is still the recommended integration if you need the most complete behavior today.
118
118
  - Every `<style>` block, including a `<style scoped>` in a `.jsx` or `.tsx` component, is a stylesheet module for the bundler's CSS pipeline, which writes the CSS file, as with `unplugin-vue`. The module is named like Vue's style requests, `App.vue?vue&type=style&index=0&lang.css` (`lang.module.css`, `lang.scss`), so a pipeline that handles a `.css` or `.scss` file handles the block: tsdown with `@tsdown/css` writes `style.css`, esbuild writes `<entry>.css` (set `outdir` or `outfile`), Rollup needs a CSS plugin such as `rollup-plugin-postcss`, and webpack uses your `.css` rule. A build with no CSS pipeline fails on the first style block. Rolldown alone does not bundle CSS, so build through tsdown or Vite.
119
- - `<style src>`, `<script src>` and `<template src>` follow Vue's SFC spec, as in `@vitejs/plugin-vue`: a `./` or `../` path is read next to the SFC, and any other `src` (a package such as `modern-normalize/modern-normalize.css`, an alias, an absolute path, or a bare `foo.css`) is a module request resolved by the bundler's own resolver. The file is inlined before compilation and watched. A request that resolves to no file, including an external module, is a build error.
119
+ - `<style src>`, `<script src>` and `<template src>` follow Vue's SFC spec, as in `@vitejs/plugin-vue`: a `./` or `../` path is read next to the SFC, and any other `src` (a package such as `modern-normalize/modern-normalize.css`, an alias, an absolute path, or a bare `foo.css`) is a module request resolved by the bundler's own resolver. The file is inlined before compilation and watched. A `<style src>` block's stylesheet module sits beside its file, so its relative `@import`, `@use` and `url()` resolve from there, as when the file is imported directly. A module the bundler keeps external (tsdown keeps `dependencies` external) stays an import, as in `@vitejs/plugin-vue`: `<style src>` becomes `import "…"` and `<script src>` imports the component from it. `<template src>`, `<script setup src>` and a scoped or module `<style src>` are compiled into the component, so an external one is a build error; let the bundler bundle it. A request that resolves to nothing is a build error.
120
120
  - Babel and esbuild without `bundle` bundle no stylesheet, so there the compiled CSS is injected into JavaScript at run time, CSS Modules included. A preprocessor block or an `@import` is a build error there, since nothing compiles or resolves it.
121
121
  - CSS Modules and preprocessors depend on the host bundler CSS pipeline and are more likely to change than the Vite path.
122
122
  - Scoped preprocessor styles are compiled before they are scoped, as in Vue: Webpack uses your `.scss`/`.less`/`.styl` rules, while Rollup, Rolldown and esbuild run the project's installed `sass` (or `sass-embedded`), `less` or `stylus`. Unscoped preprocessor blocks go to the host's preprocessor (`@tsdown/css`, `rollup-plugin-postcss`, your webpack rules), except under esbuild, whose CSS loaders compile none, so the plugin runs the installed preprocessor there too.
package/dist/babel.cjs CHANGED
@@ -1,4 +1,4 @@
1
- const require_unplugin = require("./unplugin-Cdo3QsZA.cjs");
1
+ const require_unplugin = require("./unplugin-C2D-Vdy1.cjs");
2
2
  //#region src/babel.ts
3
3
  function vizeBabelPlugin(_api, rawOptions = {}) {
4
4
  const options = require_unplugin.normalizeOptions(rawOptions);
package/dist/babel.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as createFilter, i as generateOutput, r as compileVueModule, t as normalizeOptions } from "./unplugin-C0_aL3Si.mjs";
1
+ import { a as createFilter, i as generateOutput, r as compileVueModule, t as normalizeOptions } from "./unplugin-BjxDYvYs.mjs";
2
2
  //#region src/babel.ts
3
3
  function vizeBabelPlugin(_api, rawOptions = {}) {
4
4
  const options = normalizeOptions(rawOptions);
package/dist/esbuild.cjs CHANGED
@@ -1,4 +1,4 @@
1
1
  //#region src/esbuild.ts
2
- var esbuild_default = require("./unplugin-Cdo3QsZA.cjs").vizeUnplugin.esbuild;
2
+ var esbuild_default = require("./unplugin-C2D-Vdy1.cjs").vizeUnplugin.esbuild;
3
3
  //#endregion
4
4
  module.exports = esbuild_default;
package/dist/esbuild.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { n as vizeUnplugin } from "./unplugin-C0_aL3Si.mjs";
1
+ import { n as vizeUnplugin } from "./unplugin-BjxDYvYs.mjs";
2
2
  //#region src/esbuild.ts
3
3
  var esbuild_default = vizeUnplugin.esbuild;
4
4
  //#endregion
package/dist/index.cjs CHANGED
@@ -2,6 +2,6 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
- const require_unplugin = require("./unplugin-Cdo3QsZA.cjs");
5
+ const require_unplugin = require("./unplugin-C2D-Vdy1.cjs");
6
6
  exports.default = require_unplugin.vizeUnplugin;
7
7
  exports.vizeUnplugin = require_unplugin.vizeUnplugin;
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { n as vizeUnplugin } from "./unplugin-C0_aL3Si.mjs";
1
+ import { n as vizeUnplugin } from "./unplugin-BjxDYvYs.mjs";
2
2
  export { vizeUnplugin as default, vizeUnplugin };
package/dist/rolldown.cjs CHANGED
@@ -1,4 +1,4 @@
1
1
  //#region src/rolldown.ts
2
- var rolldown_default = require("./unplugin-Cdo3QsZA.cjs").vizeUnplugin.rollup;
2
+ var rolldown_default = require("./unplugin-C2D-Vdy1.cjs").vizeUnplugin.rollup;
3
3
  //#endregion
4
4
  module.exports = rolldown_default;
package/dist/rolldown.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { n as vizeUnplugin } from "./unplugin-C0_aL3Si.mjs";
1
+ import { n as vizeUnplugin } from "./unplugin-BjxDYvYs.mjs";
2
2
  //#region src/rolldown.ts
3
3
  var rolldown_default = vizeUnplugin.rollup;
4
4
  //#endregion
package/dist/rollup.cjs CHANGED
@@ -1,4 +1,4 @@
1
1
  //#region src/rollup.ts
2
- var rollup_default = require("./unplugin-Cdo3QsZA.cjs").vizeUnplugin.rollup;
2
+ var rollup_default = require("./unplugin-C2D-Vdy1.cjs").vizeUnplugin.rollup;
3
3
  //#endregion
4
4
  module.exports = rollup_default;
package/dist/rollup.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { n as vizeUnplugin } from "./unplugin-C0_aL3Si.mjs";
1
+ import { n as vizeUnplugin } from "./unplugin-BjxDYvYs.mjs";
2
2
  //#region src/rollup.ts
3
3
  var rollup_default = vizeUnplugin.rollup;
4
4
  //#endregion
@@ -1,4 +1,4 @@
1
- import { c as scopeCss, i as webpackStyleRequest, l as transformStyleVars, n as registerWebpackStyleRule, o as isPreprocessorLang, r as webpackStylePath, s as preprocessStyle, t as findVirtualModules } from "./webpack-styles-qKeVgHc7.mjs";
1
+ import { c as scopeCss, i as webpackStyleRequest, l as transformStyleVars, n as registerWebpackStyleRule, o as isPreprocessorLang, r as webpackStylePath, s as preprocessStyle, t as findVirtualModules } from "./webpack-styles-CJFdgoZm.mjs";
2
2
  import { createRequire } from "node:module";
3
3
  import { createUnplugin } from "unplugin";
4
4
  import { createHash } from "node:crypto";
@@ -114,19 +114,31 @@ function isVueStyleRequest(id) {
114
114
  * the path stays the SFC and `<ext>` names what `load` returns. A preprocessor
115
115
  * block arrives compiled when it is scoped (scoping follows preprocessing) or
116
116
  * when the host compiles no preprocessor language.
117
+ *
118
+ * A `<style src>` block's module sits beside its src file, as
119
+ * `styles/a.css.__vize_style_0?vue&type=style&index=0&owner=<SFC>&lang.css`,
120
+ * so every host resolves the file's relative `@import`, `@use` and `url()`
121
+ * from its own directory. The path names no real file and no SFC; `owner`
122
+ * names the SFC that holds the block.
117
123
  */
118
124
  function styleRequestId(filePath, block, scoped, hostCss) {
119
125
  const lang = block.lang ?? "css";
120
126
  const delivered = (scoped !== null || hostCss !== "preprocessors") && isPreprocessorLang(lang) ? "css" : lang;
121
127
  let query = `vue&type=style&index=${block.index}`;
128
+ if (block.srcFile) query += `&owner=${encodeURIComponent(filePath)}`;
122
129
  if (scoped) query += `&scoped=${encodeURIComponent(scoped)}`;
123
130
  if (block.module !== false) query += typeof block.module === "string" ? `&module=${encodeURIComponent(block.module)}` : "&module";
124
131
  const ext = block.module === false ? delivered : `module.${delivered}`;
125
- return `${filePath}?${query}&lang.${ext}`;
132
+ return `${block.srcFile ? styleSrcModulePath(block.srcFile, block.index) : filePath}?${query}&lang.${ext}`;
133
+ }
134
+ /** Where a `<style src>` block's module sits: beside the src file, under no real name. */
135
+ function styleSrcModulePath(src, index) {
136
+ return `${src}.__vize_style_${index}`;
126
137
  }
127
138
  function parseVueRequest(id) {
128
- const [filename, rawQuery = ""] = id.split("?", 2);
139
+ const [path, rawQuery = ""] = id.split("?", 2);
129
140
  const params = new URLSearchParams(rawQuery);
141
+ const filename = params.get("owner") ?? path;
130
142
  const moduleValue = params.has("module") ? params.get("module") || true : false;
131
143
  const indexValue = params.get("index");
132
144
  const langKey = [...params.keys()].find((key) => key.startsWith("lang."));
@@ -148,16 +160,13 @@ function hasImportRule(ast) {
148
160
  if (typeof ast !== "object" || ast === null || !("rules" in ast)) return false;
149
161
  return Array.isArray(ast.rules) && ast.rules.some((rule) => typeof rule === "object" && rule !== null && "type" in rule && rule.type === "import");
150
162
  }
151
- /** `src` blocks are inlined before compilation; one left here was unreadable. */
152
- function assertInlinedStyleSrc(styles, filename) {
153
- for (const style of styles) if (style.src !== void 0) throw new Error(`[vize] ${filename}: <style src=${JSON.stringify(style.src)}> could not be inlined by @vizejs/unplugin. Write it as <style src="./file.css"> with a quoted relative path, or use @vizejs/vite-plugin.`);
154
- }
155
163
  /**
156
164
  * CSS injected at run time is a string in the page: nothing compiles a
157
165
  * preprocessor block or resolves an `@import` there.
158
166
  */
159
167
  function assertInjectableCss(styles, filename) {
160
168
  for (const style of styles) {
169
+ if (style.src) continue;
161
170
  if (isPreprocessorLang(style.lang)) throw new Error(`[vize] ${filename}: <style lang="${style.lang}"> needs a bundler CSS pipeline. @vizejs/unplugin injects CSS at run time under Babel and esbuild without \`bundle\`, where nothing compiles ${style.lang}. Bundle the build, write the block as CSS, or use @vizejs/vite-plugin.`);
162
171
  if (!style.content.includes("@")) continue;
163
172
  if (hasImportRule(parseCssAst(style.content, { filename }).ast)) throw new Error(`[vize] ${filename}: CSS @import in <style> needs a bundler CSS pipeline. @vizejs/unplugin injects CSS at run time under Babel and esbuild without \`bundle\`, where nothing resolves the import. Inline the imported CSS, bundle the build, or use @vizejs/vite-plugin.`);
@@ -209,6 +218,10 @@ const CSS_MODULE_LOCALS_HELPER = `const ${CSS_MODULE_LOCALS} = (ns) =>
209
218
  (ns.default && typeof ns.default === "object" && !Array.isArray(ns.default)
210
219
  ? ns.default
211
220
  : Object.fromEntries(Object.entries(ns).filter(([key]) => key !== "default")));`;
221
+ /** Only an external `<style src>` is left uninlined; it stays an import of that module. */
222
+ function externalStyleImport(src) {
223
+ return `import ${JSON.stringify(src)};`;
224
+ }
212
225
  function generateOutput(compiled, options) {
213
226
  const { isProduction, isDev, hostCss, filePath, styleRequest } = options;
214
227
  let output = compiled.code;
@@ -231,6 +244,10 @@ function generateOutput(compiled, options) {
231
244
  const styleImports = [];
232
245
  const cssModuleImports = [];
233
246
  for (const block of compiled.styles) {
247
+ if (block.src) {
248
+ styleImports.push(externalStyleImport(block.src));
249
+ continue;
250
+ }
234
251
  const scoped = block.scoped ? `data-v-${compiled.scopeId}` : null;
235
252
  const styleFile = styleRequest?.(block, scoped);
236
253
  const styleId = styleFile ?? styleRequestId(filePath, block, scoped, hostCss);
@@ -255,6 +272,8 @@ function generateOutput(compiled, options) {
255
272
  } else {
256
273
  assertInjectableCss(compiled.styles, filePath);
257
274
  if (compiled.css) output = prependInlineStyleInjection(output, compiled.css, compiled.scopeId);
275
+ const imports = compiled.styles.flatMap((block) => block.src ? [externalStyleImport(block.src)] : []);
276
+ if (imports.length > 0) output = `${imports.join("\n")}\n${output}`;
258
277
  }
259
278
  if (!isProduction && isDev && hasExportDefault && supportsTemplateOnlyHmr(output)) output += "";
260
279
  return output;
@@ -279,11 +298,11 @@ function toStyleBlockInfo(block) {
279
298
  function isRelativeSfcSrc(src) {
280
299
  return src.startsWith("./") || src.startsWith("../");
281
300
  }
282
- /** The file a block `src` names: next to the SFC, or where the bundler resolved it. */
283
- function sfcSrcFile(importer, tag, src, resolutions) {
284
- if (isRelativeSfcSrc(src)) return path.resolve(path.dirname(importer), src);
285
- const file = resolutions?.get(src);
286
- if (file !== void 0) return file;
301
+ /** Where a block `src` points: next to the SFC, or where the bundler resolved it. */
302
+ function sfcSrcTarget(importer, tag, src, resolutions) {
303
+ if (isRelativeSfcSrc(src)) return { file: path.resolve(path.dirname(importer), src) };
304
+ const resolution = resolutions?.get(src);
305
+ if (resolution !== void 0) return resolution;
287
306
  throw new Error(`[vize] <${tag} src="${src}"> not found: the bundler resolved no file for this module request from ${importer}`);
288
307
  }
289
308
  /** Resolve an SFC's `src` module requests with the bundler's own resolver. */
@@ -291,8 +310,14 @@ async function resolveSfcSrcRequests(importer, requests, resolve) {
291
310
  const resolutions = /* @__PURE__ */ new Map();
292
311
  for (const request of new Set(requests)) {
293
312
  if (isRelativeSfcSrc(request)) continue;
294
- const file = (await resolve(request, importer))?.replace(/[?#].*$/, "");
295
- if (file && path.isAbsolute(file)) resolutions.set(request, file);
313
+ const resolved = await resolve(request, importer);
314
+ if (!resolved) continue;
315
+ if (resolved.external) {
316
+ resolutions.set(request, { external: true });
317
+ continue;
318
+ }
319
+ const file = resolved.id.replace(/[?#].*$/, "");
320
+ if (path.isAbsolute(file)) resolutions.set(request, { file });
296
321
  }
297
322
  return resolutions;
298
323
  }
@@ -318,6 +343,14 @@ function splitSrcAttribute(tag, openTag) {
318
343
  openTag: `${head}${rest}>`
319
344
  };
320
345
  }
346
+ function needsContents(kind, block) {
347
+ const compiled = "is compiled into the component, so vize needs its contents";
348
+ if (kind === "template") return `the template ${compiled}`;
349
+ if (kind === "script setup") return `<script setup> ${compiled}`;
350
+ if (block.scoped) return "a scoped style needs its contents";
351
+ if (block.module) return "a CSS module needs its contents";
352
+ return null;
353
+ }
321
354
  /** The `src` blocks the native parser finds, so `src` text in scripts or comments is not one. */
322
355
  function collectSrcBlocks(parseSfc, filePath, bytes, source) {
323
356
  let parsed;
@@ -329,7 +362,7 @@ function collectSrcBlocks(parseSfc, filePath, bytes, source) {
329
362
  const blocks = [
330
363
  ["template", parsed.template],
331
364
  ["script", parsed.script],
332
- ["script", parsed.scriptSetup],
365
+ ["script setup", parsed.scriptSetup],
333
366
  ...parsed.styles.map((style, index) => [
334
367
  "style",
335
368
  style,
@@ -337,16 +370,19 @@ function collectSrcBlocks(parseSfc, filePath, bytes, source) {
337
370
  ])
338
371
  ];
339
372
  const found = [];
340
- for (const [tag, block, styleIndex] of blocks) {
373
+ for (const [kind, block, styleIndex] of blocks) {
341
374
  if (!block) continue;
375
+ const tag = kind === "script setup" ? "script" : kind;
342
376
  const { start, tagStart, tagEnd } = block.loc;
343
377
  const split = splitSrcAttribute(tag, bytes.subarray(tagStart, start).toString("utf8"));
344
378
  if (split) found.push({
379
+ kind,
345
380
  tag,
346
381
  ...split,
347
382
  tagStart,
348
383
  tagEnd,
349
- styleIndex
384
+ styleIndex,
385
+ needsContents: needsContents(kind, block)
350
386
  });
351
387
  }
352
388
  return found;
@@ -356,46 +392,66 @@ function listSfcSrcRequests(parseSfc, filePath, source) {
356
392
  if (!SRC_BLOCK_HINT.test(source)) return [];
357
393
  return collectSrcBlocks(parseSfc, filePath, Buffer.from(source), source).map((block) => block.src).filter((src) => !isRelativeSfcSrc(src));
358
394
  }
359
- function readSrcBlock(filePath, tag, src, resolutions) {
360
- const resolved = sfcSrcFile(filePath, tag, src, resolutions);
395
+ function readSrcFile(filePath, tag, src, file) {
361
396
  try {
362
- return {
363
- path: resolved,
364
- content: fs.readFileSync(resolved, "utf8")
365
- };
397
+ return fs.readFileSync(file, "utf8");
366
398
  } catch {
367
- throw new Error(`[vize] <${tag} src="${src}"> not found (resolved: ${resolved}) in ${filePath}`);
399
+ throw new Error(`[vize] <${tag} src="${src}"> not found (resolved: ${file}) in ${filePath}`);
400
+ }
401
+ }
402
+ /**
403
+ * The block for an external module, as `@vitejs/plugin-vue` keeps it: a style
404
+ * stays in place for the output to import (`null`), a script imports it.
405
+ */
406
+ function externalSrcBlock(filePath, block) {
407
+ if (block.needsContents) {
408
+ const tag = `${block.openTag.slice(0, -1)} src="${block.src}">`;
409
+ throw new Error(`[vize] ${tag} resolved to an external module; ${block.needsContents}. Let the bundler bundle "${block.src}" (in ${filePath})`);
368
410
  }
411
+ if (block.kind === "style") return null;
412
+ const request = JSON.stringify(block.src);
413
+ return `${block.openTag}\nimport __vize_src_main__ from ${request};\nexport * from ${request};\nexport default __vize_src_main__;\n<\/script>`;
369
414
  }
370
415
  /**
371
416
  * Inline `<template src>`, `<script src>` and `<style src>` files into the SFC
372
417
  * source. Blocks are located by the native parser. Module requests come from
373
- * the bundler's `resolutions` (see {@link sfcSrcFile}).
418
+ * the bundler's `resolutions`; an external one stays an import.
374
419
  */
375
420
  function inlineSfcSrcBlocks(parseSfc, filePath, source, resolutions) {
376
421
  const styleSrcs = /* @__PURE__ */ new Map();
377
422
  if (!SRC_BLOCK_HINT.test(source)) return {
378
423
  source,
379
424
  dependencies: [],
380
- styleSrcs
425
+ styleSrcs,
426
+ imports: []
381
427
  };
382
428
  const bytes = Buffer.from(source);
383
429
  const edits = [];
384
430
  const dependencies = [];
431
+ const imports = [];
385
432
  for (const block of collectSrcBlocks(parseSfc, filePath, bytes, source)) {
386
- const file = readSrcBlock(filePath, block.tag, block.src, resolutions);
387
- dependencies.push(file.path);
388
- if (block.styleIndex !== void 0) styleSrcs.set(block.styleIndex, file.path);
389
- edits.push({
433
+ const target = sfcSrcTarget(filePath, block.tag, block.src, resolutions);
434
+ let text;
435
+ if ("external" in target) {
436
+ text = externalSrcBlock(filePath, block);
437
+ if (text === null) imports.push(block.src);
438
+ } else {
439
+ const content = readSrcFile(filePath, block.tag, block.src, target.file);
440
+ dependencies.push(target.file);
441
+ if (block.styleIndex !== void 0) styleSrcs.set(block.styleIndex, target.file);
442
+ text = `${block.openTag}\n${content}\n</${block.tag}>`;
443
+ }
444
+ if (text !== null) edits.push({
390
445
  start: block.tagStart,
391
446
  end: block.tagEnd,
392
- text: `${block.openTag}\n${file.content}\n</${block.tag}>`
447
+ text
393
448
  });
394
449
  }
395
450
  if (edits.length === 0) return {
396
451
  source,
397
452
  dependencies,
398
- styleSrcs
453
+ styleSrcs,
454
+ imports
399
455
  };
400
456
  edits.sort((a, b) => a.start - b.start);
401
457
  const parts = [];
@@ -408,9 +464,20 @@ function inlineSfcSrcBlocks(parseSfc, filePath, source, resolutions) {
408
464
  return {
409
465
  source: Buffer.concat(parts).toString("utf8"),
410
466
  dependencies,
411
- styleSrcs
467
+ styleSrcs,
468
+ imports
412
469
  };
413
470
  }
471
+ /**
472
+ * A `<style src>` the compiler still sees was not inlined. Only an external one
473
+ * may stay, as an import; any other was written in a form the inliner cannot read.
474
+ */
475
+ function assertSfcStyleSrcImports(filePath, styles, imports = []) {
476
+ for (const style of styles) {
477
+ if (style.src == null || imports.includes(style.src)) continue;
478
+ 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.`);
479
+ }
480
+ }
414
481
  //#endregion
415
482
  //#region src/compiler.ts
416
483
  const { compileSfc, compileJsx } = native;
@@ -440,7 +507,7 @@ function buildSourceHash(source) {
440
507
  return createHash("sha256").update(source).digest("hex");
441
508
  }
442
509
  function compileVueModule(filePath, source, options, cache, srcResolutions) {
443
- const { source: inlined, dependencies } = inlineSfcSrcBlocks(native.parseSfc, filePath, source, srcResolutions);
510
+ const { source: inlined, dependencies, imports, styleSrcs } = inlineSfcSrcBlocks(native.parseSfc, filePath, source, srcResolutions);
444
511
  const sourceHash = buildSourceHash(inlined);
445
512
  const signature = buildSignature(options);
446
513
  const cached = cache.get(filePath);
@@ -472,7 +539,7 @@ function compileVueModule(filePath, source, options, cache, srcResolutions) {
472
539
  inlineTemplate: options.isProduction && !options.ssr && options.mode !== "function"
473
540
  });
474
541
  if (result.errors.length > 0) throw new Error(result.errors.join("\n"));
475
- assertInlinedStyleSrc(result.styles, filePath);
542
+ assertSfcStyleSrcImports(filePath, result.styles, imports);
476
543
  const compiled = {
477
544
  code: result.code,
478
545
  css: result.css,
@@ -482,7 +549,10 @@ function compileVueModule(filePath, source, options, cache, srcResolutions) {
482
549
  styleHash: result.styleHash,
483
550
  scriptHash: result.scriptHash,
484
551
  macroArtifacts: result.macroArtifacts ?? [],
485
- styles: result.styles.map(toStyleBlockInfo)
552
+ styles: result.styles.map((style) => ({
553
+ ...toStyleBlockInfo(style),
554
+ srcFile: styleSrcs.get(style.index) ?? null
555
+ }))
486
556
  };
487
557
  cache.set(filePath, {
488
558
  compiled,
@@ -548,15 +618,12 @@ function hostResolver(context) {
548
618
  const ctx = context;
549
619
  if (typeof ctx.resolve === "function") {
550
620
  const resolve = ctx.resolve;
551
- return async (request, importer) => {
552
- const result = await resolve.call(context, request, importer, { skipSelf: true });
553
- return result && !result.external ? result.id : null;
554
- };
621
+ return (request, importer) => resolve.call(context, request, importer, { skipSelf: true });
555
622
  }
556
623
  const native = ctx.getNativeBuildContext?.();
557
624
  if (native && "loaderContext" in native && native.loaderContext) {
558
625
  const resolve = native.loaderContext.getResolve();
559
- return (request, importer) => resolve(path.dirname(importer), request).catch(() => null);
626
+ return (request, importer) => resolve(path.dirname(importer), request).then((id) => ({ id }), () => null);
560
627
  }
561
628
  if (native && "build" in native) {
562
629
  const { build } = native;
@@ -566,7 +633,10 @@ function hostResolver(context) {
566
633
  resolveDir: path.dirname(importer),
567
634
  importer
568
635
  });
569
- return result.errors.length > 0 || result.external ? null : result.path;
636
+ return result.errors.length > 0 ? null : {
637
+ id: result.path,
638
+ external: result.external
639
+ };
570
640
  };
571
641
  }
572
642
  return null;
@@ -592,8 +662,9 @@ async function loadStyleBlock(context, id, options, cache, jsxStyles) {
592
662
  }
593
663
  const block = compiled?.styles[index];
594
664
  if (!compiled || !block) return "";
665
+ if (block.srcFile) context.addWatchFile?.(block.srcFile);
595
666
  const source = transformStyleVars(block.content, compiled.scopeId, options.isProduction ? request.filename : void 0);
596
- const css = block.lang && isPreprocessorLang(block.lang) && request.query.lang === "css" ? await preprocessStyle(source, block.lang, request.filename, options.root) : source;
667
+ const css = block.lang && isPreprocessorLang(block.lang) && request.query.lang === "css" ? await preprocessStyle(source, block.lang, block.srcFile ?? request.filename, options.root) : source;
597
668
  const scoped = request.query.scoped;
598
669
  return scoped ? scopeCss(css, scoped) : css;
599
670
  }
@@ -787,8 +858,8 @@ const vizeUnplugin = createUnplugin((rawOptions = {}, meta) => {
787
858
  }
788
859
  },
789
860
  esbuild: {
790
- onResolveFilter: /\.(?:vue|[jt]sx)(?:$|\?)/,
791
- onLoadFilter: /\.(?:vue|[jt]sx)(?:$|\?)/,
861
+ onResolveFilter: /\.(?:vue|[jt]sx)(?:$|\?)|\.__vize_style_\d+\?/,
862
+ onLoadFilter: /\.(?:vue|[jt]sx)(?:$|\?)|\.__vize_style_\d+\?/,
792
863
  loader(_code, id) {
793
864
  const request = parseVueRequest(id);
794
865
  if (request.query.type === "style") return request.query.module !== false ? "local-css" : "css";
@@ -1,4 +1,4 @@
1
- const require_webpack_styles = require("./webpack-styles-B4946o00.cjs");
1
+ const require_webpack_styles = require("./webpack-styles-CmdUBM2f.cjs");
2
2
  let node_module = require("node:module");
3
3
  let unplugin = require("unplugin");
4
4
  let node_crypto = require("node:crypto");
@@ -116,19 +116,31 @@ function isVueStyleRequest(id) {
116
116
  * the path stays the SFC and `<ext>` names what `load` returns. A preprocessor
117
117
  * block arrives compiled when it is scoped (scoping follows preprocessing) or
118
118
  * when the host compiles no preprocessor language.
119
+ *
120
+ * A `<style src>` block's module sits beside its src file, as
121
+ * `styles/a.css.__vize_style_0?vue&type=style&index=0&owner=<SFC>&lang.css`,
122
+ * so every host resolves the file's relative `@import`, `@use` and `url()`
123
+ * from its own directory. The path names no real file and no SFC; `owner`
124
+ * names the SFC that holds the block.
119
125
  */
120
126
  function styleRequestId(filePath, block, scoped, hostCss) {
121
127
  const lang = block.lang ?? "css";
122
128
  const delivered = (scoped !== null || hostCss !== "preprocessors") && require_webpack_styles.isPreprocessorLang(lang) ? "css" : lang;
123
129
  let query = `vue&type=style&index=${block.index}`;
130
+ if (block.srcFile) query += `&owner=${encodeURIComponent(filePath)}`;
124
131
  if (scoped) query += `&scoped=${encodeURIComponent(scoped)}`;
125
132
  if (block.module !== false) query += typeof block.module === "string" ? `&module=${encodeURIComponent(block.module)}` : "&module";
126
133
  const ext = block.module === false ? delivered : `module.${delivered}`;
127
- return `${filePath}?${query}&lang.${ext}`;
134
+ return `${block.srcFile ? styleSrcModulePath(block.srcFile, block.index) : filePath}?${query}&lang.${ext}`;
135
+ }
136
+ /** Where a `<style src>` block's module sits: beside the src file, under no real name. */
137
+ function styleSrcModulePath(src, index) {
138
+ return `${src}.__vize_style_${index}`;
128
139
  }
129
140
  function parseVueRequest(id) {
130
- const [filename, rawQuery = ""] = id.split("?", 2);
141
+ const [path, rawQuery = ""] = id.split("?", 2);
131
142
  const params = new URLSearchParams(rawQuery);
143
+ const filename = params.get("owner") ?? path;
132
144
  const moduleValue = params.has("module") ? params.get("module") || true : false;
133
145
  const indexValue = params.get("index");
134
146
  const langKey = [...params.keys()].find((key) => key.startsWith("lang."));
@@ -150,16 +162,13 @@ function hasImportRule(ast) {
150
162
  if (typeof ast !== "object" || ast === null || !("rules" in ast)) return false;
151
163
  return Array.isArray(ast.rules) && ast.rules.some((rule) => typeof rule === "object" && rule !== null && "type" in rule && rule.type === "import");
152
164
  }
153
- /** `src` blocks are inlined before compilation; one left here was unreadable. */
154
- function assertInlinedStyleSrc(styles, filename) {
155
- for (const style of styles) if (style.src !== void 0) throw new Error(`[vize] ${filename}: <style src=${JSON.stringify(style.src)}> could not be inlined by @vizejs/unplugin. Write it as <style src="./file.css"> with a quoted relative path, or use @vizejs/vite-plugin.`);
156
- }
157
165
  /**
158
166
  * CSS injected at run time is a string in the page: nothing compiles a
159
167
  * preprocessor block or resolves an `@import` there.
160
168
  */
161
169
  function assertInjectableCss(styles, filename) {
162
170
  for (const style of styles) {
171
+ if (style.src) continue;
163
172
  if (require_webpack_styles.isPreprocessorLang(style.lang)) throw new Error(`[vize] ${filename}: <style lang="${style.lang}"> needs a bundler CSS pipeline. @vizejs/unplugin injects CSS at run time under Babel and esbuild without \`bundle\`, where nothing compiles ${style.lang}. Bundle the build, write the block as CSS, or use @vizejs/vite-plugin.`);
164
173
  if (!style.content.includes("@")) continue;
165
174
  if (hasImportRule((0, _vizejs_native.parseCssAst)(style.content, { filename }).ast)) throw new Error(`[vize] ${filename}: CSS @import in <style> needs a bundler CSS pipeline. @vizejs/unplugin injects CSS at run time under Babel and esbuild without \`bundle\`, where nothing resolves the import. Inline the imported CSS, bundle the build, or use @vizejs/vite-plugin.`);
@@ -211,6 +220,10 @@ const CSS_MODULE_LOCALS_HELPER = `const ${CSS_MODULE_LOCALS} = (ns) =>
211
220
  (ns.default && typeof ns.default === "object" && !Array.isArray(ns.default)
212
221
  ? ns.default
213
222
  : Object.fromEntries(Object.entries(ns).filter(([key]) => key !== "default")));`;
223
+ /** Only an external `<style src>` is left uninlined; it stays an import of that module. */
224
+ function externalStyleImport(src) {
225
+ return `import ${JSON.stringify(src)};`;
226
+ }
214
227
  function generateOutput(compiled, options) {
215
228
  const { isProduction, isDev, hostCss, filePath, styleRequest } = options;
216
229
  let output = compiled.code;
@@ -233,6 +246,10 @@ function generateOutput(compiled, options) {
233
246
  const styleImports = [];
234
247
  const cssModuleImports = [];
235
248
  for (const block of compiled.styles) {
249
+ if (block.src) {
250
+ styleImports.push(externalStyleImport(block.src));
251
+ continue;
252
+ }
236
253
  const scoped = block.scoped ? `data-v-${compiled.scopeId}` : null;
237
254
  const styleFile = styleRequest?.(block, scoped);
238
255
  const styleId = styleFile ?? styleRequestId(filePath, block, scoped, hostCss);
@@ -257,6 +274,8 @@ function generateOutput(compiled, options) {
257
274
  } else {
258
275
  assertInjectableCss(compiled.styles, filePath);
259
276
  if (compiled.css) output = prependInlineStyleInjection(output, compiled.css, compiled.scopeId);
277
+ const imports = compiled.styles.flatMap((block) => block.src ? [externalStyleImport(block.src)] : []);
278
+ if (imports.length > 0) output = `${imports.join("\n")}\n${output}`;
260
279
  }
261
280
  if (!isProduction && isDev && hasExportDefault && supportsTemplateOnlyHmr(output)) output += "";
262
281
  return output;
@@ -281,11 +300,11 @@ function toStyleBlockInfo(block) {
281
300
  function isRelativeSfcSrc(src) {
282
301
  return src.startsWith("./") || src.startsWith("../");
283
302
  }
284
- /** The file a block `src` names: next to the SFC, or where the bundler resolved it. */
285
- function sfcSrcFile(importer, tag, src, resolutions) {
286
- if (isRelativeSfcSrc(src)) return node_path.default.resolve(node_path.default.dirname(importer), src);
287
- const file = resolutions?.get(src);
288
- if (file !== void 0) return file;
303
+ /** Where a block `src` points: next to the SFC, or where the bundler resolved it. */
304
+ function sfcSrcTarget(importer, tag, src, resolutions) {
305
+ if (isRelativeSfcSrc(src)) return { file: node_path.default.resolve(node_path.default.dirname(importer), src) };
306
+ const resolution = resolutions?.get(src);
307
+ if (resolution !== void 0) return resolution;
289
308
  throw new Error(`[vize] <${tag} src="${src}"> not found: the bundler resolved no file for this module request from ${importer}`);
290
309
  }
291
310
  /** Resolve an SFC's `src` module requests with the bundler's own resolver. */
@@ -293,8 +312,14 @@ async function resolveSfcSrcRequests(importer, requests, resolve) {
293
312
  const resolutions = /* @__PURE__ */ new Map();
294
313
  for (const request of new Set(requests)) {
295
314
  if (isRelativeSfcSrc(request)) continue;
296
- const file = (await resolve(request, importer))?.replace(/[?#].*$/, "");
297
- if (file && node_path.default.isAbsolute(file)) resolutions.set(request, file);
315
+ const resolved = await resolve(request, importer);
316
+ if (!resolved) continue;
317
+ if (resolved.external) {
318
+ resolutions.set(request, { external: true });
319
+ continue;
320
+ }
321
+ const file = resolved.id.replace(/[?#].*$/, "");
322
+ if (node_path.default.isAbsolute(file)) resolutions.set(request, { file });
298
323
  }
299
324
  return resolutions;
300
325
  }
@@ -320,6 +345,14 @@ function splitSrcAttribute(tag, openTag) {
320
345
  openTag: `${head}${rest}>`
321
346
  };
322
347
  }
348
+ function needsContents(kind, block) {
349
+ const compiled = "is compiled into the component, so vize needs its contents";
350
+ if (kind === "template") return `the template ${compiled}`;
351
+ if (kind === "script setup") return `<script setup> ${compiled}`;
352
+ if (block.scoped) return "a scoped style needs its contents";
353
+ if (block.module) return "a CSS module needs its contents";
354
+ return null;
355
+ }
323
356
  /** The `src` blocks the native parser finds, so `src` text in scripts or comments is not one. */
324
357
  function collectSrcBlocks(parseSfc, filePath, bytes, source) {
325
358
  let parsed;
@@ -331,7 +364,7 @@ function collectSrcBlocks(parseSfc, filePath, bytes, source) {
331
364
  const blocks = [
332
365
  ["template", parsed.template],
333
366
  ["script", parsed.script],
334
- ["script", parsed.scriptSetup],
367
+ ["script setup", parsed.scriptSetup],
335
368
  ...parsed.styles.map((style, index) => [
336
369
  "style",
337
370
  style,
@@ -339,16 +372,19 @@ function collectSrcBlocks(parseSfc, filePath, bytes, source) {
339
372
  ])
340
373
  ];
341
374
  const found = [];
342
- for (const [tag, block, styleIndex] of blocks) {
375
+ for (const [kind, block, styleIndex] of blocks) {
343
376
  if (!block) continue;
377
+ const tag = kind === "script setup" ? "script" : kind;
344
378
  const { start, tagStart, tagEnd } = block.loc;
345
379
  const split = splitSrcAttribute(tag, bytes.subarray(tagStart, start).toString("utf8"));
346
380
  if (split) found.push({
381
+ kind,
347
382
  tag,
348
383
  ...split,
349
384
  tagStart,
350
385
  tagEnd,
351
- styleIndex
386
+ styleIndex,
387
+ needsContents: needsContents(kind, block)
352
388
  });
353
389
  }
354
390
  return found;
@@ -358,46 +394,66 @@ function listSfcSrcRequests(parseSfc, filePath, source) {
358
394
  if (!SRC_BLOCK_HINT.test(source)) return [];
359
395
  return collectSrcBlocks(parseSfc, filePath, Buffer.from(source), source).map((block) => block.src).filter((src) => !isRelativeSfcSrc(src));
360
396
  }
361
- function readSrcBlock(filePath, tag, src, resolutions) {
362
- const resolved = sfcSrcFile(filePath, tag, src, resolutions);
397
+ function readSrcFile(filePath, tag, src, file) {
363
398
  try {
364
- return {
365
- path: resolved,
366
- content: node_fs.default.readFileSync(resolved, "utf8")
367
- };
399
+ return node_fs.default.readFileSync(file, "utf8");
368
400
  } catch {
369
- throw new Error(`[vize] <${tag} src="${src}"> not found (resolved: ${resolved}) in ${filePath}`);
401
+ throw new Error(`[vize] <${tag} src="${src}"> not found (resolved: ${file}) in ${filePath}`);
402
+ }
403
+ }
404
+ /**
405
+ * The block for an external module, as `@vitejs/plugin-vue` keeps it: a style
406
+ * stays in place for the output to import (`null`), a script imports it.
407
+ */
408
+ function externalSrcBlock(filePath, block) {
409
+ if (block.needsContents) {
410
+ const tag = `${block.openTag.slice(0, -1)} src="${block.src}">`;
411
+ throw new Error(`[vize] ${tag} resolved to an external module; ${block.needsContents}. Let the bundler bundle "${block.src}" (in ${filePath})`);
370
412
  }
413
+ if (block.kind === "style") return null;
414
+ const request = JSON.stringify(block.src);
415
+ return `${block.openTag}\nimport __vize_src_main__ from ${request};\nexport * from ${request};\nexport default __vize_src_main__;\n<\/script>`;
371
416
  }
372
417
  /**
373
418
  * Inline `<template src>`, `<script src>` and `<style src>` files into the SFC
374
419
  * source. Blocks are located by the native parser. Module requests come from
375
- * the bundler's `resolutions` (see {@link sfcSrcFile}).
420
+ * the bundler's `resolutions`; an external one stays an import.
376
421
  */
377
422
  function inlineSfcSrcBlocks(parseSfc, filePath, source, resolutions) {
378
423
  const styleSrcs = /* @__PURE__ */ new Map();
379
424
  if (!SRC_BLOCK_HINT.test(source)) return {
380
425
  source,
381
426
  dependencies: [],
382
- styleSrcs
427
+ styleSrcs,
428
+ imports: []
383
429
  };
384
430
  const bytes = Buffer.from(source);
385
431
  const edits = [];
386
432
  const dependencies = [];
433
+ const imports = [];
387
434
  for (const block of collectSrcBlocks(parseSfc, filePath, bytes, source)) {
388
- const file = readSrcBlock(filePath, block.tag, block.src, resolutions);
389
- dependencies.push(file.path);
390
- if (block.styleIndex !== void 0) styleSrcs.set(block.styleIndex, file.path);
391
- edits.push({
435
+ const target = sfcSrcTarget(filePath, block.tag, block.src, resolutions);
436
+ let text;
437
+ if ("external" in target) {
438
+ text = externalSrcBlock(filePath, block);
439
+ if (text === null) imports.push(block.src);
440
+ } else {
441
+ const content = readSrcFile(filePath, block.tag, block.src, target.file);
442
+ dependencies.push(target.file);
443
+ if (block.styleIndex !== void 0) styleSrcs.set(block.styleIndex, target.file);
444
+ text = `${block.openTag}\n${content}\n</${block.tag}>`;
445
+ }
446
+ if (text !== null) edits.push({
392
447
  start: block.tagStart,
393
448
  end: block.tagEnd,
394
- text: `${block.openTag}\n${file.content}\n</${block.tag}>`
449
+ text
395
450
  });
396
451
  }
397
452
  if (edits.length === 0) return {
398
453
  source,
399
454
  dependencies,
400
- styleSrcs
455
+ styleSrcs,
456
+ imports
401
457
  };
402
458
  edits.sort((a, b) => a.start - b.start);
403
459
  const parts = [];
@@ -410,9 +466,20 @@ function inlineSfcSrcBlocks(parseSfc, filePath, source, resolutions) {
410
466
  return {
411
467
  source: Buffer.concat(parts).toString("utf8"),
412
468
  dependencies,
413
- styleSrcs
469
+ styleSrcs,
470
+ imports
414
471
  };
415
472
  }
473
+ /**
474
+ * A `<style src>` the compiler still sees was not inlined. Only an external one
475
+ * may stay, as an import; any other was written in a form the inliner cannot read.
476
+ */
477
+ function assertSfcStyleSrcImports(filePath, styles, imports = []) {
478
+ for (const style of styles) {
479
+ if (style.src == null || imports.includes(style.src)) continue;
480
+ 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.`);
481
+ }
482
+ }
416
483
  //#endregion
417
484
  //#region src/compiler.ts
418
485
  const { compileSfc, compileJsx } = _vizejs_native;
@@ -442,7 +509,7 @@ function buildSourceHash(source) {
442
509
  return (0, node_crypto.createHash)("sha256").update(source).digest("hex");
443
510
  }
444
511
  function compileVueModule(filePath, source, options, cache, srcResolutions) {
445
- const { source: inlined, dependencies } = inlineSfcSrcBlocks(_vizejs_native.parseSfc, filePath, source, srcResolutions);
512
+ const { source: inlined, dependencies, imports, styleSrcs } = inlineSfcSrcBlocks(_vizejs_native.parseSfc, filePath, source, srcResolutions);
446
513
  const sourceHash = buildSourceHash(inlined);
447
514
  const signature = buildSignature(options);
448
515
  const cached = cache.get(filePath);
@@ -474,7 +541,7 @@ function compileVueModule(filePath, source, options, cache, srcResolutions) {
474
541
  inlineTemplate: options.isProduction && !options.ssr && options.mode !== "function"
475
542
  });
476
543
  if (result.errors.length > 0) throw new Error(result.errors.join("\n"));
477
- assertInlinedStyleSrc(result.styles, filePath);
544
+ assertSfcStyleSrcImports(filePath, result.styles, imports);
478
545
  const compiled = {
479
546
  code: result.code,
480
547
  css: result.css,
@@ -484,7 +551,10 @@ function compileVueModule(filePath, source, options, cache, srcResolutions) {
484
551
  styleHash: result.styleHash,
485
552
  scriptHash: result.scriptHash,
486
553
  macroArtifacts: result.macroArtifacts ?? [],
487
- styles: result.styles.map(toStyleBlockInfo)
554
+ styles: result.styles.map((style) => ({
555
+ ...toStyleBlockInfo(style),
556
+ srcFile: styleSrcs.get(style.index) ?? null
557
+ }))
488
558
  };
489
559
  cache.set(filePath, {
490
560
  compiled,
@@ -550,15 +620,12 @@ function hostResolver(context) {
550
620
  const ctx = context;
551
621
  if (typeof ctx.resolve === "function") {
552
622
  const resolve = ctx.resolve;
553
- return async (request, importer) => {
554
- const result = await resolve.call(context, request, importer, { skipSelf: true });
555
- return result && !result.external ? result.id : null;
556
- };
623
+ return (request, importer) => resolve.call(context, request, importer, { skipSelf: true });
557
624
  }
558
625
  const native = ctx.getNativeBuildContext?.();
559
626
  if (native && "loaderContext" in native && native.loaderContext) {
560
627
  const resolve = native.loaderContext.getResolve();
561
- return (request, importer) => resolve(node_path.default.dirname(importer), request).catch(() => null);
628
+ return (request, importer) => resolve(node_path.default.dirname(importer), request).then((id) => ({ id }), () => null);
562
629
  }
563
630
  if (native && "build" in native) {
564
631
  const { build } = native;
@@ -568,7 +635,10 @@ function hostResolver(context) {
568
635
  resolveDir: node_path.default.dirname(importer),
569
636
  importer
570
637
  });
571
- return result.errors.length > 0 || result.external ? null : result.path;
638
+ return result.errors.length > 0 ? null : {
639
+ id: result.path,
640
+ external: result.external
641
+ };
572
642
  };
573
643
  }
574
644
  return null;
@@ -594,8 +664,9 @@ async function loadStyleBlock(context, id, options, cache, jsxStyles) {
594
664
  }
595
665
  const block = compiled?.styles[index];
596
666
  if (!compiled || !block) return "";
667
+ if (block.srcFile) context.addWatchFile?.(block.srcFile);
597
668
  const source = require_webpack_styles.transformStyleVars(block.content, compiled.scopeId, options.isProduction ? request.filename : void 0);
598
- const css = block.lang && require_webpack_styles.isPreprocessorLang(block.lang) && request.query.lang === "css" ? await require_webpack_styles.preprocessStyle(source, block.lang, request.filename, options.root) : source;
669
+ const css = block.lang && require_webpack_styles.isPreprocessorLang(block.lang) && request.query.lang === "css" ? await require_webpack_styles.preprocessStyle(source, block.lang, block.srcFile ?? request.filename, options.root) : source;
599
670
  const scoped = request.query.scoped;
600
671
  return scoped ? require_webpack_styles.scopeCss(css, scoped) : css;
601
672
  }
@@ -789,8 +860,8 @@ const vizeUnplugin = (0, unplugin.createUnplugin)((rawOptions = {}, meta) => {
789
860
  }
790
861
  },
791
862
  esbuild: {
792
- onResolveFilter: /\.(?:vue|[jt]sx)(?:$|\?)/,
793
- onLoadFilter: /\.(?:vue|[jt]sx)(?:$|\?)/,
863
+ onResolveFilter: /\.(?:vue|[jt]sx)(?:$|\?)|\.__vize_style_\d+\?/,
864
+ onLoadFilter: /\.(?:vue|[jt]sx)(?:$|\?)|\.__vize_style_\d+\?/,
794
865
  loader(_code, id) {
795
866
  const request = parseVueRequest(id);
796
867
  if (request.query.type === "style") return request.query.module !== false ? "local-css" : "css";
@@ -2,7 +2,7 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
- const require_webpack_styles = require("./webpack-styles-B4946o00.cjs");
5
+ const require_webpack_styles = require("./webpack-styles-CmdUBM2f.cjs");
6
6
  //#region src/webpack-style-loader.ts
7
7
  const SCOPE_QUERY = "?scope";
8
8
  const CSS_LOADER = /(?:^|[/\\])css-loader(?:[/\\]|$)/;
@@ -1,4 +1,4 @@
1
- import { a as webpackStyleScope, c as scopeCss } from "./webpack-styles-qKeVgHc7.mjs";
1
+ import { a as webpackStyleScope, c as scopeCss } from "./webpack-styles-CJFdgoZm.mjs";
2
2
  //#region src/webpack-style-loader.ts
3
3
  const SCOPE_QUERY = "?scope";
4
4
  const CSS_LOADER = /(?:^|[/\\])css-loader(?:[/\\]|$)/;
@@ -53,7 +53,7 @@ const SCOPED_STYLE_FILE = /\.__vize_style_\d+\.(data-v-[0-9a-f]+)(?:\.module)?\.
53
53
  function webpackStylePath(filePath, block, scoped) {
54
54
  const scope = scoped ? `.${scoped}` : "";
55
55
  const module = block.module === false ? "" : ".module";
56
- return `${filePath}.__vize_style_${block.index}${scope}${module}.${block.lang ?? "css"}`;
56
+ return `${block.srcFile ?? filePath}.__vize_style_${block.index}${scope}${module}.${block.lang ?? "css"}`;
57
57
  }
58
58
  function webpackStyleRequest(stylePath, block) {
59
59
  if (block.module === false) return stylePath;
@@ -76,7 +76,7 @@ const SCOPED_STYLE_FILE = /\.__vize_style_\d+\.(data-v-[0-9a-f]+)(?:\.module)?\.
76
76
  function webpackStylePath(filePath, block, scoped) {
77
77
  const scope = scoped ? `.${scoped}` : "";
78
78
  const module = block.module === false ? "" : ".module";
79
- return `${filePath}.__vize_style_${block.index}${scope}${module}.${block.lang ?? "css"}`;
79
+ return `${block.srcFile ?? filePath}.__vize_style_${block.index}${scope}${module}.${block.lang ?? "css"}`;
80
80
  }
81
81
  function webpackStyleRequest(stylePath, block) {
82
82
  if (block.module === false) return stylePath;
package/dist/webpack.cjs CHANGED
@@ -1,4 +1,4 @@
1
1
  //#region src/webpack.ts
2
- var webpack_default = require("./unplugin-Cdo3QsZA.cjs").vizeUnplugin.webpack;
2
+ var webpack_default = require("./unplugin-C2D-Vdy1.cjs").vizeUnplugin.webpack;
3
3
  //#endregion
4
4
  module.exports = webpack_default;
package/dist/webpack.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { n as vizeUnplugin } from "./unplugin-C0_aL3Si.mjs";
1
+ import { n as vizeUnplugin } from "./unplugin-BjxDYvYs.mjs";
2
2
  //#region src/webpack.ts
3
3
  var webpack_default = vizeUnplugin.webpack;
4
4
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vizejs/unplugin",
3
- "version": "0.669.0",
3
+ "version": "0.671.0",
4
4
  "description": "Experimental Vue SFC integrations for Rollup, Rolldown, Webpack, esbuild, and Babel powered by Vize",
5
5
  "keywords": [
6
6
  "babel",
@@ -68,7 +68,7 @@
68
68
  "access": "public"
69
69
  },
70
70
  "dependencies": {
71
- "@vizejs/native": "0.669.0",
71
+ "@vizejs/native": "0.671.0",
72
72
  "oxc-transform": "0.144.0",
73
73
  "unplugin": "3.3.0"
74
74
  },