@module-federation/vite 1.23.6 → 1.23.8
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 +6 -0
- package/lib/{dtsConstants-CDuC8Bb7.js → dtsConstants-286VtFnC.js} +19 -33
- package/lib/index.js +749 -566
- package/lib/{pluginDts-rZMRTCTz.js → pluginDts-DvTJxjaE.js} +1 -1
- package/lib/{ssrEntryLoader-Bh2Tq1cZ.js → ssrEntryLoader-DKpOrW8D.js} +69 -5
- package/lib/{ssrVmStrategy-BCaiSEbA.js → ssrVmStrategy-D1cSKUV-.js} +4 -7
- package/lib/utils/ssrEntryLoader.d.ts +7 -1
- package/lib/utils/ssrEntryLoader.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -253,6 +253,8 @@ export default defineConfig({
|
|
|
253
253
|
|
|
254
254
|
The host app configuration specifies its name, the filename of its exposed remote entry remoteEntry.js, and importantly, the configuration of the remote application to load.
|
|
255
255
|
Object remotes that omit `type` retain the legacy `"var"` default and emit a warning. Use `type: "module"` for Vite ESM remotes. Use `type: "var"` explicitly only for global-format remotes, such as Webpack/Rspack remotes or a Vite remote's `varFilename` output.
|
|
256
|
+
|
|
257
|
+
The optional `varFilename` wrapper registers the container on `globalThis[name]` and throws if that name already belongs to another global (e.g. `window`, `self`, `location`), even when its value is `0`, `false`, `""` or `null` (e.g. `length`). Use a distinct name or an ESM remote (`type: "module"`). Loading the wrapper again keeps the existing container.
|
|
256
258
|
You can specify the place the host initialization file is injected with the **hostInitInjectLocation** option, which is described in the example code above.
|
|
257
259
|
The **moduleParseTimeout** option allows you to configure the maximum time to wait for module parsing during the build process.
|
|
258
260
|
The **moduleParseIdleTimeout** option is an alternative that resets the timer on every parsed module. It only fires when there has been no module activity for the configured duration, making it suitable for large codebases where the total build time exceeds the fixed timeout.
|
|
@@ -267,6 +269,10 @@ loading stays lazy, including with `loaded-first`. Apps without remotes receive
|
|
|
267
269
|
SSR host bootstrap. Cold development SSR follows the existing Vite 8+ support gate;
|
|
268
270
|
independent SSR builds are supported on Vite 5–8.
|
|
269
271
|
|
|
272
|
+
A remote the application registers at runtime with `init()` or `registerRemotes()`
|
|
273
|
+
under a configured remote's name or alias replaces that remote for `loadRemote()`
|
|
274
|
+
calls. Static `import "remote/expose"` statements keep using the configured entry.
|
|
275
|
+
|
|
270
276
|
Dependencies externalized by Vite keep Node's own runtime resolution. Their runtime
|
|
271
277
|
imports are not bound to the application's instance by this bootstrap.
|
|
272
278
|
Include runtime-consuming dependencies in Vite's `ssr.noExternal` when they need
|
|
@@ -279,35 +279,17 @@ function getPackageNameFromNodeModulePath(source) {
|
|
|
279
279
|
if (parts[0].startsWith("@")) return parts[1] ? `${parts[0]}/${parts[1]}` : void 0;
|
|
280
280
|
return parts[0];
|
|
281
281
|
}
|
|
282
|
-
function
|
|
283
|
-
const
|
|
284
|
-
const id =
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
key: `${scope}:${id}`
|
|
289
|
-
};
|
|
282
|
+
function createSharedCacheDescriptor(pkg, singleton, version, scope) {
|
|
283
|
+
const scopeName = (Array.isArray(scope) ? scope[0] : scope) || "default";
|
|
284
|
+
const id = singleton || !version ? pkg : pkg + "@" + version;
|
|
285
|
+
const descriptor = { canonical: scopeName + ":" + id };
|
|
286
|
+
if (scopeName === "default") descriptor.aliases = [id];
|
|
287
|
+
return descriptor;
|
|
290
288
|
}
|
|
291
289
|
function getSharedCacheDescriptor(pkg, shareItem) {
|
|
292
|
-
|
|
293
|
-
pkg: shareItem.shareConfig.request !== void 0 || shareItem.shareConfig.shareKey !== void 0 ? getSharedRuntimeKey(pkg, shareItem) : pkg,
|
|
294
|
-
singleton: shareItem.shareConfig.singleton,
|
|
295
|
-
version: shareItem.version,
|
|
296
|
-
scope: shareItem.scope
|
|
297
|
-
});
|
|
298
|
-
return {
|
|
299
|
-
canonical: parts.key,
|
|
300
|
-
...parts.scope === "default" ? { aliases: [parts.id] } : {}
|
|
301
|
-
};
|
|
290
|
+
return createSharedCacheDescriptor(shareItem.shareConfig.request !== void 0 || shareItem.shareConfig.shareKey !== void 0 ? getSharedRuntimeKey(pkg, shareItem) : pkg, shareItem.shareConfig.singleton, shareItem.version, shareItem.scope);
|
|
302
291
|
}
|
|
303
|
-
const sharedCacheHelperCode = `const __mfGetSharedCacheDescriptor = (
|
|
304
|
-
const normalizedScope = Array.isArray(scope) ? scope[0] : scope;
|
|
305
|
-
const scopeName = normalizedScope || "default";
|
|
306
|
-
const id = singleton || !version ? pkg : pkg + "@" + version;
|
|
307
|
-
const descriptor = { canonical: scopeName + ":" + id };
|
|
308
|
-
if (scopeName === "default") descriptor.aliases = [id];
|
|
309
|
-
return descriptor;
|
|
310
|
-
};
|
|
292
|
+
const sharedCacheHelperCode = `const __mfGetSharedCacheDescriptor = ${createSharedCacheDescriptor.toString()};
|
|
311
293
|
const __mfReadSharedCache = (cache, descriptor) => {
|
|
312
294
|
const value = cache[descriptor.canonical];
|
|
313
295
|
if (value !== undefined) return value;
|
|
@@ -530,7 +512,7 @@ function resolveInstalledPackageJson(pkg, cwd, packageName, opts) {
|
|
|
530
512
|
const directCandidate = tryReadPackageJson(path$1.join(dir, "node_modules", packageName, "package.json"), packageName);
|
|
531
513
|
if (directCandidate) return directCandidate;
|
|
532
514
|
}
|
|
533
|
-
return findPackageInDependents(packageName, cwd) ?? findPackageInPnpmStore(packageName, cwd);
|
|
515
|
+
return findPackageInDependents(packageName, cwd)?.copy ?? findPackageInPnpmStore(packageName, cwd);
|
|
534
516
|
}
|
|
535
517
|
function readDirEntries(dir) {
|
|
536
518
|
try {
|
|
@@ -605,12 +587,13 @@ function walkDependents(packageName, cwd, reachedNames) {
|
|
|
605
587
|
for (const rootDependencies of rootDependencyGroups) {
|
|
606
588
|
let level = rootDependencies.map((name) => ({
|
|
607
589
|
name,
|
|
608
|
-
fromDir: cwd
|
|
590
|
+
fromDir: cwd,
|
|
591
|
+
chain: [name]
|
|
609
592
|
}));
|
|
610
593
|
while (level.length) {
|
|
611
594
|
const candidates = [];
|
|
612
595
|
const nextLevel = [];
|
|
613
|
-
for (const { name, fromDir } of level) {
|
|
596
|
+
for (const { name, fromDir, chain } of level) {
|
|
614
597
|
if (name === packageName) continue;
|
|
615
598
|
const dependent = findPackageFrom(name, fromDir);
|
|
616
599
|
if (!dependent || visited.has(dependent.dir)) continue;
|
|
@@ -621,17 +604,20 @@ function walkDependents(packageName, cwd, reachedNames) {
|
|
|
621
604
|
const copy = findPackageFrom(packageName, dependent.dir);
|
|
622
605
|
if (copy) candidates.push({
|
|
623
606
|
copy,
|
|
624
|
-
via: name
|
|
607
|
+
via: name,
|
|
608
|
+
dependentDir: dependent.dir,
|
|
609
|
+
chain
|
|
625
610
|
});
|
|
626
611
|
}
|
|
627
612
|
for (const dependency of dependencies) nextLevel.push({
|
|
628
613
|
name: dependency,
|
|
629
|
-
fromDir: dependent.dir
|
|
614
|
+
fromDir: dependent.dir,
|
|
615
|
+
chain: [...chain, dependency]
|
|
630
616
|
});
|
|
631
617
|
}
|
|
632
618
|
if (candidates.length) {
|
|
633
619
|
warnOnAmbiguousDependents(packageName, candidates);
|
|
634
|
-
return candidates[0]
|
|
620
|
+
return candidates[0];
|
|
635
621
|
}
|
|
636
622
|
level = nextLevel;
|
|
637
623
|
}
|
|
@@ -804,4 +790,4 @@ function watchFileEvents(watcher, listener) {
|
|
|
804
790
|
//#region src/utils/dtsConstants.ts
|
|
805
791
|
const DEFAULT_PUBLIC_TYPES_FOLDER = "@mf-types";
|
|
806
792
|
//#endregion
|
|
807
|
-
export {
|
|
793
|
+
export { sharedCacheHelperCode as C, isReactCoreShare as D, REACT_DOM_CLIENT_SHARE as E, setPackageDetectionCwd as S, REACT_CLIENT_INTERNALS_KEY as T, isPackageInstalled as _, getDependencyNames as a, resolveImportPath as b, getIsRolldown as c, getPackageName as d, getPackageNameFromNodeModulePath as f, isPackageExportAvailable as g, isNuxtProjectRoot as h, findPackageInDependents as i, getPackageDetectionCwd as l, hasPackageDependency as m, formatDevServerHostForOrigin as n, getInstalledPackageEntry as o, getSharedCacheDescriptor as p, watchFileEvents as r, getInstalledPackageJson as s, DEFAULT_PUBLIC_TYPES_FOLDER as t, getPackageExportSpecifiersForFile as u, packageNameDecode as v, supportsCodeSplittingGroupDebugName as w, resolveModulePath as x, packageNameEncode as y };
|