@vizejs/vite-plugin 0.321.0 → 0.323.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 VizeVueVersion, c as
|
|
1
|
+
import { a as VizeVueVersion, c as VizeInspectorLintPlanRequest, d as LoadConfigOptions, f as ResolvedVizeConfig, i as VizeOptions, l as VizeInspectorOptions, m as VizeConfig, n as MacroArtifact, o as VizeVueFeatures, p as UserConfigExport, r as VizeCompatibilityOptions, s as VizeInspectorLintPlanProvider, t as CompiledModule, u as ConfigEnv } from "./types-DR5IFFd7.mjs";
|
|
2
2
|
import { Plugin } from "vite";
|
|
3
3
|
|
|
4
4
|
//#region src/virtual.d.ts
|
|
@@ -40,4 +40,4 @@ declare const __internal: {
|
|
|
40
40
|
rewriteStaticAssetUrls: typeof rewriteStaticAssetUrls;
|
|
41
41
|
};
|
|
42
42
|
//#endregion
|
|
43
|
-
export { type CompiledModule, type LoadConfigOptions, type MacroArtifact, type ResolvedVizeConfig, type UserConfigExport, VIZE_CONFIG_FILE_ENV, type VizeCompatibilityOptions, type VizeConfig, type VizeInspectorLintPlanProvider, type VizeInspectorLintPlanRequest, type VizeInspectorOptions, type VizeOptions, type VizeVueVersion, __internal, rewriteStaticAssetUrls as __internal_rewriteStaticAssetUrls, vize as default, vize, defineConfig, loadConfig, resolveConfigExport, vizeConfigStore };
|
|
43
|
+
export { type CompiledModule, type LoadConfigOptions, type MacroArtifact, type ResolvedVizeConfig, type UserConfigExport, VIZE_CONFIG_FILE_ENV, type VizeCompatibilityOptions, type VizeConfig, type VizeInspectorLintPlanProvider, type VizeInspectorLintPlanRequest, type VizeInspectorOptions, type VizeOptions, type VizeVueFeatures, type VizeVueVersion, __internal, rewriteStaticAssetUrls as __internal_rewriteStaticAssetUrls, vize as default, vize, defineConfig, loadConfig, resolveConfigExport, vizeConfigStore };
|
package/dist/index.mjs
CHANGED
|
@@ -597,6 +597,13 @@ function generateOutputWithMap(compiled, options) {
|
|
|
597
597
|
};
|
|
598
598
|
}
|
|
599
599
|
const RESOLVED_CSS_MODULE = "\0vize:all-styles.css";
|
|
600
|
+
/** Check if a module ID is a vize-compiled virtual module */
|
|
601
|
+
function isVizeVirtual(id) {
|
|
602
|
+
return classifyVitePluginRequest(id).isVizeVirtual;
|
|
603
|
+
}
|
|
604
|
+
function isVizeSsrVirtual(id) {
|
|
605
|
+
return classifyVitePluginRequest(id).isVizeSsrVirtual;
|
|
606
|
+
}
|
|
600
607
|
/** Create a virtual module ID from a real .vue file path */
|
|
601
608
|
function toVirtualId(realPath, ssr = false) {
|
|
602
609
|
return createViteVirtualId(realPath, ssr);
|
|
@@ -2571,7 +2578,6 @@ function loadCompiledSfcModule(state, realPath, isSsr, currentBase, loadOptions)
|
|
|
2571
2578
|
rewritten.edit(rewriteDynamicTemplateImports(rewritten.code, state.dynamicImportAliasRules));
|
|
2572
2579
|
rewritten.edit(rewriteStaticAssetUrls(rewritten.code, state.dynamicImportAliasRules));
|
|
2573
2580
|
rewritten.edit(rewriteImportMetaGlobBase(rewritten.code, realPath, state.root));
|
|
2574
|
-
if (!loadOptions?.ssr) state.pendingHmrUpdateTypes.delete(realPath);
|
|
2575
2581
|
return {
|
|
2576
2582
|
code: rewritten.code,
|
|
2577
2583
|
map: rewritten.map
|
|
@@ -2765,30 +2771,46 @@ function getVueModuleFileCandidates(vueFile) {
|
|
|
2765
2771
|
function getStyleModuleFileCandidates(styleId) {
|
|
2766
2772
|
return unique([styleId, `${styleId}.css`]);
|
|
2767
2773
|
}
|
|
2768
|
-
function collectModulesByFile(server, fileIds) {
|
|
2774
|
+
async function collectModulesByFile(server, fileIds) {
|
|
2769
2775
|
const modules = /* @__PURE__ */ new Set();
|
|
2776
|
+
const graph = server.moduleGraph;
|
|
2770
2777
|
for (const fileId of fileIds) {
|
|
2771
|
-
const
|
|
2772
|
-
|
|
2773
|
-
|
|
2778
|
+
const add = (module) => {
|
|
2779
|
+
if (module) modules.add(module);
|
|
2780
|
+
};
|
|
2781
|
+
add(graph.getModuleById?.(fileId));
|
|
2782
|
+
if (!fileId.startsWith("\0")) try {
|
|
2783
|
+
add(await graph.getModuleByUrl?.(fileId));
|
|
2784
|
+
} catch {}
|
|
2785
|
+
for (const module of graph.getModulesByFile(fileId) ?? []) add(module);
|
|
2774
2786
|
}
|
|
2775
2787
|
return modules;
|
|
2776
2788
|
}
|
|
2789
|
+
function preferAcceptingClientModules(modules, requireAcceptingClientModule = false) {
|
|
2790
|
+
const accepting = [...modules].filter((module) => {
|
|
2791
|
+
if (isVizeVirtual(module.url)) return !isVizeSsrVirtual(module.url);
|
|
2792
|
+
return fromPluginVisibleVirtualId(module.url) !== null && !isPluginVisibleSsrVirtualId(module.url);
|
|
2793
|
+
});
|
|
2794
|
+
if (accepting.length > 0) return new Set(accepting);
|
|
2795
|
+
return requireAcceptingClientModule ? /* @__PURE__ */ new Set() : modules;
|
|
2796
|
+
}
|
|
2777
2797
|
function invalidateModules(server, modules) {
|
|
2778
2798
|
for (const module of modules) server.moduleGraph.invalidateModule(module);
|
|
2779
2799
|
}
|
|
2780
|
-
async function handleHotUpdateHook(state, ctx) {
|
|
2800
|
+
async function handleHotUpdateHook(state, ctx, options = {}) {
|
|
2781
2801
|
const { file, server, read } = ctx;
|
|
2782
2802
|
const dependencyOwners = getVueFilesDependingOn(state, file);
|
|
2783
2803
|
if (dependencyOwners.length > 0) {
|
|
2784
2804
|
const affectedModules = /* @__PURE__ */ new Set();
|
|
2785
2805
|
for (const vueFile of dependencyOwners) {
|
|
2806
|
+
const collectedModules = await collectModulesByFile(server, getVueModuleFileCandidates(vueFile));
|
|
2807
|
+
const modules = options.requireAcceptingClientModule ? preferAcceptingClientModules(collectedModules, true) : collectedModules;
|
|
2808
|
+
if (options.requireAcceptingClientModule && modules.size === 0) continue;
|
|
2786
2809
|
state.cache.delete(vueFile);
|
|
2787
2810
|
state.ssrCache.delete(vueFile);
|
|
2788
2811
|
state.collectedCss.delete(vueFile);
|
|
2789
2812
|
state.precompileMetadata.delete(vueFile);
|
|
2790
2813
|
state.pendingHmrUpdateTypes.set(vueFile, "full-reload");
|
|
2791
|
-
const modules = collectModulesByFile(server, getVueModuleFileCandidates(vueFile));
|
|
2792
2814
|
for (const module of modules) {
|
|
2793
2815
|
server.moduleGraph.invalidateModule(module);
|
|
2794
2816
|
affectedModules.add(module);
|
|
@@ -2798,6 +2820,8 @@ async function handleHotUpdateHook(state, ctx) {
|
|
|
2798
2820
|
return [...affectedModules];
|
|
2799
2821
|
}
|
|
2800
2822
|
if (file.endsWith(".vue") && state.filter(file)) try {
|
|
2823
|
+
const initialModules = options.requireAcceptingClientModule ? preferAcceptingClientModules(await collectModulesByFile(server, getVueModuleFileCandidates(file)), true) : void 0;
|
|
2824
|
+
if (initialModules?.size === 0) return [];
|
|
2801
2825
|
const source = await read();
|
|
2802
2826
|
const prevCompiled = state.cache.get(file);
|
|
2803
2827
|
compileFile(file, state.cache, getCompileOptionsForRequest(state, false), source);
|
|
@@ -2819,7 +2843,7 @@ async function handleHotUpdateHook(state, ctx) {
|
|
|
2819
2843
|
}
|
|
2820
2844
|
const updateType = detectHmrUpdateType(prevCompiled, newCompiled);
|
|
2821
2845
|
state.logger.log(`Re-compiled: ${path.relative(state.root, file)} (${updateType})`);
|
|
2822
|
-
const modules = collectModulesByFile(server, getVueModuleFileCandidates(file));
|
|
2846
|
+
const modules = preferAcceptingClientModules(initialModules ?? await collectModulesByFile(server, getVueModuleFileCandidates(file)), options.requireAcceptingClientModule);
|
|
2823
2847
|
const hasDelegated = hasDelegatedStyles(newCompiled);
|
|
2824
2848
|
if (hasDelegated && updateType === "style-only") {
|
|
2825
2849
|
const affectedModules = /* @__PURE__ */ new Set();
|
|
@@ -2831,7 +2855,7 @@ async function handleHotUpdateHook(state, ctx) {
|
|
|
2831
2855
|
if (block.scoped) params.set("scoped", `data-v-${newCompiled.scopeId}`);
|
|
2832
2856
|
params.set("lang", block.lang ?? "css");
|
|
2833
2857
|
if (block.module !== false) params.set("module", typeof block.module === "string" ? block.module : "");
|
|
2834
|
-
const styleMods = collectModulesByFile(server, getStyleModuleFileCandidates(`${file}?${params.toString()}`));
|
|
2858
|
+
const styleMods = await collectModulesByFile(server, getStyleModuleFileCandidates(`${file}?${params.toString()}`));
|
|
2835
2859
|
for (const mod of styleMods) affectedModules.add(mod);
|
|
2836
2860
|
}
|
|
2837
2861
|
if (affectedModules.size > 0) return [...affectedModules];
|
|
@@ -2859,6 +2883,7 @@ async function handleHotUpdateHook(state, ctx) {
|
|
|
2859
2883
|
state.pendingHmrUpdateTypes.delete(file);
|
|
2860
2884
|
} catch (e) {
|
|
2861
2885
|
state.logger.error(`Re-compilation failed for ${file}:`, e);
|
|
2886
|
+
options.onRecompileError?.(e);
|
|
2862
2887
|
}
|
|
2863
2888
|
}
|
|
2864
2889
|
function handleGenerateBundleHook(state, emitFile, bundle) {
|
|
@@ -2890,6 +2915,28 @@ function attachComponentsCssToEntryChunks(bundle, cssFileName) {
|
|
|
2890
2915
|
}
|
|
2891
2916
|
}
|
|
2892
2917
|
//#endregion
|
|
2918
|
+
//#region src/plugin/hot-update-environment.ts
|
|
2919
|
+
async function handleHotUpdateEnvironmentHook(state, environment, options) {
|
|
2920
|
+
if (environment.name !== "client" && environment.name !== "browser") return options.modules;
|
|
2921
|
+
const server = {
|
|
2922
|
+
moduleGraph: environment.moduleGraph,
|
|
2923
|
+
ws: { send: environment.hot.send.bind(environment.hot) }
|
|
2924
|
+
};
|
|
2925
|
+
let recompileFailed = false;
|
|
2926
|
+
const modules = await handleHotUpdateHook(state, {
|
|
2927
|
+
...options,
|
|
2928
|
+
server
|
|
2929
|
+
}, {
|
|
2930
|
+
requireAcceptingClientModule: true,
|
|
2931
|
+
onRecompileError: () => {
|
|
2932
|
+
recompileFailed = true;
|
|
2933
|
+
}
|
|
2934
|
+
});
|
|
2935
|
+
if (recompileFailed) return;
|
|
2936
|
+
if (modules === void 0 && options.file.endsWith(".vue") && state.filter(options.file)) return [];
|
|
2937
|
+
return modules;
|
|
2938
|
+
}
|
|
2939
|
+
//#endregion
|
|
2893
2940
|
//#region src/plugin/compat.ts
|
|
2894
2941
|
function createVueCompatPlugin(state) {
|
|
2895
2942
|
let compilerSfc = null;
|
|
@@ -3529,6 +3576,23 @@ function unregisterBuild(context) {
|
|
|
3529
3576
|
if (resolvedConfig) unregisterConfig(resolvedConfig);
|
|
3530
3577
|
}
|
|
3531
3578
|
//#endregion
|
|
3579
|
+
//#region src/plugin/vue-feature-defines.ts
|
|
3580
|
+
function parseDefine(value) {
|
|
3581
|
+
try {
|
|
3582
|
+
return typeof value === "string" ? JSON.parse(value) : value;
|
|
3583
|
+
} catch {
|
|
3584
|
+
return value;
|
|
3585
|
+
}
|
|
3586
|
+
}
|
|
3587
|
+
/** Resolve Vue runtime defines with plugin-vue's precedence and defaults. */
|
|
3588
|
+
function resolveVueFeatureDefines(features, define, command) {
|
|
3589
|
+
return {
|
|
3590
|
+
__VUE_OPTIONS_API__: features?.optionsAPI ?? parseDefine(define?.__VUE_OPTIONS_API__) ?? true,
|
|
3591
|
+
__VUE_PROD_DEVTOOLS__: command === "serve",
|
|
3592
|
+
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: (features?.prodHydrationMismatchDetails || parseDefine(define?.__VUE_PROD_HYDRATION_MISMATCH_DETAILS__)) ?? false
|
|
3593
|
+
};
|
|
3594
|
+
}
|
|
3595
|
+
//#endregion
|
|
3532
3596
|
//#region src/plugin/index.ts
|
|
3533
3597
|
function aliasSortKey(find) {
|
|
3534
3598
|
return typeof find === "string" ? find.length : find.source.length;
|
|
@@ -3586,12 +3650,7 @@ function vize(options = {}) {
|
|
|
3586
3650
|
config(userConfig, env) {
|
|
3587
3651
|
patchCssModuleGenerateScopedName(userConfig);
|
|
3588
3652
|
return {
|
|
3589
|
-
|
|
3590
|
-
define: {
|
|
3591
|
-
__VUE_OPTIONS_API__: true,
|
|
3592
|
-
__VUE_PROD_DEVTOOLS__: env.command === "serve",
|
|
3593
|
-
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: false
|
|
3594
|
-
},
|
|
3653
|
+
define: resolveVueFeatureDefines(options.features, userConfig.define, env.command),
|
|
3595
3654
|
optimizeDeps: { exclude: ["virtual:vize-styles"] }
|
|
3596
3655
|
};
|
|
3597
3656
|
},
|
|
@@ -3705,6 +3764,9 @@ function vize(options = {}) {
|
|
|
3705
3764
|
async transform(code, id, transformOptions) {
|
|
3706
3765
|
return transformHook(state, code, id, transformOptions);
|
|
3707
3766
|
},
|
|
3767
|
+
async hotUpdate(options) {
|
|
3768
|
+
return handleHotUpdateEnvironmentHook(state, this.environment, options);
|
|
3769
|
+
},
|
|
3708
3770
|
async handleHotUpdate(ctx) {
|
|
3709
3771
|
return handleHotUpdateHook(state, ctx);
|
|
3710
3772
|
},
|
|
@@ -721,6 +721,22 @@ interface VizeInspectorOptions {
|
|
|
721
721
|
lintPlan?: VizeInspectorLintPlanProvider;
|
|
722
722
|
}
|
|
723
723
|
//#endregion
|
|
724
|
+
//#region src/vue-features.d.ts
|
|
725
|
+
/** Vue runtime feature flags shared with `@vitejs/plugin-vue`. */
|
|
726
|
+
interface VizeVueFeatures {
|
|
727
|
+
/**
|
|
728
|
+
* Set to `false` to allow Vue's Options API code to be tree-shaken from
|
|
729
|
+
* production bundles.
|
|
730
|
+
* @default true
|
|
731
|
+
*/
|
|
732
|
+
optionsAPI?: boolean;
|
|
733
|
+
/**
|
|
734
|
+
* Enable detailed hydration mismatch errors in production bundles.
|
|
735
|
+
* @default false
|
|
736
|
+
*/
|
|
737
|
+
prodHydrationMismatchDetails?: boolean;
|
|
738
|
+
}
|
|
739
|
+
//#endregion
|
|
724
740
|
//#region src/utils/module-output.d.ts
|
|
725
741
|
type ModuleOutputInfo = {
|
|
726
742
|
hasDefaultExport: boolean;
|
|
@@ -789,6 +805,8 @@ interface VizeOptions extends ExperimentalPluginOptions {
|
|
|
789
805
|
config?: UserConfigExport;
|
|
790
806
|
/** Development inspector integrations exposed through Vite's dev server. */
|
|
791
807
|
inspector?: VizeInspectorOptions;
|
|
808
|
+
/** Vue runtime feature flags compatible with `@vitejs/plugin-vue`. */
|
|
809
|
+
features?: VizeVueFeatures;
|
|
792
810
|
/**
|
|
793
811
|
* Vue major version for the host project.
|
|
794
812
|
*
|
|
@@ -968,4 +986,4 @@ interface CompiledModule {
|
|
|
968
986
|
moduleShape?: ModuleOutputInfo;
|
|
969
987
|
}
|
|
970
988
|
//#endregion
|
|
971
|
-
export { VizeVueVersion as a,
|
|
989
|
+
export { VizeVueVersion as a, VizeInspectorLintPlanRequest as c, LoadConfigOptions as d, ResolvedVizeConfig as f, VizeOptions as i, VizeInspectorOptions as l, VizeConfig as m, MacroArtifact as n, VizeVueFeatures as o, UserConfigExport as p, VizeCompatibilityOptions as r, VizeInspectorLintPlanProvider as s, CompiledModule 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.323.0",
|
|
4
4
|
"description": "High-performance native Vite plugin for Vue SFC compilation powered by Vize",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compiler",
|
|
@@ -45,10 +45,10 @@
|
|
|
45
45
|
"access": "public"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@vizejs/native": "0.
|
|
48
|
+
"@vizejs/native": "0.323.0",
|
|
49
49
|
"oxc-parser": "0.133.0",
|
|
50
50
|
"tinyglobby": "0.2.16",
|
|
51
|
-
"vize": "0.
|
|
51
|
+
"vize": "0.323.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@types/node": "25.9.2",
|