@vizejs/vite-plugin 0.182.0 → 0.184.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 +34 -8
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -448,6 +448,7 @@ function clearBuildCaches(state) {
|
|
|
448
448
|
state.collectedCss.clear();
|
|
449
449
|
state.precompileMetadata.clear();
|
|
450
450
|
state.pendingHmrUpdateTypes.clear();
|
|
451
|
+
state.viteResolveCache?.clear();
|
|
451
452
|
}
|
|
452
453
|
/**
|
|
453
454
|
* Pre-compile all Vue files matching scan patterns.
|
|
@@ -561,6 +562,30 @@ const VUE_PEER_RUNTIME_ESM_ENTRIES = new Map([["vue-router", [
|
|
|
561
562
|
"index.mjs",
|
|
562
563
|
"index.js"
|
|
563
564
|
]]]);
|
|
565
|
+
function getViteResolveCache(state) {
|
|
566
|
+
return state.viteResolveCache ??= /* @__PURE__ */ new Map();
|
|
567
|
+
}
|
|
568
|
+
function createViteResolveCacheKey(id, importer, options, environmentName) {
|
|
569
|
+
return JSON.stringify([
|
|
570
|
+
environmentName ?? null,
|
|
571
|
+
id,
|
|
572
|
+
importer ?? null,
|
|
573
|
+
options?.skipSelf ?? false
|
|
574
|
+
]);
|
|
575
|
+
}
|
|
576
|
+
function resolveWithVite(ctx, state, id, importer, options) {
|
|
577
|
+
if (state.server !== null) return ctx.resolve(id, importer, options);
|
|
578
|
+
const cache = getViteResolveCache(state);
|
|
579
|
+
const key = createViteResolveCacheKey(id, importer, options, ctx.environment?.name);
|
|
580
|
+
const cached = cache.get(key);
|
|
581
|
+
if (cached) return cached;
|
|
582
|
+
const pending = ctx.resolve(id, importer, options).catch((error) => {
|
|
583
|
+
cache.delete(key);
|
|
584
|
+
throw error;
|
|
585
|
+
});
|
|
586
|
+
cache.set(key, pending);
|
|
587
|
+
return pending;
|
|
588
|
+
}
|
|
564
589
|
function resolveAliasRequest(state, id) {
|
|
565
590
|
return resolveViteAliasRequest(id, nativeCssAliasRules(state));
|
|
566
591
|
}
|
|
@@ -854,7 +879,7 @@ async function resolveProjectVueRuntime(ctx, state, id, importer, isSsrRequest)
|
|
|
854
879
|
return pnpmHoistedEntry;
|
|
855
880
|
}
|
|
856
881
|
try {
|
|
857
|
-
const resolved = await ctx
|
|
882
|
+
const resolved = await resolveWithVite(ctx, state, id, viteImporter, { skipSelf: true });
|
|
858
883
|
if (resolved && !isOptimizedVueDependency(resolved.id)) {
|
|
859
884
|
const projectLocalEntry = resolveProjectLocalPnpmVueRuntime(state, resolved.id);
|
|
860
885
|
if (projectLocalEntry) {
|
|
@@ -904,8 +929,7 @@ function cleanVueSfcImporter(importer, request) {
|
|
|
904
929
|
}
|
|
905
930
|
async function resolveAliasedVueImport(ctx, state, id, importer, isSsrRequest, handleNodeModules, querySuffix, preserveQueryAsPath, isDependencyScan) {
|
|
906
931
|
if (path.isAbsolute(id)) return null;
|
|
907
|
-
const
|
|
908
|
-
const viteResolved = await ctx.resolve(id, viteImporter, { skipSelf: true });
|
|
932
|
+
const viteResolved = await resolveWithVite(ctx, state, id, normalizeViteRequireBase(importer) ?? importer, { skipSelf: true });
|
|
909
933
|
const realPath = viteResolved ? normalizeResolvedVuePath(viteResolved.id) : null;
|
|
910
934
|
if (!realPath) return null;
|
|
911
935
|
const isResolvedNodeModules = realPath.includes("node_modules");
|
|
@@ -963,7 +987,7 @@ async function resolveIdHook(ctx, state, id, importer, options) {
|
|
|
963
987
|
let realPath = id.slice(5);
|
|
964
988
|
if (realPath.endsWith(".ts")) realPath = realPath.slice(0, -3);
|
|
965
989
|
state.logger.log(`resolveId: redirecting stale vize: ID to ${realPath}`);
|
|
966
|
-
const resolved = await ctx
|
|
990
|
+
const resolved = await resolveWithVite(ctx, state, realPath, importer, { skipSelf: true });
|
|
967
991
|
const normalizedFsId = resolved ? classifyVitePluginRequest(resolved.id).normalizedFsId : null;
|
|
968
992
|
if (resolved && isBuild && normalizedFsId) return {
|
|
969
993
|
...resolved,
|
|
@@ -995,7 +1019,7 @@ async function resolveIdHook(ctx, state, id, importer, options) {
|
|
|
995
1019
|
const cleanImporter = isMacroImporter ? importerRequest?.strippedVirtualPath ?? "" : isVizeVirtualImporter ? importerRequest?.vizeVirtualPath ?? "" : cleanVueSfcImporter(importer, importerRequest);
|
|
996
1020
|
state.logger.log(`resolveId from virtual: id=${id}, cleanImporter=${cleanImporter}`);
|
|
997
1021
|
if (id.startsWith("#")) try {
|
|
998
|
-
return await ctx
|
|
1022
|
+
return await resolveWithVite(ctx, state, id, cleanImporter, { skipSelf: true });
|
|
999
1023
|
} catch {
|
|
1000
1024
|
return null;
|
|
1001
1025
|
}
|
|
@@ -1032,7 +1056,7 @@ async function resolveIdHook(ctx, state, id, importer, options) {
|
|
|
1032
1056
|
}
|
|
1033
1057
|
}
|
|
1034
1058
|
try {
|
|
1035
|
-
const resolved = await ctx
|
|
1059
|
+
const resolved = await resolveWithVite(ctx, state, id, cleanImporter, { skipSelf: true });
|
|
1036
1060
|
if (resolved) {
|
|
1037
1061
|
state.logger.log(`resolveId: resolved bare ${id} to ${resolved.id} via Vite resolver`);
|
|
1038
1062
|
const normalizedFsId = classifyVitePluginRequest(resolved.id).normalizedFsId;
|
|
@@ -1109,7 +1133,7 @@ async function resolveIdHook(ctx, state, id, importer, options) {
|
|
|
1109
1133
|
}
|
|
1110
1134
|
if (aliasRequest && aliasRequest !== id && !isViteBareSpecifier(aliasRequest)) {
|
|
1111
1135
|
try {
|
|
1112
|
-
const resolved = await ctx
|
|
1136
|
+
const resolved = await resolveWithVite(ctx, state, aliasRequest, cleanImporter, { skipSelf: true });
|
|
1113
1137
|
if (resolved) {
|
|
1114
1138
|
state.logger.log(`resolveId: resolved aliased bare ${id} to ${resolved.id} via Vite resolver`);
|
|
1115
1139
|
const normalizedFsId = classifyVitePluginRequest(resolved.id).normalizedFsId;
|
|
@@ -1137,7 +1161,7 @@ async function resolveIdHook(ctx, state, id, importer, options) {
|
|
|
1137
1161
|
return null;
|
|
1138
1162
|
}
|
|
1139
1163
|
try {
|
|
1140
|
-
const resolved = await ctx
|
|
1164
|
+
const resolved = await resolveWithVite(ctx, state, id, cleanImporter, { skipSelf: true });
|
|
1141
1165
|
if (resolved) {
|
|
1142
1166
|
state.logger.log(`resolveId: resolved ${id} to ${resolved.id} via Vite resolver`);
|
|
1143
1167
|
const normalizedFsId = classifyVitePluginRequest(resolved.id).normalizedFsId;
|
|
@@ -1812,6 +1836,7 @@ function vize(options = {}) {
|
|
|
1812
1836
|
collectedCss: /* @__PURE__ */ new Map(),
|
|
1813
1837
|
precompileMetadata: /* @__PURE__ */ new Map(),
|
|
1814
1838
|
pendingHmrUpdateTypes: /* @__PURE__ */ new Map(),
|
|
1839
|
+
viteResolveCache: /* @__PURE__ */ new Map(),
|
|
1815
1840
|
isProduction: false,
|
|
1816
1841
|
root: "",
|
|
1817
1842
|
clientViteBase: "/",
|
|
@@ -1954,6 +1979,7 @@ function vize(options = {}) {
|
|
|
1954
1979
|
installVirtualAssetMiddleware(devServer, state);
|
|
1955
1980
|
},
|
|
1956
1981
|
async buildStart() {
|
|
1982
|
+
state.viteResolveCache?.clear();
|
|
1957
1983
|
if (!state.scanPatterns || state.scanPatterns.length === 0) return;
|
|
1958
1984
|
await compileAll({
|
|
1959
1985
|
...state,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vizejs/vite-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.184.0",
|
|
4
4
|
"description": "High-performance native Vite plugin for Vue SFC compilation powered by Vize",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compiler",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@vizejs/native": "0.
|
|
42
|
+
"@vizejs/native": "0.184.0",
|
|
43
43
|
"tinyglobby": "0.2.16",
|
|
44
|
-
"vize": "0.
|
|
44
|
+
"vize": "0.184.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/node": "25.7.0",
|