@module-federation/vite 1.21.6 → 1.22.1
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 +25 -4
- package/lib/{dtsConstants-BsaLBaaK.js → dtsConstants-dDsHZFC1.js} +40 -10
- package/lib/index.d.ts +25 -3
- package/lib/index.js +1130 -684
- package/lib/{pluginDts-4sHIZPIi.js → pluginDts-CQ088qGF.js} +1 -1
- package/lib/{sharedKeyMatcher-DiUzRVH1.js → sharedKeyMatcher-BRzBCbuR.js} +19 -25
- package/lib/{ssrEntryLoader-BqzV2t-n.js → ssrEntryLoader-BUXUQi0P.js} +11 -7
- package/lib/{ssrVmStrategy-CkmYR5_u.js → ssrVmStrategy-Ud06y3Xf.js} +2 -2
- package/lib/utils/ssrEntryLoader.js +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as normalizePathForImport } from "./buildPaths-BoaQTkxt.js";
|
|
2
|
-
import {
|
|
2
|
+
import { h as resolveImportPath, l as hasPackageDependency, v as createModuleFederationError, y as mfError } from "./dtsConstants-dDsHZFC1.js";
|
|
3
3
|
import fs from "fs";
|
|
4
4
|
import * as path$1 from "node:path";
|
|
5
5
|
import os from "os";
|
|
@@ -82,9 +82,25 @@ function getBasePath(base) {
|
|
|
82
82
|
function isNuxtClientBase(base) {
|
|
83
83
|
return getBasePath(base).endsWith("/_nuxt");
|
|
84
84
|
}
|
|
85
|
+
const VITE_FS_PREFIX = "/@fs/";
|
|
86
|
+
function stripQueryAndHash(id) {
|
|
87
|
+
const queryIndex = id.indexOf("?");
|
|
88
|
+
const hashIndex = id.indexOf("#");
|
|
89
|
+
const endIndex = queryIndex === -1 ? hashIndex : hashIndex === -1 ? queryIndex : Math.min(queryIndex, hashIndex);
|
|
90
|
+
return endIndex === -1 ? id : id.slice(0, endIndex);
|
|
91
|
+
}
|
|
92
|
+
function stripViteFsPrefix(id) {
|
|
93
|
+
if (!id.startsWith("/@fs/")) return id;
|
|
94
|
+
const file = id.slice(5);
|
|
95
|
+
return file.startsWith("/") || /^[a-z]:\//i.test(file) ? file : `/${file}`;
|
|
96
|
+
}
|
|
85
97
|
function normalizeNodeModulePath(source) {
|
|
86
|
-
|
|
87
|
-
|
|
98
|
+
return stripQueryAndHash(source).replace(/\\/g, "/");
|
|
99
|
+
}
|
|
100
|
+
function getNodeModulesSuffix(source) {
|
|
101
|
+
const normalized = normalizeNodeModulePath(source);
|
|
102
|
+
const index = normalized.lastIndexOf("/node_modules/");
|
|
103
|
+
return index === -1 ? void 0 : normalized.slice(index + 14);
|
|
88
104
|
}
|
|
89
105
|
function isNodeModulePath(source) {
|
|
90
106
|
return source.includes("/node_modules/") || source.includes("\\node_modules\\");
|
|
@@ -92,31 +108,9 @@ function isNodeModulePath(source) {
|
|
|
92
108
|
function filterId(id) {
|
|
93
109
|
return typeof id === "string" && !id.includes("\0");
|
|
94
110
|
}
|
|
95
|
-
const NODE_MODULE_FILE_EXT_RE = /^\.[cm]?[jt]sx?$/i;
|
|
96
|
-
function matchesNodeModuleCandidate(normalized, candidate) {
|
|
97
|
-
const marker = `/node_modules/${candidate}`;
|
|
98
|
-
let from = 0;
|
|
99
|
-
while (from < normalized.length) {
|
|
100
|
-
const index = normalized.indexOf(marker, from);
|
|
101
|
-
if (index === -1) return false;
|
|
102
|
-
const after = normalized.slice(index + marker.length);
|
|
103
|
-
const boundary = after.search(/[?#]/);
|
|
104
|
-
const afterPath = boundary === -1 ? after : after.slice(0, boundary);
|
|
105
|
-
if (afterPath === "" || afterPath.startsWith("/") || NODE_MODULE_FILE_EXT_RE.test(afterPath)) return true;
|
|
106
|
-
from = index + 1;
|
|
107
|
-
}
|
|
108
|
-
return false;
|
|
109
|
-
}
|
|
110
|
-
function getMatchingNodeModuleSubpath(source, candidates) {
|
|
111
|
-
const normalized = normalizeNodeModulePath(source);
|
|
112
|
-
return [...candidates].sort((a, b) => b.length - a.length).find((candidate) => matchesNodeModuleCandidate(normalized, candidate));
|
|
113
|
-
}
|
|
114
111
|
function getCommonSharedSubpaths(sharedKey) {
|
|
115
112
|
return COMMON_SHARED_SUBPATHS[removeTrailingSlash(sharedKey)] || [];
|
|
116
113
|
}
|
|
117
|
-
function getCommonSharedSubpathFromNodeModulePath(source, sharedKey) {
|
|
118
|
-
return getMatchingNodeModuleSubpath(source, getCommonSharedSubpaths(removeTrailingSlash(sharedKey)));
|
|
119
|
-
}
|
|
120
114
|
/**
|
|
121
115
|
* Resolves the public path for remote entries
|
|
122
116
|
* @param options - Module Federation options
|
|
@@ -195,4 +189,4 @@ function getSharedKeyMatcher(shared) {
|
|
|
195
189
|
return matcher;
|
|
196
190
|
}
|
|
197
191
|
//#endregion
|
|
198
|
-
export {
|
|
192
|
+
export { stripViteFsPrefix as _, ensureTrailingSlash as a, getCommonSharedSubpaths as c, isNodeModulePath as d, isNuxtClientBase as f, stripQueryAndHash as g, resolvePublicPath as h, VITE_FS_PREFIX as i, getNodeModulesSuffix as l, normalizeNodeModulePath as m, invalidateSharedKeyMatcher as n, filterId as o, isViteOptimizableEntry as p, matchesSharedSource as r, getBasePath as s, findSharedKey as t, isAssetLikeImport as u };
|
|
@@ -470,7 +470,10 @@ async function getSSREntry(remoteEntryUrl, maxAgeMs, fetchTimeoutMs, fetchMaxByt
|
|
|
470
470
|
manifestFetchCache.delete(makeUrlCacheKey(getManifestUrl(remoteEntryUrl), fetchTimeoutMs, fetchMaxBytes));
|
|
471
471
|
const record = setSsrEntryCache(remoteEntryUrl, fetchTimeoutMs, fetchMaxBytes);
|
|
472
472
|
const next = await record.promise.catch(() => null);
|
|
473
|
-
if (previous && next && previous.versionKey !== next.versionKey)
|
|
473
|
+
if (previous && next && previous.versionKey !== next.versionKey) {
|
|
474
|
+
dropRemoteCaches(remoteEntryUrl);
|
|
475
|
+
await clearRunnerCaches(remoteEntryUrl);
|
|
476
|
+
}
|
|
474
477
|
return record.promise;
|
|
475
478
|
}
|
|
476
479
|
/**
|
|
@@ -490,17 +493,18 @@ function dropRemoteCaches(remoteEntryUrl) {
|
|
|
490
493
|
tempFilePathCache.delete(key);
|
|
491
494
|
}
|
|
492
495
|
}
|
|
493
|
-
function clearRunnerCaches(remoteEntryUrl) {
|
|
496
|
+
async function clearRunnerCaches(remoteEntryUrl) {
|
|
494
497
|
let remoteOrigin;
|
|
495
498
|
if (remoteEntryUrl) try {
|
|
496
499
|
remoteOrigin = new URL(remoteEntryUrl).origin;
|
|
497
500
|
} catch {
|
|
498
501
|
return;
|
|
499
502
|
}
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
503
|
+
await Promise.all([...runnerCache.values()].filter((cached) => !remoteOrigin || cached.remoteOrigin === remoteOrigin).map(async (cached) => {
|
|
504
|
+
try {
|
|
505
|
+
(await cached.promise)?.clearCache?.();
|
|
506
|
+
} catch {}
|
|
507
|
+
}));
|
|
504
508
|
}
|
|
505
509
|
/**
|
|
506
510
|
* Drop the loader's caches so the next `loadEntry` re-resolves and re-fetches
|
|
@@ -662,7 +666,7 @@ async function importTempModule(filePath, versionKey) {
|
|
|
662
666
|
}
|
|
663
667
|
let warnedVmUnavailable = false;
|
|
664
668
|
async function tryVmStrategy(ssrEntry, options) {
|
|
665
|
-
const { loadViaVmStrategy, isVmStrategyAvailable } = await import("./ssrVmStrategy-
|
|
669
|
+
const { loadViaVmStrategy, isVmStrategyAvailable } = await import("./ssrVmStrategy-Ud06y3Xf.js");
|
|
666
670
|
if (!await isVmStrategyAvailable()) {
|
|
667
671
|
if (!warnedVmUnavailable) {
|
|
668
672
|
warnedVmUnavailable = true;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as findSharedKey } from "./sharedKeyMatcher-
|
|
2
|
-
import { c as readResponseTextBounded, n as neutralizeBrowserPreloadHelpers, s as fetchWithTimeout, t as SsrEntryHttpError } from "./ssrEntryLoader-
|
|
1
|
+
import { t as findSharedKey } from "./sharedKeyMatcher-BRzBCbuR.js";
|
|
2
|
+
import { c as readResponseTextBounded, n as neutralizeBrowserPreloadHelpers, s as fetchWithTimeout, t as SsrEntryHttpError } from "./ssrEntryLoader-BUXUQi0P.js";
|
|
3
3
|
//#region src/utils/ssrVmStrategy.ts
|
|
4
4
|
/**
|
|
5
5
|
* vm.SourceTextModule strategy for loading remote SSR entries.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as ssrEntryLoaderPlugin, n as neutralizeBrowserPreloadHelpers, r as revalidate, t as SsrEntryHttpError } from "../ssrEntryLoader-
|
|
1
|
+
import { i as ssrEntryLoaderPlugin, n as neutralizeBrowserPreloadHelpers, r as revalidate, t as SsrEntryHttpError } from "../ssrEntryLoader-BUXUQi0P.js";
|
|
2
2
|
export { SsrEntryHttpError, ssrEntryLoaderPlugin as default, neutralizeBrowserPreloadHelpers, revalidate };
|