@vizejs/vite-plugin 0.428.1 → 0.429.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.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as rewriteStaticAssetUrls, t as vize } from "./plugin-
|
|
1
|
+
import { n as rewriteStaticAssetUrls, t as vize } from "./plugin-46Af12dC.mjs";
|
|
2
2
|
import { a as vizeConfigStore, i as resolveConfigExport, n as defineConfig, r as loadConfig, t as VIZE_CONFIG_FILE_ENV } from "./config-PP6EAmWc.mjs";
|
|
3
3
|
//#region src/index.ts
|
|
4
4
|
const __internal = { rewriteStaticAssetUrls };
|
|
@@ -232,7 +232,7 @@ function insertBeforeSfcMainDefaultExport(code, insertion, options = {}) {
|
|
|
232
232
|
return `${code.slice(0, exportStart)}${insertion}\n${code.slice(exportStart)}`;
|
|
233
233
|
}
|
|
234
234
|
//#endregion
|
|
235
|
-
//#region
|
|
235
|
+
//#region ../shared/source-map.ts
|
|
236
236
|
function isSourceMapV3(value) {
|
|
237
237
|
if (value === null || typeof value !== "object") return false;
|
|
238
238
|
const map = value;
|
|
@@ -279,6 +279,59 @@ function shiftMappedLines(map, atLine, count) {
|
|
|
279
279
|
mappings: shifted.join(";")
|
|
280
280
|
};
|
|
281
281
|
}
|
|
282
|
+
/** Prefix a native JSX module with unmapped generated whole lines.
|
|
283
|
+
* The actual style injection supplies the prefix; authored UTF-16 columns are
|
|
284
|
+
* unchanged because the module resumes at column zero on a new generated line.
|
|
285
|
+
*/
|
|
286
|
+
function prependMappedJsxCode(code, mapJson, prefix) {
|
|
287
|
+
const output = prefix + code;
|
|
288
|
+
if (!prefix) return {
|
|
289
|
+
code: output,
|
|
290
|
+
map: mapJson ?? null
|
|
291
|
+
};
|
|
292
|
+
const map = parseSourceMap(mapJson);
|
|
293
|
+
if (!map || !prefix.endsWith("\n")) return {
|
|
294
|
+
code: output,
|
|
295
|
+
map: null
|
|
296
|
+
};
|
|
297
|
+
return {
|
|
298
|
+
code: output,
|
|
299
|
+
map: JSON.stringify(shiftMappedLines(map, 0, countNewlines(prefix)))
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
//#endregion
|
|
303
|
+
//#region src/utils/source-map.ts
|
|
304
|
+
/**
|
|
305
|
+
* Keeping the compiler's Source Map v3 document valid through the edits
|
|
306
|
+
* `generateOutput` makes to the emitted module (#3399).
|
|
307
|
+
*
|
|
308
|
+
* The native compiler returns a map for the module it emitted. `generateOutput`
|
|
309
|
+
* then rewrites that module: it prepends a `<style>` injection, splices style
|
|
310
|
+
* imports in after the last static import, inserts CSS-module wiring before the
|
|
311
|
+
* default export, rewrites `export default` to `const _sfc_main =`, and appends
|
|
312
|
+
* `__scopeId`/HMR code. All of those are whole-line insertions or same-line
|
|
313
|
+
* substitutions, which is exactly the class of edit a v3 `mappings` string can
|
|
314
|
+
* absorb without being decoded:
|
|
315
|
+
*
|
|
316
|
+
* - Lines are separated by `;` and each line's segments by `,`.
|
|
317
|
+
* - A segment's generated column is relative to the previous segment **on the
|
|
318
|
+
* same line** and resets at every line, so an inserted line never disturbs the
|
|
319
|
+
* columns after it.
|
|
320
|
+
* - The source index/line/column fields are relative to the previous *segment*,
|
|
321
|
+
* not the previous line, so inserting empty lines between segments leaves
|
|
322
|
+
* every delta untouched.
|
|
323
|
+
*
|
|
324
|
+
* Shifting generated lines is therefore literally inserting `;` characters, with
|
|
325
|
+
* no VLQ decoding and no chance of a rounding error.
|
|
326
|
+
*
|
|
327
|
+
* Rather than have every call site declare where its edit landed — which would
|
|
328
|
+
* silently rot the first time an edit moves — {@link MappedModule.edit} derives
|
|
329
|
+
* it from the two strings: the common prefix and suffix bound the changed span
|
|
330
|
+
* exactly, and the change in newline count inside that span is the line shift.
|
|
331
|
+
* A same-line substitution comes out as a zero shift (columns within a line are
|
|
332
|
+
* not tracked; a frame still resolves to the right authored line), and an edit
|
|
333
|
+
* that *removes* lines drops the map rather than emit one that is wrong.
|
|
334
|
+
*/
|
|
282
335
|
/**
|
|
283
336
|
* A module's code and the map that describes it, edited together.
|
|
284
337
|
*
|
|
@@ -315,6 +368,31 @@ var MappedModule = class {
|
|
|
315
368
|
}
|
|
316
369
|
};
|
|
317
370
|
//#endregion
|
|
371
|
+
//#region src/plugin/style-request.ts
|
|
372
|
+
const STYLE_MARKER = ".__vize_style_";
|
|
373
|
+
/** Keep the CSS extension in the path, outside Vue/Nuxt's query metadata. */
|
|
374
|
+
function createStyleVirtualId(id) {
|
|
375
|
+
const start = id.indexOf("?");
|
|
376
|
+
const filename = id.slice(0, start);
|
|
377
|
+
const params = new URLSearchParams(id.slice(start + 1));
|
|
378
|
+
if (params.has("vize-file") && filename.includes(STYLE_MARKER)) return id;
|
|
379
|
+
const index = params.get("index") ?? "0";
|
|
380
|
+
const lang = params.get("lang") || "css";
|
|
381
|
+
const suffix = params.has("module") ? `.module.${lang}` : `.${lang}`;
|
|
382
|
+
const source = params.has("vize-file") ? "" : `&${new URLSearchParams({ "vize-file": filename }).toString()}`;
|
|
383
|
+
return `${filename}${STYLE_MARKER}${index}${suffix}?${id.slice(start + 1)}${source}`;
|
|
384
|
+
}
|
|
385
|
+
/** Recover the authored SFC before native classification and cache lookup. */
|
|
386
|
+
function normalizeStyleVirtualId(id) {
|
|
387
|
+
const withoutPrefix = id.startsWith("\0") ? id.slice(1) : id;
|
|
388
|
+
if (!withoutPrefix.includes("?vue")) return id;
|
|
389
|
+
const start = withoutPrefix.indexOf("?");
|
|
390
|
+
const query = withoutPrefix.slice(start + 1);
|
|
391
|
+
const source = new URLSearchParams(query).get("vize-file");
|
|
392
|
+
if (source && withoutPrefix.slice(0, start).includes(STYLE_MARKER)) return `${source}?${query}`;
|
|
393
|
+
return withoutPrefix.replace(/\.module\.\w+$/, "").replace(/\.\w+$/, "");
|
|
394
|
+
}
|
|
395
|
+
//#endregion
|
|
318
396
|
//#region src/utils/css.ts
|
|
319
397
|
function scopeCssForPipeline(css, scopeId) {
|
|
320
398
|
return scopeViteCssForPipeline(css, scopeId);
|
|
@@ -450,12 +528,8 @@ function isCssModule(block) {
|
|
|
450
528
|
function needsCssPipeline(block) {
|
|
451
529
|
return block.content.includes("@apply");
|
|
452
530
|
}
|
|
453
|
-
function
|
|
454
|
-
|
|
455
|
-
return block.module !== false ? `.module.${lang}` : `.${lang}`;
|
|
456
|
-
}
|
|
457
|
-
function createStyleImportUrl(filePath, params, block) {
|
|
458
|
-
return `${filePath}?${params.toString()}${styleVirtualSuffix(block)}`;
|
|
531
|
+
function createStyleImportUrl(filePath, params) {
|
|
532
|
+
return createStyleVirtualId(`${filePath}?${params.toString()}`);
|
|
459
533
|
}
|
|
460
534
|
/**
|
|
461
535
|
* Check if any style blocks in the compiled module require delegation to
|
|
@@ -586,16 +660,16 @@ function generateOutputWithMap(compiled, options) {
|
|
|
586
660
|
if (isCssModule(block)) throw new Error("<style module> is not supported in custom element mode");
|
|
587
661
|
params.set("inline", "");
|
|
588
662
|
const bindingName = `_style_${block.index}`;
|
|
589
|
-
const importUrl = createStyleImportUrl(filePath, params
|
|
663
|
+
const importUrl = createStyleImportUrl(filePath, params);
|
|
590
664
|
styleImports.push(`import ${bindingName} from ${JSON.stringify(importUrl)};`);
|
|
591
665
|
customElementStyleBindings.push(bindingName);
|
|
592
666
|
} else if (isCssModule(block)) {
|
|
593
667
|
const bindingName = typeof block.module === "string" ? block.module : "$style";
|
|
594
668
|
params.set("module", typeof block.module === "string" ? block.module : "");
|
|
595
|
-
const importUrl = createStyleImportUrl(filePath, params
|
|
669
|
+
const importUrl = createStyleImportUrl(filePath, params);
|
|
596
670
|
cssModuleImports.push(`import ${bindingName} from ${JSON.stringify(importUrl)};`);
|
|
597
671
|
} else {
|
|
598
|
-
const importUrl = createStyleImportUrl(filePath, params
|
|
672
|
+
const importUrl = createStyleImportUrl(filePath, params);
|
|
599
673
|
styleImports.push(`import ${JSON.stringify(importUrl)};`);
|
|
600
674
|
}
|
|
601
675
|
}
|
|
@@ -1156,8 +1230,7 @@ function compileJsxModule(filePath, source, options = {}) {
|
|
|
1156
1230
|
let map = result.map ?? null;
|
|
1157
1231
|
if (css && !options.ssr) {
|
|
1158
1232
|
const styleKey = result.scopedStyles[0].scopeId.replace(/^data-v-/, "");
|
|
1159
|
-
code =
|
|
1160
|
-
map = null;
|
|
1233
|
+
({code, map} = prependMappedJsxCode(code, map, prependInlineStyleInjection("", css, styleKey)));
|
|
1161
1234
|
}
|
|
1162
1235
|
return {
|
|
1163
1236
|
code,
|
|
@@ -2426,7 +2499,7 @@ async function resolveIdHook(ctx, state, id, importer, options) {
|
|
|
2426
2499
|
state.logger.log(`resolveId: skipping vitepress-plugin-llms style import ${id}`);
|
|
2427
2500
|
return null;
|
|
2428
2501
|
}
|
|
2429
|
-
return
|
|
2502
|
+
return createStyleVirtualId(request.normalizedFsId ?? id);
|
|
2430
2503
|
}
|
|
2431
2504
|
if (isBuild && request.normalizedFsId) return request.normalizedFsId;
|
|
2432
2505
|
const isMacroImporter = importerRequest?.isMacroVirtualId ?? false;
|
|
@@ -2850,13 +2923,6 @@ async function transformVizeVirtualModule(state, code, realPath, ssr, forceTypeS
|
|
|
2850
2923
|
}
|
|
2851
2924
|
}
|
|
2852
2925
|
//#endregion
|
|
2853
|
-
//#region src/plugin/load-style.ts
|
|
2854
|
-
function normalizeStyleVirtualId(id) {
|
|
2855
|
-
const withoutPrefix = id.startsWith("\0") ? id.slice(1) : id;
|
|
2856
|
-
if (!withoutPrefix.includes("?vue")) return id;
|
|
2857
|
-
return withoutPrefix.replace(/\.module\.\w+$/, "").replace(/\.\w+$/, "");
|
|
2858
|
-
}
|
|
2859
|
-
//#endregion
|
|
2860
2926
|
//#region src/plugin/load.ts
|
|
2861
2927
|
const SERVER_PLACEHOLDER_CODE = `import { createElementBlock, defineComponent } from "vue";
|
|
2862
2928
|
export default defineComponent({
|
|
@@ -3103,7 +3169,11 @@ function getVueModuleFileCandidates(vueFile) {
|
|
|
3103
3169
|
return unique([...candidates, ...viteFsCandidates]);
|
|
3104
3170
|
}
|
|
3105
3171
|
function getStyleModuleFileCandidates(styleId) {
|
|
3106
|
-
return unique([
|
|
3172
|
+
return unique([
|
|
3173
|
+
styleId,
|
|
3174
|
+
`${styleId}.css`,
|
|
3175
|
+
createStyleVirtualId(styleId)
|
|
3176
|
+
]);
|
|
3107
3177
|
}
|
|
3108
3178
|
async function collectModulesByFile(server, fileIds) {
|
|
3109
3179
|
const modules = /* @__PURE__ */ new Set();
|
|
@@ -3370,11 +3440,6 @@ function createVueCompatPlugin(state, options) {
|
|
|
3370
3440
|
}
|
|
3371
3441
|
};
|
|
3372
3442
|
}
|
|
3373
|
-
function normalizeVirtualStyleId(id) {
|
|
3374
|
-
const withoutPrefix = id.startsWith("\0") ? id.slice(1) : id;
|
|
3375
|
-
if (!withoutPrefix.includes("?vue")) return id;
|
|
3376
|
-
return withoutPrefix.replace(/\.module\.\w+$/, "").replace(/\.\w+$/, "");
|
|
3377
|
-
}
|
|
3378
3443
|
/**
|
|
3379
3444
|
* String pre-gate for {@link transformScopedPreprocessorCss} (#3427).
|
|
3380
3445
|
*
|
|
@@ -3383,15 +3448,15 @@ function normalizeVirtualStyleId(id) {
|
|
|
3383
3448
|
* not a style query. The native `isVueStyleQuery` is
|
|
3384
3449
|
* `query.contains("vue&type=style") || query.contains("vue=&type=style")`, both
|
|
3385
3450
|
* of which contain `type=style`; the query is a substring of the id, and
|
|
3386
|
-
* `normalizeVirtualStyleId`
|
|
3387
|
-
*
|
|
3451
|
+
* `normalizeVirtualStyleId` preserves the query, so a normalized style id
|
|
3452
|
+
* implies `type=style` in the raw id.
|
|
3388
3453
|
*/
|
|
3389
3454
|
function mayBeVueStyleQuery(id) {
|
|
3390
3455
|
return id.includes("type=style");
|
|
3391
3456
|
}
|
|
3392
3457
|
function transformScopedPreprocessorCss(code, id) {
|
|
3393
3458
|
if (!mayBeVueStyleQuery(id)) return null;
|
|
3394
|
-
const request = classifyVitePluginRequest(
|
|
3459
|
+
const request = classifyVitePluginRequest(normalizeStyleVirtualId(id));
|
|
3395
3460
|
if (!request.isVueStyleQuery || !request.styleScoped || !request.styleLang || request.styleLang === "css") return null;
|
|
3396
3461
|
return scopeCssForPipeline(code, request.styleScoped);
|
|
3397
3462
|
}
|
package/dist/vite-plus.mjs
CHANGED
|
@@ -321,7 +321,7 @@ function defineConfig(config = {}, integration = {}) {
|
|
|
321
321
|
const { options } = metadata;
|
|
322
322
|
const plugins = compiler === false ? [...vp.plugins ?? []] : await withoutVueCompiler(vp.plugins ?? []);
|
|
323
323
|
if (compiler !== false) {
|
|
324
|
-
const { vize } = await import("./plugin-
|
|
324
|
+
const { vize } = await import("./plugin-M-BPcy7h.mjs");
|
|
325
325
|
plugins.unshift(vize({
|
|
326
326
|
...compiler,
|
|
327
327
|
configMode: false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vizejs/vite-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.429.0",
|
|
4
4
|
"description": "High-performance native Vite plugin for Vue SFC compilation powered by Vize",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compiler",
|
|
@@ -51,12 +51,12 @@
|
|
|
51
51
|
"access": "public"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@vizejs/native": "0.
|
|
55
|
-
"@vizejs/unplugin": "0.
|
|
54
|
+
"@vizejs/native": "0.429.0",
|
|
55
|
+
"@vizejs/unplugin": "0.429.0",
|
|
56
56
|
"jsonc-parser": "^3.3.1",
|
|
57
57
|
"oxc-parser": "0.144.0",
|
|
58
58
|
"tinyglobby": "0.2.17",
|
|
59
|
-
"vize": "0.
|
|
59
|
+
"vize": "0.429.0"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@types/node": "25.9.2",
|
package/dist/plugin-BZN9h1bb.mjs
DELETED