@module-federation/vite 1.23.3 → 1.23.5
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/lib/{dtsConstants-DSTzyKSG.js → dtsConstants-BQdFpgKb.js} +92 -12
- package/lib/index.js +519 -215
- package/lib/{pluginDts-CVyHPAEq.js → pluginDts-DShMdjzR.js} +1 -1
- package/lib/{sharedKeyMatcher-Od_nYxJA.js → sharedKeyMatcher-CHp4QRNq.js} +1 -1
- package/lib/{ssrEntryLoader-DjZj-5Lw.js → ssrEntryLoader-CHdWk8Yg.js} +31 -17
- package/lib/{ssrVmStrategy-Dk5xXVvR.js → ssrVmStrategy-BkyvcG4s.js} +2 -2
- package/lib/utils/ssrEntryLoader.d.ts +2 -1
- package/lib/utils/ssrEntryLoader.js +2 -2
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { l as normalizePathForImport, n as mfError, t as createModuleFederationError } from "./logger-DOwfTlw5.js";
|
|
2
|
-
import {
|
|
2
|
+
import { _ as resolveImportPath, d as hasPackageDependency } from "./dtsConstants-BQdFpgKb.js";
|
|
3
3
|
import fs from "fs";
|
|
4
4
|
import * as path$1 from "node:path";
|
|
5
5
|
import { normalizeOptions } from "@module-federation/sdk";
|
|
@@ -218,4 +218,4 @@ function getSharedKeyMatcher(shared) {
|
|
|
218
218
|
return matcher;
|
|
219
219
|
}
|
|
220
220
|
//#endregion
|
|
221
|
-
export {
|
|
221
|
+
export { removeTrailingSlash as _, matchesSharedSource as a, stripViteFsPrefix as b, filterId as c, getNodeModulesSuffix as d, isAssetLikeImport as f, normalizeNodeModulePath as g, isViteOptimizableEntry as h, invalidateSharedKeyMatcher as i, getBasePath as l, isNuxtClientBase as m, getSharedRequest as n, VITE_FS_PREFIX as o, isNodeModulePath as p, getSharedRuntimeKey as r, ensureTrailingSlash as s, findSharedKey as t, getCommonSharedSubpaths as u, resolvePublicPath as v, stripQueryAndHash as y };
|
|
@@ -146,7 +146,23 @@ async function nodeImport(id) {
|
|
|
146
146
|
const isNodeServer = () => {
|
|
147
147
|
return import.meta.env?.SSR ?? typeof globalThis.process?.versions?.node === "string";
|
|
148
148
|
};
|
|
149
|
-
const
|
|
149
|
+
const SSR_ENTRY_LOADER_STATE_KEY = Symbol.for("module-federation.vite.ssrEntryLoader.state");
|
|
150
|
+
function getLoaderState() {
|
|
151
|
+
const holder = globalThis;
|
|
152
|
+
const state = holder[SSR_ENTRY_LOADER_STATE_KEY] ??= {};
|
|
153
|
+
state.runnerCache ??= /* @__PURE__ */ new Map();
|
|
154
|
+
state.unversionedGenerations ??= /* @__PURE__ */ new Map();
|
|
155
|
+
state.unversionedGlobalGeneration ??= 0;
|
|
156
|
+
state.ssrEntryCache ??= /* @__PURE__ */ new Map();
|
|
157
|
+
state.manifestFetchCache ??= /* @__PURE__ */ new Map();
|
|
158
|
+
state.tempFileCache ??= /* @__PURE__ */ new Map();
|
|
159
|
+
state.tempFilePathCache ??= /* @__PURE__ */ new Map();
|
|
160
|
+
state.tempFileRecords ??= /* @__PURE__ */ new Map();
|
|
161
|
+
state.scheduledTempFileCleanup ??= /* @__PURE__ */ new Set();
|
|
162
|
+
return state;
|
|
163
|
+
}
|
|
164
|
+
const loaderState = getLoaderState();
|
|
165
|
+
const runnerCache = loaderState.runnerCache;
|
|
150
166
|
function getSortedRecordEntries(record) {
|
|
151
167
|
return Object.entries(record).sort(([left], [right]) => left.localeCompare(right));
|
|
152
168
|
}
|
|
@@ -271,10 +287,9 @@ function parseRunnerInvokeResult(data) {
|
|
|
271
287
|
* advance a process-local generation so the next import is fresh.
|
|
272
288
|
*/
|
|
273
289
|
const UNVERSIONED = "unversioned";
|
|
274
|
-
const unversionedGenerations =
|
|
275
|
-
let unversionedGlobalGeneration = 0;
|
|
290
|
+
const unversionedGenerations = loaderState.unversionedGenerations;
|
|
276
291
|
function getUnversionedVersionKey(remoteEntryUrl) {
|
|
277
|
-
return `${UNVERSIONED}-${unversionedGlobalGeneration}-${unversionedGenerations.get(remoteEntryUrl) ?? 0}`;
|
|
292
|
+
return `${UNVERSIONED}-${loaderState.unversionedGlobalGeneration}-${unversionedGenerations.get(remoteEntryUrl) ?? 0}`;
|
|
278
293
|
}
|
|
279
294
|
function bumpUnversionedGeneration(remoteEntryUrl) {
|
|
280
295
|
unversionedGenerations.set(remoteEntryUrl, (unversionedGenerations.get(remoteEntryUrl) ?? 0) + 1);
|
|
@@ -292,8 +307,8 @@ function computeManifestVersionKey(manifest) {
|
|
|
292
307
|
const contentHash = hashString(JSON.stringify(manifest));
|
|
293
308
|
return buildVersion ? `${buildVersion}-${contentHash}` : contentHash;
|
|
294
309
|
}
|
|
295
|
-
const ssrEntryCache =
|
|
296
|
-
const manifestFetchCache =
|
|
310
|
+
const ssrEntryCache = loaderState.ssrEntryCache;
|
|
311
|
+
const manifestFetchCache = loaderState.manifestFetchCache;
|
|
297
312
|
function makeUrlCacheKey(url, fetchTimeoutMs, fetchMaxBytes) {
|
|
298
313
|
return `${fetchTimeoutMs}::${fetchMaxBytes}::${url}`;
|
|
299
314
|
}
|
|
@@ -514,8 +529,8 @@ function invalidateRemoteCaches(remoteEntryUrl) {
|
|
|
514
529
|
* static import cycle between the two SSR strategies.
|
|
515
530
|
*/
|
|
516
531
|
function scheduleVmCacheCleanup(remoteEntryUrl) {
|
|
517
|
-
if (!vmStrategyModulePromise) return;
|
|
518
|
-
vmStrategyModulePromise.then(({ clearVmStrategyCaches }) => clearVmStrategyCaches(remoteEntryUrl)).catch(() => {});
|
|
532
|
+
if (!loaderState.vmStrategyModulePromise) return;
|
|
533
|
+
loaderState.vmStrategyModulePromise.then(({ clearVmStrategyCaches }) => clearVmStrategyCaches(remoteEntryUrl)).catch(() => {});
|
|
519
534
|
}
|
|
520
535
|
/**
|
|
521
536
|
* A dev-mode ModuleRunner is created per origin (one Vite dev server) and is
|
|
@@ -575,7 +590,7 @@ function revalidate(remoteEntryUrl) {
|
|
|
575
590
|
for (const key of manifestFetchCache.keys()) if (key.endsWith(`::${manifestUrl}`)) manifestFetchCache.delete(key);
|
|
576
591
|
invalidateRemoteCaches(remoteEntryUrl);
|
|
577
592
|
} else {
|
|
578
|
-
unversionedGlobalGeneration += 1;
|
|
593
|
+
loaderState.unversionedGlobalGeneration += 1;
|
|
579
594
|
ssrEntryCache.clear();
|
|
580
595
|
manifestFetchCache.clear();
|
|
581
596
|
invalidateAllRemoteCaches();
|
|
@@ -585,11 +600,11 @@ function revalidate(remoteEntryUrl) {
|
|
|
585
600
|
instance?.moduleCache?.clear?.();
|
|
586
601
|
} catch {}
|
|
587
602
|
}
|
|
588
|
-
const tempFileCache =
|
|
589
|
-
const tempFilePathCache =
|
|
603
|
+
const tempFileCache = loaderState.tempFileCache;
|
|
604
|
+
const tempFilePathCache = loaderState.tempFilePathCache;
|
|
590
605
|
const TEMP_FILE_CLEANUP_DELAY_MS = 3e4;
|
|
591
|
-
const tempFileRecords =
|
|
592
|
-
const scheduledTempFileCleanup =
|
|
606
|
+
const tempFileRecords = loaderState.tempFileRecords;
|
|
607
|
+
const scheduledTempFileCleanup = loaderState.scheduledTempFileCleanup;
|
|
593
608
|
function scheduleTempFileCleanup(records) {
|
|
594
609
|
for (const record of records) {
|
|
595
610
|
if (scheduledTempFileCleanup.has(record.cacheKey)) continue;
|
|
@@ -832,10 +847,9 @@ async function importTempModule(filePath, versionKey) {
|
|
|
832
847
|
);
|
|
833
848
|
}
|
|
834
849
|
let warnedVmUnavailable = false;
|
|
835
|
-
let vmStrategyModulePromise;
|
|
836
850
|
function getVmStrategyModule() {
|
|
837
|
-
if (!vmStrategyModulePromise) vmStrategyModulePromise = import("./ssrVmStrategy-
|
|
838
|
-
return vmStrategyModulePromise;
|
|
851
|
+
if (!loaderState.vmStrategyModulePromise) loaderState.vmStrategyModulePromise = import("./ssrVmStrategy-BkyvcG4s.js");
|
|
852
|
+
return loaderState.vmStrategyModulePromise;
|
|
839
853
|
}
|
|
840
854
|
/**
|
|
841
855
|
* Non-HTTP failures keep falling back (to temp-file after vm, to the federation
|
|
@@ -954,4 +968,4 @@ function ssrEntryLoaderPlugin(options = {}) {
|
|
|
954
968
|
};
|
|
955
969
|
}
|
|
956
970
|
//#endregion
|
|
957
|
-
export {
|
|
971
|
+
export { ssrEntryLoaderPlugin as a, fetchWithTimeout as c, revalidate as i, readResponseTextBounded as l, SsrEntryHttpError as n, DEFAULT_SSR_FETCH_MAX_BYTES as o, neutralizeBrowserPreloadHelpers as r, DEFAULT_SSR_FETCH_TIMEOUT_MS as s, SSR_ENTRY_LOADER_STATE_KEY as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as findSharedKey } from "./sharedKeyMatcher-
|
|
2
|
-
import { c as
|
|
1
|
+
import { t as findSharedKey } from "./sharedKeyMatcher-CHp4QRNq.js";
|
|
2
|
+
import { c as fetchWithTimeout, l as readResponseTextBounded, n as SsrEntryHttpError, r as neutralizeBrowserPreloadHelpers } from "./ssrEntryLoader-CHdWk8Yg.js";
|
|
3
3
|
//#region src/utils/ssrVmStrategy.ts
|
|
4
4
|
/**
|
|
5
5
|
* vm.SourceTextModule strategy for loading remote SSR entries.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { i as SsrEntryLoaderConfig } from "../normalizeModuleFederationOptions-DNUlv-AL.js";
|
|
2
2
|
//#region src/utils/ssrEntryLoader.d.ts
|
|
3
|
+
declare const SSR_ENTRY_LOADER_STATE_KEY: unique symbol;
|
|
3
4
|
interface RemoteInfo {
|
|
4
5
|
name: string;
|
|
5
6
|
entry: string;
|
|
@@ -64,4 +65,4 @@ declare function ssrEntryLoaderPlugin(options?: SsrEntryLoaderOptions): {
|
|
|
64
65
|
} | undefined>;
|
|
65
66
|
};
|
|
66
67
|
//#endregion
|
|
67
|
-
export { SsrEntryHttpError, ssrEntryLoaderPlugin as default, neutralizeBrowserPreloadHelpers, revalidate };
|
|
68
|
+
export { SSR_ENTRY_LOADER_STATE_KEY, SsrEntryHttpError, ssrEntryLoaderPlugin as default, neutralizeBrowserPreloadHelpers, revalidate };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { SsrEntryHttpError, ssrEntryLoaderPlugin as default, neutralizeBrowserPreloadHelpers, revalidate };
|
|
1
|
+
import { a as ssrEntryLoaderPlugin, i as revalidate, n as SsrEntryHttpError, r as neutralizeBrowserPreloadHelpers, t as SSR_ENTRY_LOADER_STATE_KEY } from "../ssrEntryLoader-CHdWk8Yg.js";
|
|
2
|
+
export { SSR_ENTRY_LOADER_STATE_KEY, SsrEntryHttpError, ssrEntryLoaderPlugin as default, neutralizeBrowserPreloadHelpers, revalidate };
|