@vizejs/vite-plugin 0.347.7 → 0.351.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
|
|
1
|
+
import { a as VizeInspectorLintPlanProvider, c as VizeCompatibilityOptions, d as LoadConfigOptions, f as ResolvedVizeConfig, i as VizeVueFeatures, l as VizeVueVersion, m as VizeConfig, n as CompiledModule, o as VizeInspectorLintPlanRequest, p as UserConfigExport, r as MacroArtifact, s as VizeInspectorOptions, t as VizeOptions, u as ConfigEnv } from "./types-0tlI4YFk.mjs";
|
|
2
2
|
import { Plugin } from "vite";
|
|
3
3
|
|
|
4
4
|
//#region src/virtual.d.ts
|
package/dist/index.mjs
CHANGED
|
@@ -448,6 +448,13 @@ function isCssModule(block) {
|
|
|
448
448
|
function needsCssPipeline(block) {
|
|
449
449
|
return block.content.includes("@apply");
|
|
450
450
|
}
|
|
451
|
+
function styleVirtualSuffix(block) {
|
|
452
|
+
const lang = block.lang ?? "css";
|
|
453
|
+
return block.module !== false ? `.module.${lang}` : `.${lang}`;
|
|
454
|
+
}
|
|
455
|
+
function createStyleImportUrl(filePath, params, block) {
|
|
456
|
+
return `${filePath}?${params.toString()}${styleVirtualSuffix(block)}`;
|
|
457
|
+
}
|
|
451
458
|
/**
|
|
452
459
|
* Check if any style blocks in the compiled module require delegation to
|
|
453
460
|
* Vite's CSS pipeline (preprocessor, CSS Modules, or PostCSS transforms).
|
|
@@ -505,7 +512,7 @@ function generateScopeId(filename) {
|
|
|
505
512
|
* emitted as imports and `compiled.css` is not used.
|
|
506
513
|
*/
|
|
507
514
|
function usesStyleImports(compiled, options) {
|
|
508
|
-
return !!options.filePath && !!compiled.styles?.length && (hasDelegatedStyles(compiled) || !options.ssr && options.isProduction && !!options.extractCss);
|
|
515
|
+
return !!options.filePath && !!compiled.styles?.length && (options.customElement || hasDelegatedStyles(compiled) || !options.ssr && options.isProduction && !!options.extractCss);
|
|
509
516
|
}
|
|
510
517
|
/**
|
|
511
518
|
* Whether `generateOutput` will embed `compiled.css` in the module.
|
|
@@ -524,7 +531,7 @@ function usesStyleImports(compiled, options) {
|
|
|
524
531
|
* 300-file bench corpus).
|
|
525
532
|
*/
|
|
526
533
|
function embedsInlineCss(compiled, options) {
|
|
527
|
-
return !usesStyleImports(compiled, options) && !options.ssr && !!compiled.css && !(options.isProduction && !!options.extractCss);
|
|
534
|
+
return !usesStyleImports(compiled, options) && !options.customElement && !options.ssr && !!compiled.css && !(options.isProduction && !!options.extractCss);
|
|
528
535
|
}
|
|
529
536
|
function generateOutput(compiled, options) {
|
|
530
537
|
return generateOutputWithMap(compiled, options).code;
|
|
@@ -538,7 +545,7 @@ function generateOutput(compiled, options) {
|
|
|
538
545
|
* `null` when the compiler produced none.
|
|
539
546
|
*/
|
|
540
547
|
function generateOutputWithMap(compiled, options) {
|
|
541
|
-
const { isProduction, isDev, ssr, hmrUpdateType, extractCss, filePath } = options;
|
|
548
|
+
const { customElement, isProduction, isDev, ssr, hmrUpdateType, extractCss, filePath } = options;
|
|
542
549
|
const emitted = new MappedModule(compiled.code, parseSourceMap(compiled.map));
|
|
543
550
|
const moduleInfo = compiled.moduleShape ?? analyzeModuleOutput(emitted.code);
|
|
544
551
|
const hasExportDefault = moduleInfo.hasDefaultExport;
|
|
@@ -565,6 +572,7 @@ function generateOutputWithMap(compiled, options) {
|
|
|
565
572
|
if (usesStyleImports(compiled, options)) {
|
|
566
573
|
const styleImports = [];
|
|
567
574
|
const cssModuleImports = [];
|
|
575
|
+
const customElementStyleBindings = [];
|
|
568
576
|
for (const block of compiled.styles) {
|
|
569
577
|
const lang = block.lang ?? "css";
|
|
570
578
|
const params = new URLSearchParams();
|
|
@@ -573,19 +581,27 @@ function generateOutputWithMap(compiled, options) {
|
|
|
573
581
|
params.set("index", String(block.index));
|
|
574
582
|
if (block.scoped) params.set("scoped", `data-v-${compiled.scopeId}`);
|
|
575
583
|
params.set("lang", lang);
|
|
576
|
-
if (
|
|
584
|
+
if (customElement) {
|
|
585
|
+
if (isCssModule(block)) throw new Error("<style module> is not supported in custom element mode");
|
|
586
|
+
params.set("inline", "");
|
|
587
|
+
const bindingName = `_style_${block.index}`;
|
|
588
|
+
const importUrl = createStyleImportUrl(filePath, params, block);
|
|
589
|
+
styleImports.push(`import ${bindingName} from ${JSON.stringify(importUrl)};`);
|
|
590
|
+
customElementStyleBindings.push(bindingName);
|
|
591
|
+
} else if (isCssModule(block)) {
|
|
577
592
|
const bindingName = typeof block.module === "string" ? block.module : "$style";
|
|
578
593
|
params.set("module", typeof block.module === "string" ? block.module : "");
|
|
579
|
-
const importUrl =
|
|
594
|
+
const importUrl = createStyleImportUrl(filePath, params, block);
|
|
580
595
|
cssModuleImports.push(`import ${bindingName} from ${JSON.stringify(importUrl)};`);
|
|
581
596
|
} else {
|
|
582
|
-
const importUrl =
|
|
597
|
+
const importUrl = createStyleImportUrl(filePath, params, block);
|
|
583
598
|
styleImports.push(`import ${JSON.stringify(importUrl)};`);
|
|
584
599
|
}
|
|
585
600
|
}
|
|
586
601
|
const allImports = [...styleImports, ...cssModuleImports].join("\n");
|
|
587
602
|
if (allImports) emitted.edit(insertAfterStaticImports(emitted.code, allImports));
|
|
588
|
-
if (
|
|
603
|
+
if (customElementStyleBindings.length > 0) emitted.edit(insertBeforeSfcMainDefaultExport(emitted.code, `_sfc_main.styles = [${customElementStyleBindings.join(", ")}];`, { normalizeSemicolon: true }));
|
|
604
|
+
else if (cssModuleImports.length > 0) {
|
|
589
605
|
const moduleBindings = [];
|
|
590
606
|
for (const block of compiled.styles) if (isCssModule(block)) {
|
|
591
607
|
const bindingName = typeof block.module === "string" ? block.module : "$style";
|
|
@@ -725,6 +741,37 @@ function createLogger(debug) {
|
|
|
725
741
|
};
|
|
726
742
|
}
|
|
727
743
|
//#endregion
|
|
744
|
+
//#region src/plugin/plugin-vue-options.ts
|
|
745
|
+
const PLUGIN_VUE_COMPAT_VERSION = "6.0.7";
|
|
746
|
+
const DEFAULT_CUSTOM_ELEMENT_PATTERN = /\.ce\.vue$/;
|
|
747
|
+
function booleanCompilerOption(value) {
|
|
748
|
+
return typeof value === "boolean" ? value : void 0;
|
|
749
|
+
}
|
|
750
|
+
function resolvePluginVueCompileOptions(options) {
|
|
751
|
+
const compilerOptions = options.template?.compilerOptions;
|
|
752
|
+
const resolved = { styleTrim: options.style?.trim ?? true };
|
|
753
|
+
const templateCacheHandlers = booleanCompilerOption(compilerOptions?.cacheHandlers);
|
|
754
|
+
const templateComments = booleanCompilerOption(compilerOptions?.comments);
|
|
755
|
+
const templateHoistStatic = booleanCompilerOption(compilerOptions?.hoistStatic);
|
|
756
|
+
const templatePrefixIdentifiers = booleanCompilerOption(compilerOptions?.prefixIdentifiers);
|
|
757
|
+
if (templateCacheHandlers !== void 0) resolved.templateCacheHandlers = templateCacheHandlers;
|
|
758
|
+
if (templateComments !== void 0) resolved.templateComments = templateComments;
|
|
759
|
+
if (templateHoistStatic !== void 0) resolved.templateHoistStatic = templateHoistStatic;
|
|
760
|
+
if (templatePrefixIdentifiers !== void 0) resolved.templatePrefixIdentifiers = templatePrefixIdentifiers;
|
|
761
|
+
return resolved;
|
|
762
|
+
}
|
|
763
|
+
function resolveCustomElementOption(options) {
|
|
764
|
+
const featureCustomElement = options.features?.customElement;
|
|
765
|
+
if (featureCustomElement) return featureCustomElement;
|
|
766
|
+
if (options.customElement !== void 0) return options.customElement;
|
|
767
|
+
return DEFAULT_CUSTOM_ELEMENT_PATTERN;
|
|
768
|
+
}
|
|
769
|
+
function isPluginVueCustomElement(options, filePath) {
|
|
770
|
+
const customElement = resolveCustomElementOption(options);
|
|
771
|
+
if (typeof customElement === "boolean") return customElement;
|
|
772
|
+
return createFilter(customElement, void 0)(filePath);
|
|
773
|
+
}
|
|
774
|
+
//#endregion
|
|
728
775
|
//#region src/plugin/precompile.ts
|
|
729
776
|
const DEFAULT_PRECOMPILE_IGNORE_PATTERNS = [
|
|
730
777
|
"node_modules/**",
|
|
@@ -770,8 +817,10 @@ function getCompileOptionsForRequest(state, ssr) {
|
|
|
770
817
|
ssr,
|
|
771
818
|
vapor: !ssr && (state.mergedOptions?.vapor ?? false),
|
|
772
819
|
customRenderer: state.mergedOptions?.customRenderer ?? false,
|
|
773
|
-
templateSyntax: state.mergedOptions?.templateSyntax ?? "standard"
|
|
820
|
+
templateSyntax: state.mergedOptions?.templateSyntax ?? "standard",
|
|
821
|
+
...resolvePluginVueCompileOptions(state.mergedOptions ?? {})
|
|
774
822
|
};
|
|
823
|
+
if (state.mergedOptions?.customElements !== void 0) options.customElements = state.mergedOptions.customElements;
|
|
775
824
|
if (state.mergedOptions?.mode !== void 0) options.mode = state.mergedOptions.mode;
|
|
776
825
|
if (state.mergedOptions?.runtimeModuleName !== void 0) options.runtimeModuleName = state.mergedOptions.runtimeModuleName;
|
|
777
826
|
if (state.mergedOptions?.runtimeGlobalName !== void 0) options.runtimeGlobalName = state.mergedOptions.runtimeGlobalName;
|
|
@@ -908,10 +957,16 @@ function buildCompileFileOptions(filePath, options) {
|
|
|
908
957
|
ssr: options.ssr,
|
|
909
958
|
vapor: options.vapor,
|
|
910
959
|
customRenderer: options.customRenderer ?? false,
|
|
960
|
+
...options.customElements === void 0 ? {} : { customElements: options.customElements },
|
|
911
961
|
experimentalInTagComments: options.experimentalInTagComments ?? false,
|
|
912
962
|
experimentalPatternedTemplate: options.experimentalPatternedTemplate ?? false,
|
|
913
963
|
experimentalServerScript: options.experimentalServerScript ?? false,
|
|
914
964
|
scopeId: `data-v-${generateScopeId(filePath)}`,
|
|
965
|
+
styleTrim: options.styleTrim,
|
|
966
|
+
...options.templateCacheHandlers === void 0 ? {} : { templateCacheHandlers: options.templateCacheHandlers },
|
|
967
|
+
...options.templateComments === void 0 ? {} : { templateComments: options.templateComments },
|
|
968
|
+
...options.templateHoistStatic === void 0 ? {} : { templateHoistStatic: options.templateHoistStatic },
|
|
969
|
+
...options.templatePrefixIdentifiers === void 0 ? {} : { templatePrefixIdentifiers: options.templatePrefixIdentifiers },
|
|
915
970
|
...options.mode === void 0 ? {} : { mode: options.mode },
|
|
916
971
|
...options.templateSyntax === void 0 ? {} : { templateSyntax: options.templateSyntax },
|
|
917
972
|
...options.runtimeModuleName === void 0 ? {} : { runtimeModuleName: options.runtimeModuleName },
|
|
@@ -924,6 +979,7 @@ function buildCompileBatchOptions(options) {
|
|
|
924
979
|
ssr: options.ssr,
|
|
925
980
|
vapor: options.vapor,
|
|
926
981
|
customRenderer: options.customRenderer ?? false,
|
|
982
|
+
...options.customElements === void 0 ? {} : { customElements: options.customElements },
|
|
927
983
|
experimentalInTagComments: options.experimentalInTagComments ?? false,
|
|
928
984
|
experimentalPatternedTemplate: options.experimentalPatternedTemplate ?? false,
|
|
929
985
|
experimentalServerScript: options.experimentalServerScript ?? false,
|
|
@@ -931,6 +987,11 @@ function buildCompileBatchOptions(options) {
|
|
|
931
987
|
includeMacroArtifacts: true,
|
|
932
988
|
includeHashes: true,
|
|
933
989
|
includeSourceMap: options.sourceMap,
|
|
990
|
+
styleTrim: options.styleTrim,
|
|
991
|
+
...options.templateCacheHandlers === void 0 ? {} : { templateCacheHandlers: options.templateCacheHandlers },
|
|
992
|
+
...options.templateComments === void 0 ? {} : { templateComments: options.templateComments },
|
|
993
|
+
...options.templateHoistStatic === void 0 ? {} : { templateHoistStatic: options.templateHoistStatic },
|
|
994
|
+
...options.templatePrefixIdentifiers === void 0 ? {} : { templatePrefixIdentifiers: options.templatePrefixIdentifiers },
|
|
934
995
|
...options.mode === void 0 ? {} : { mode: options.mode },
|
|
935
996
|
...options.templateSyntax === void 0 ? {} : { templateSyntax: options.templateSyntax },
|
|
936
997
|
...options.runtimeModuleName === void 0 ? {} : { runtimeModuleName: options.runtimeModuleName },
|
|
@@ -1588,19 +1649,26 @@ function writeManifest(file, container, onDiagnostic) {
|
|
|
1588
1649
|
* that reaches the native compiler reaches the key with it.
|
|
1589
1650
|
*/
|
|
1590
1651
|
function resolvePrecompileBatchOptions(state) {
|
|
1652
|
+
const requestOptions = getCompileOptionsForRequest(state, false);
|
|
1591
1653
|
return {
|
|
1592
|
-
sourceMap:
|
|
1654
|
+
sourceMap: requestOptions.sourceMap,
|
|
1593
1655
|
ssr: false,
|
|
1594
1656
|
vapor: state.mergedOptions.vapor ?? false,
|
|
1595
1657
|
mode: state.mergedOptions.mode,
|
|
1596
1658
|
customRenderer: state.mergedOptions.customRenderer ?? false,
|
|
1659
|
+
customElements: state.mergedOptions.customElements,
|
|
1597
1660
|
templateSyntax: state.mergedOptions.templateSyntax ?? "standard",
|
|
1598
1661
|
experimentalInTagComments: state.mergedOptions.experimentalInTagComments ?? false,
|
|
1599
1662
|
experimentalPatternedTemplate: state.mergedOptions.experimentalPatternedTemplate ?? false,
|
|
1600
1663
|
experimentalServerScript: state.mergedOptions.experimentalServerScript ?? false,
|
|
1601
1664
|
runtimeModuleName: state.mergedOptions.runtimeModuleName,
|
|
1602
1665
|
runtimeGlobalName: state.mergedOptions.runtimeGlobalName,
|
|
1603
|
-
vueVersion: state.mergedOptions.vueVersion
|
|
1666
|
+
vueVersion: state.mergedOptions.vueVersion,
|
|
1667
|
+
styleTrim: requestOptions.styleTrim,
|
|
1668
|
+
templateCacheHandlers: requestOptions.templateCacheHandlers,
|
|
1669
|
+
templateComments: requestOptions.templateComments,
|
|
1670
|
+
templateHoistStatic: requestOptions.templateHoistStatic,
|
|
1671
|
+
templatePrefixIdentifiers: requestOptions.templatePrefixIdentifiers
|
|
1604
1672
|
};
|
|
1605
1673
|
}
|
|
1606
1674
|
function openCacheForRun(state, batchOptions) {
|
|
@@ -1682,7 +1750,10 @@ async function compileAll(state) {
|
|
|
1682
1750
|
state.cache.set(file, restored);
|
|
1683
1751
|
const metadata = currentMetadata.get(file);
|
|
1684
1752
|
if (metadata) state.precompileMetadata.set(file, metadata);
|
|
1685
|
-
syncCollectedCssForFile(
|
|
1753
|
+
syncCollectedCssForFile({
|
|
1754
|
+
...state,
|
|
1755
|
+
extractCss: state.extractCss && !isPluginVueCustomElement(state.mergedOptions, file)
|
|
1756
|
+
}, file, restored);
|
|
1686
1757
|
restoredCount++;
|
|
1687
1758
|
continue;
|
|
1688
1759
|
}
|
|
@@ -1712,7 +1783,10 @@ async function compileAll(state) {
|
|
|
1712
1783
|
const compiled = state.cache.get(fileResult.path);
|
|
1713
1784
|
const sourceHash = sourceHashes.get(fileResult.path);
|
|
1714
1785
|
if (compiled && sourceHash !== void 0) cache.set(fileResult.path, sourceHash, compiled);
|
|
1715
|
-
syncCollectedCssForFile(
|
|
1786
|
+
syncCollectedCssForFile({
|
|
1787
|
+
...state,
|
|
1788
|
+
extractCss: state.extractCss && !isPluginVueCustomElement(state.mergedOptions, fileResult.path)
|
|
1789
|
+
}, fileResult.path, compiled);
|
|
1716
1790
|
}
|
|
1717
1791
|
}
|
|
1718
1792
|
cache.retain(new Set(sfcFiles));
|
|
@@ -2639,6 +2713,13 @@ async function transformVizeVirtualModule(state, code, realPath, ssr, forceTypeS
|
|
|
2639
2713
|
}
|
|
2640
2714
|
}
|
|
2641
2715
|
//#endregion
|
|
2716
|
+
//#region src/plugin/load-style.ts
|
|
2717
|
+
function normalizeStyleVirtualId(id) {
|
|
2718
|
+
const withoutPrefix = id.startsWith("\0") ? id.slice(1) : id;
|
|
2719
|
+
if (!withoutPrefix.includes("?vue")) return id;
|
|
2720
|
+
return withoutPrefix.replace(/\.module\.\w+$/, "").replace(/\.\w+$/, "");
|
|
2721
|
+
}
|
|
2722
|
+
//#endregion
|
|
2642
2723
|
//#region src/plugin/load.ts
|
|
2643
2724
|
const SERVER_PLACEHOLDER_CODE = `import { createElementBlock, defineComponent } from "vue";
|
|
2644
2725
|
export default defineComponent({
|
|
@@ -2669,11 +2750,6 @@ function findMacroArtifactModule(state, realPath, ssr, kind) {
|
|
|
2669
2750
|
}, realPath, compiled);
|
|
2670
2751
|
return compiled?.macroArtifacts?.find((artifact) => artifact.kind === kind)?.moduleCode ?? null;
|
|
2671
2752
|
}
|
|
2672
|
-
function normalizeStyleVirtualId(id) {
|
|
2673
|
-
const withoutPrefix = id.startsWith("\0") ? id.slice(1) : id;
|
|
2674
|
-
if (!withoutPrefix.includes("?vue")) return id;
|
|
2675
|
-
return withoutPrefix.replace(/\.module\.\w+$/, "").replace(/\.\w+$/, "");
|
|
2676
|
-
}
|
|
2677
2753
|
function loadCompiledSfcModule(state, realPath, isSsr, currentBase, loadOptions) {
|
|
2678
2754
|
const placeholderCode = getBoundaryPlaceholderCode(realPath, !!loadOptions?.ssr);
|
|
2679
2755
|
if (placeholderCode) {
|
|
@@ -2684,7 +2760,8 @@ function loadCompiledSfcModule(state, realPath, isSsr, currentBase, loadOptions)
|
|
|
2684
2760
|
};
|
|
2685
2761
|
}
|
|
2686
2762
|
const cache = getEnvironmentCache(state, isSsr);
|
|
2687
|
-
const
|
|
2763
|
+
const customElement = isPluginVueCustomElement(state.mergedOptions, realPath);
|
|
2764
|
+
const extractCss = shouldExtractCssForRequest(state, isSsr) && !customElement;
|
|
2688
2765
|
let compiled = cache.get(realPath);
|
|
2689
2766
|
if (!compiled && fs.existsSync(realPath)) {
|
|
2690
2767
|
state.logger.log(`load: on-demand compiling ${realPath}`);
|
|
@@ -2703,6 +2780,7 @@ function loadCompiledSfcModule(state, realPath, isSsr, currentBase, loadOptions)
|
|
|
2703
2780
|
ssr: isSsr,
|
|
2704
2781
|
hmrUpdateType: loadOptions?.ssr ? void 0 : state.pendingHmrUpdateTypes.get(realPath),
|
|
2705
2782
|
extractCss,
|
|
2783
|
+
customElement,
|
|
2706
2784
|
filePath: realPath
|
|
2707
2785
|
};
|
|
2708
2786
|
if (compiled.css && !hasDelegated && embedsInlineCss(compiled, outputOptions)) compiled = {
|
|
@@ -2994,6 +3072,15 @@ async function handleHotUpdateHook(state, ctx, options = {}) {
|
|
|
2994
3072
|
state.logger.log(`Re-compiled: ${path.relative(state.root, file)} (${updateType})`);
|
|
2995
3073
|
const modules = preferAcceptingClientModules(initialModules ?? await collectModulesByFile(server, getVueModuleFileCandidates(file)), options.requireAcceptingClientModule);
|
|
2996
3074
|
const hasDelegated = hasDelegatedStyles(newCompiled);
|
|
3075
|
+
if (isPluginVueCustomElement(state.mergedOptions, file) && updateType === "style-only") {
|
|
3076
|
+
if (modules.size > 0) {
|
|
3077
|
+
state.pendingHmrUpdateTypes.set(file, "full-reload");
|
|
3078
|
+
invalidateModules(server, modules);
|
|
3079
|
+
return [...modules];
|
|
3080
|
+
}
|
|
3081
|
+
state.pendingHmrUpdateTypes.delete(file);
|
|
3082
|
+
return [];
|
|
3083
|
+
}
|
|
2997
3084
|
if (hasDelegated && updateType === "style-only") {
|
|
2998
3085
|
const affectedModules = /* @__PURE__ */ new Set();
|
|
2999
3086
|
for (const block of newCompiled.styles ?? []) {
|
|
@@ -3099,6 +3186,10 @@ async function handleHotUpdateEnvironmentHook(state, environment, options) {
|
|
|
3099
3186
|
*/
|
|
3100
3187
|
function createVueCompatPlugin(state, options) {
|
|
3101
3188
|
let compilerSfc = null;
|
|
3189
|
+
const templateOptions = { compilerOptions: {
|
|
3190
|
+
directiveTransforms: {},
|
|
3191
|
+
nodeTransforms: []
|
|
3192
|
+
} };
|
|
3102
3193
|
const loadCompilerSfc = () => {
|
|
3103
3194
|
if (!compilerSfc) try {
|
|
3104
3195
|
compilerSfc = createRequire(import.meta.url)("@vue/compiler-sfc");
|
|
@@ -3122,7 +3213,7 @@ function createVueCompatPlugin(state, options) {
|
|
|
3122
3213
|
compiler: loadCompilerSfc(),
|
|
3123
3214
|
isProduction: state.isProduction ?? false,
|
|
3124
3215
|
root: state.root ?? process.cwd(),
|
|
3125
|
-
template:
|
|
3216
|
+
template: templateOptions
|
|
3126
3217
|
};
|
|
3127
3218
|
},
|
|
3128
3219
|
get include() {
|
|
@@ -3138,7 +3229,8 @@ function createVueCompatPlugin(state, options) {
|
|
|
3138
3229
|
set exclude(value) {
|
|
3139
3230
|
assertUnresolved("exclude");
|
|
3140
3231
|
options.exclude = value;
|
|
3141
|
-
}
|
|
3232
|
+
},
|
|
3233
|
+
version: PLUGIN_VUE_COMPAT_VERSION
|
|
3142
3234
|
}
|
|
3143
3235
|
};
|
|
3144
3236
|
}
|
|
@@ -3779,10 +3871,7 @@ function resolveVueFeatureDefines(features, define) {
|
|
|
3779
3871
|
};
|
|
3780
3872
|
}
|
|
3781
3873
|
//#endregion
|
|
3782
|
-
//#region src/plugin/index.ts
|
|
3783
|
-
function aliasSortKey(find) {
|
|
3784
|
-
return typeof find === "string" ? find.length : find.source.length;
|
|
3785
|
-
}
|
|
3874
|
+
//#region src/plugin/index-helpers.ts
|
|
3786
3875
|
function shouldExtractCssForBuild(state, context) {
|
|
3787
3876
|
if (!state.isProduction) return false;
|
|
3788
3877
|
const environmentName = context.environment?.name;
|
|
@@ -3799,6 +3888,11 @@ function resolveCompatibilityOptions(options, compilerConfig = {}) {
|
|
|
3799
3888
|
if (compatibility.hostCompiler === void 0 && isLegacyVueVersion(vueVersion)) compatibility.hostCompiler = true;
|
|
3800
3889
|
return compatibility;
|
|
3801
3890
|
}
|
|
3891
|
+
function aliasSortKey(find) {
|
|
3892
|
+
return typeof find === "string" ? find.length : find.source.length;
|
|
3893
|
+
}
|
|
3894
|
+
//#endregion
|
|
3895
|
+
//#region src/plugin/index.ts
|
|
3802
3896
|
function vize(options = {}) {
|
|
3803
3897
|
if (isLegacyVueCompatibilityMode(options)) return [createLegacyVueCompatibilityPlugin(options)];
|
|
3804
3898
|
const state = {
|
|
@@ -3878,6 +3972,7 @@ function vize(options = {}) {
|
|
|
3878
3972
|
sourceMap: options.sourceMap ?? compilerConfig.sourceMap,
|
|
3879
3973
|
...resolveExperimentalCompilerOptions(options, compilerConfig, sharedConfig?.experimentals),
|
|
3880
3974
|
customRenderer: options.customRenderer ?? compilerConfig.customRenderer ?? false,
|
|
3975
|
+
customElements: options.customElements ?? compilerConfig.customElements,
|
|
3881
3976
|
templateSyntax,
|
|
3882
3977
|
compatibility,
|
|
3883
3978
|
vueVersion,
|
|
@@ -3953,6 +4048,9 @@ function vize(options = {}) {
|
|
|
3953
4048
|
async hotUpdate(options) {
|
|
3954
4049
|
return handleHotUpdateEnvironmentHook(state, this.environment, options);
|
|
3955
4050
|
},
|
|
4051
|
+
shouldTransformCachedModule({ id }) {
|
|
4052
|
+
return id?.includes(".vue") ? true : void 0;
|
|
4053
|
+
},
|
|
3956
4054
|
async handleHotUpdate(ctx) {
|
|
3957
4055
|
return handleHotUpdateHook(state, ctx);
|
|
3958
4056
|
},
|
|
@@ -74,6 +74,10 @@ interface CompilerConfig {
|
|
|
74
74
|
* Treat lowercase non-HTML tags as custom renderer elements
|
|
75
75
|
*/
|
|
76
76
|
customRenderer?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Tag patterns that compile as custom elements instead of Vue components
|
|
79
|
+
*/
|
|
80
|
+
customElements?: string[];
|
|
77
81
|
/**
|
|
78
82
|
* Enable SSR mode
|
|
79
83
|
*/
|
|
@@ -712,6 +716,36 @@ interface ExperimentalPluginOptions extends ExperimentalCompileFlags {
|
|
|
712
716
|
experimentals?: ExperimentalOptions;
|
|
713
717
|
}
|
|
714
718
|
//#endregion
|
|
719
|
+
//#region src/compatibility-types.d.ts
|
|
720
|
+
type VizeVueVersion = 0.11 | 1 | 2 | "2.7" | 3 | "legacy";
|
|
721
|
+
interface VizeCompatibilityOptions {
|
|
722
|
+
/**
|
|
723
|
+
* Host Vue version. Vue 0.11/1/2/2.7 opt into host-compiler compatibility.
|
|
724
|
+
*/
|
|
725
|
+
vueVersion?: VizeVueVersion;
|
|
726
|
+
/**
|
|
727
|
+
* Keep .vue files on the existing Vue compiler for legacy Vue runtimes.
|
|
728
|
+
* @default true when vueVersion is 0.11, 1, 2, "2.7", or "legacy"
|
|
729
|
+
*/
|
|
730
|
+
hostCompiler?: boolean;
|
|
731
|
+
/**
|
|
732
|
+
* Enable function-body output for CDN/global Vue evaluation.
|
|
733
|
+
*/
|
|
734
|
+
scriptSetupInStandalone?: boolean;
|
|
735
|
+
/**
|
|
736
|
+
* Allow Vapor output for Options API SFCs when vapor is enabled.
|
|
737
|
+
*/
|
|
738
|
+
optionsApiVapor?: boolean;
|
|
739
|
+
/**
|
|
740
|
+
* Override the host Nuxt major when this option object is shared with Nuxt.
|
|
741
|
+
*/
|
|
742
|
+
nuxtVersion?: 2 | 3 | 4;
|
|
743
|
+
/**
|
|
744
|
+
* Override the host Webpack major when this option object is shared with unplugin.
|
|
745
|
+
*/
|
|
746
|
+
webpackVersion?: 4 | 5;
|
|
747
|
+
}
|
|
748
|
+
//#endregion
|
|
715
749
|
//#region src/inspector-types.d.ts
|
|
716
750
|
interface VizeInspectorLintPlanRequest {
|
|
717
751
|
/** Project-relative files whose effective lint rules should be explained. */
|
|
@@ -725,6 +759,36 @@ interface VizeInspectorOptions {
|
|
|
725
759
|
lintPlan?: VizeInspectorLintPlanProvider;
|
|
726
760
|
}
|
|
727
761
|
//#endregion
|
|
762
|
+
//#region src/plugin-vue-types.d.ts
|
|
763
|
+
type VitePluginVueFilterPattern = string | RegExp | (string | RegExp)[];
|
|
764
|
+
type VitePluginVueCustomElementOption = boolean | VitePluginVueFilterPattern;
|
|
765
|
+
type VitePluginVueComponentIdGenerator = "filepath" | "filepath-source" | ((filepath: string, source: string, isProduction: boolean, getHash: (text: string) => string) => string);
|
|
766
|
+
interface VitePluginVueScriptOptions {
|
|
767
|
+
hoistStatic?: boolean;
|
|
768
|
+
propsDestructure?: boolean | "error";
|
|
769
|
+
globalTypeFiles?: string[];
|
|
770
|
+
[key: string]: unknown;
|
|
771
|
+
}
|
|
772
|
+
interface VitePluginVueTemplateCompilerOptions {
|
|
773
|
+
comments?: boolean;
|
|
774
|
+
hoistStatic?: boolean;
|
|
775
|
+
cacheHandlers?: boolean;
|
|
776
|
+
prefixIdentifiers?: boolean;
|
|
777
|
+
[key: string]: unknown;
|
|
778
|
+
}
|
|
779
|
+
interface VitePluginVueTemplateOptions {
|
|
780
|
+
compilerOptions?: VitePluginVueTemplateCompilerOptions;
|
|
781
|
+
transformAssetUrls?: boolean | Record<string, unknown>;
|
|
782
|
+
preprocessCustomRequire?: unknown;
|
|
783
|
+
preprocessOptions?: Record<string, unknown>;
|
|
784
|
+
[key: string]: unknown;
|
|
785
|
+
}
|
|
786
|
+
interface VitePluginVueStyleOptions {
|
|
787
|
+
trim?: boolean;
|
|
788
|
+
inMap?: unknown;
|
|
789
|
+
[key: string]: unknown;
|
|
790
|
+
}
|
|
791
|
+
//#endregion
|
|
728
792
|
//#region src/vue-features.d.ts
|
|
729
793
|
/** Vue runtime feature flags shared with `@vitejs/plugin-vue`. */
|
|
730
794
|
interface VizeVueFeatures {
|
|
@@ -744,6 +808,12 @@ interface VizeVueFeatures {
|
|
|
744
808
|
* @default false
|
|
745
809
|
*/
|
|
746
810
|
prodHydrationMismatchDetails?: boolean;
|
|
811
|
+
/** Custom-element matcher from `@vitejs/plugin-vue`'s `features` bag. */
|
|
812
|
+
customElement?: VitePluginVueCustomElementOption;
|
|
813
|
+
/** Vue 3.5 reactive props destructure feature flag. */
|
|
814
|
+
propsDestructure?: boolean | "error";
|
|
815
|
+
/** Scope-id strategy hook accepted for plugin-vue config compatibility. */
|
|
816
|
+
componentIdGenerator?: VitePluginVueComponentIdGenerator;
|
|
747
817
|
}
|
|
748
818
|
//#endregion
|
|
749
819
|
//#region src/utils/module-output.d.ts
|
|
@@ -768,7 +838,7 @@ type ModuleOutputInfo = {
|
|
|
768
838
|
defaultExportIsSfcMain: boolean;
|
|
769
839
|
};
|
|
770
840
|
//#endregion
|
|
771
|
-
//#region src/types.d.ts
|
|
841
|
+
//#region src/sfc-types.d.ts
|
|
772
842
|
interface MacroArtifact {
|
|
773
843
|
kind: string;
|
|
774
844
|
name: string;
|
|
@@ -778,34 +848,51 @@ interface MacroArtifact {
|
|
|
778
848
|
start: number;
|
|
779
849
|
end: number;
|
|
780
850
|
}
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
/**
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
* Allow Vapor output for Options API SFCs when vapor is enabled.
|
|
798
|
-
*/
|
|
799
|
-
optionsApiVapor?: boolean;
|
|
851
|
+
interface StyleBlockInfo {
|
|
852
|
+
/** Raw style content (uncompiled for preprocessor langs) */
|
|
853
|
+
content: string;
|
|
854
|
+
/** External source path from `<style src>`, when present */
|
|
855
|
+
src?: string | null;
|
|
856
|
+
/** Language of the style block (e.g., "css", "scss", "less", "sass", "stylus") */
|
|
857
|
+
lang: string | null;
|
|
858
|
+
/** Whether the style block has the scoped attribute */
|
|
859
|
+
scoped: boolean;
|
|
860
|
+
/** CSS Modules: true for unnamed `module`, or the binding name for `module="name"` */
|
|
861
|
+
module: boolean | string;
|
|
862
|
+
/** Index of this style block in the SFC */
|
|
863
|
+
index: number;
|
|
864
|
+
}
|
|
865
|
+
interface CompiledModule {
|
|
866
|
+
code: string;
|
|
800
867
|
/**
|
|
801
|
-
*
|
|
868
|
+
* Source Map v3 document (JSON) describing `code`, when the compiler was
|
|
869
|
+
* asked for one (#3399). Absent when source maps are off, when the SFC has no
|
|
870
|
+
* script block, and for the rspack and unplugin builders, which do not request
|
|
871
|
+
* maps. Persisted with the rest of the module in the pre-compile cache.
|
|
802
872
|
*/
|
|
803
|
-
|
|
873
|
+
map?: string;
|
|
874
|
+
css?: string;
|
|
875
|
+
scopeId: string;
|
|
876
|
+
hasScoped: boolean;
|
|
877
|
+
templateHash?: string;
|
|
878
|
+
styleHash?: string;
|
|
879
|
+
scriptHash?: string;
|
|
880
|
+
/** Compile-time macro artifacts extracted from the source SFC */
|
|
881
|
+
macroArtifacts?: MacroArtifact[];
|
|
882
|
+
/** Per-block style metadata extracted from the source SFC */
|
|
883
|
+
styles?: StyleBlockInfo[];
|
|
884
|
+
/** Files loaded through SFC `src` imports */
|
|
885
|
+
dependencies?: string[];
|
|
804
886
|
/**
|
|
805
|
-
*
|
|
887
|
+
* Module shape reported by the native compiler, so `generateOutput` need not
|
|
888
|
+
* re-parse the emitted module (#3425). Absent for a cache entry written before
|
|
889
|
+
* the field existed, and for the rspack and unplugin builders, which never set
|
|
890
|
+
* it — both fall back to parsing.
|
|
806
891
|
*/
|
|
807
|
-
|
|
892
|
+
moduleShape?: ModuleOutputInfo;
|
|
808
893
|
}
|
|
894
|
+
//#endregion
|
|
895
|
+
//#region src/types.d.ts
|
|
809
896
|
interface VizeOptions extends ExperimentalPluginOptions {
|
|
810
897
|
/**
|
|
811
898
|
* Inline shared Vize config for Vite Plus-first projects.
|
|
@@ -816,6 +903,19 @@ interface VizeOptions extends ExperimentalPluginOptions {
|
|
|
816
903
|
inspector?: VizeInspectorOptions;
|
|
817
904
|
/** Vue runtime feature flags compatible with `@vitejs/plugin-vue`. */
|
|
818
905
|
features?: VizeVueFeatures;
|
|
906
|
+
/** `@vitejs/plugin-vue` script option bag accepted for drop-in config parity. */
|
|
907
|
+
script?: VitePluginVueScriptOptions;
|
|
908
|
+
/** `@vitejs/plugin-vue` template option bag. */
|
|
909
|
+
template?: VitePluginVueTemplateOptions;
|
|
910
|
+
/** `@vitejs/plugin-vue` style option bag. */
|
|
911
|
+
style?: VitePluginVueStyleOptions;
|
|
912
|
+
/** Lower-level compiler override accepted for plugin-vue config parity. */
|
|
913
|
+
compiler?: unknown;
|
|
914
|
+
/**
|
|
915
|
+
* Top-level custom-element matcher supported by `@vitejs/plugin-vue`.
|
|
916
|
+
* @default /\.ce\.vue$/
|
|
917
|
+
*/
|
|
918
|
+
customElement?: VitePluginVueCustomElementOption;
|
|
819
919
|
/**
|
|
820
920
|
* Vue major version for the host project.
|
|
821
921
|
*
|
|
@@ -898,6 +998,11 @@ interface VizeOptions extends ExperimentalPluginOptions {
|
|
|
898
998
|
* @default false
|
|
899
999
|
*/
|
|
900
1000
|
customRenderer?: boolean;
|
|
1001
|
+
/**
|
|
1002
|
+
* Tag patterns that compile as custom elements instead of Vue components.
|
|
1003
|
+
* Supports exact tags and `*` wildcards, e.g. `["Tres*", "primitive"]`.
|
|
1004
|
+
*/
|
|
1005
|
+
customElements?: string[];
|
|
901
1006
|
/**
|
|
902
1007
|
* Template syntax compatibility mode.
|
|
903
1008
|
* @default "standard"
|
|
@@ -951,48 +1056,5 @@ interface VizeOptions extends ExperimentalPluginOptions {
|
|
|
951
1056
|
*/
|
|
952
1057
|
debug?: boolean;
|
|
953
1058
|
}
|
|
954
|
-
interface StyleBlockInfo {
|
|
955
|
-
/** Raw style content (uncompiled for preprocessor langs) */
|
|
956
|
-
content: string;
|
|
957
|
-
/** External source path from `<style src>`, when present */
|
|
958
|
-
src?: string | null;
|
|
959
|
-
/** Language of the style block (e.g., "css", "scss", "less", "sass", "stylus") */
|
|
960
|
-
lang: string | null;
|
|
961
|
-
/** Whether the style block has the scoped attribute */
|
|
962
|
-
scoped: boolean;
|
|
963
|
-
/** CSS Modules: true for unnamed `module`, or the binding name for `module="name"` */
|
|
964
|
-
module: boolean | string;
|
|
965
|
-
/** Index of this style block in the SFC */
|
|
966
|
-
index: number;
|
|
967
|
-
}
|
|
968
|
-
interface CompiledModule {
|
|
969
|
-
code: string;
|
|
970
|
-
/**
|
|
971
|
-
* Source Map v3 document (JSON) describing `code`, when the compiler was
|
|
972
|
-
* asked for one (#3399). Absent when source maps are off, when the SFC has no
|
|
973
|
-
* script block, and for the rspack and unplugin builders, which do not request
|
|
974
|
-
* maps. Persisted with the rest of the module in the pre-compile cache.
|
|
975
|
-
*/
|
|
976
|
-
map?: string;
|
|
977
|
-
css?: string;
|
|
978
|
-
scopeId: string;
|
|
979
|
-
hasScoped: boolean;
|
|
980
|
-
templateHash?: string;
|
|
981
|
-
styleHash?: string;
|
|
982
|
-
scriptHash?: string;
|
|
983
|
-
/** Compile-time macro artifacts extracted from the source SFC */
|
|
984
|
-
macroArtifacts?: MacroArtifact[];
|
|
985
|
-
/** Per-block style metadata extracted from the source SFC */
|
|
986
|
-
styles?: StyleBlockInfo[];
|
|
987
|
-
/** Files loaded through SFC `src` imports */
|
|
988
|
-
dependencies?: string[];
|
|
989
|
-
/**
|
|
990
|
-
* Module shape reported by the native compiler, so `generateOutput` need not
|
|
991
|
-
* re-parse the emitted module (#3425). Absent for a cache entry written before
|
|
992
|
-
* the field existed, and for the rspack and unplugin builders, which never set
|
|
993
|
-
* it — both fall back to parsing.
|
|
994
|
-
*/
|
|
995
|
-
moduleShape?: ModuleOutputInfo;
|
|
996
|
-
}
|
|
997
1059
|
//#endregion
|
|
998
|
-
export {
|
|
1060
|
+
export { VizeInspectorLintPlanProvider as a, VizeCompatibilityOptions as c, LoadConfigOptions as d, ResolvedVizeConfig as f, VizeVueFeatures as i, VizeVueVersion as l, VizeConfig as m, CompiledModule as n, VizeInspectorLintPlanRequest as o, UserConfigExport as p, MacroArtifact as r, VizeInspectorOptions as s, VizeOptions as t, ConfigEnv as u };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vizejs/vite-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.351.0",
|
|
4
4
|
"description": "High-performance native Vite plugin for Vue SFC compilation powered by Vize",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compiler",
|
|
@@ -45,16 +45,16 @@
|
|
|
45
45
|
"access": "public"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@vizejs/native": "0.
|
|
49
|
-
"oxc-parser": "0.
|
|
50
|
-
"tinyglobby": "0.2.
|
|
51
|
-
"vize": "0.
|
|
48
|
+
"@vizejs/native": "0.351.0",
|
|
49
|
+
"oxc-parser": "0.144.0",
|
|
50
|
+
"tinyglobby": "0.2.17",
|
|
51
|
+
"vize": "0.351.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/node": "25.9.2",
|
|
55
55
|
"typescript": "6.0.3",
|
|
56
|
-
"vite": "npm:@voidzero-dev/vite-plus-core@0.1.
|
|
57
|
-
"vite-plus": "0.1.
|
|
56
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@0.1.24",
|
|
57
|
+
"vite-plus": "0.1.24"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"vite": "^7.3.0 || ^8.0.0"
|