@module-federation/vite 1.16.14 → 1.16.16
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/index.d.ts +1 -1
- package/lib/index.js +147 -33
- package/lib/{pluginDts-CTAHkt4C.js → pluginDts-Bo95ELmX.js} +36 -1
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -49,7 +49,7 @@ type ModuleFederationOptions = {
|
|
|
49
49
|
version?: string;
|
|
50
50
|
shareScope?: string;
|
|
51
51
|
singleton?: boolean;
|
|
52
|
-
requiredVersion?:
|
|
52
|
+
requiredVersion?: moduleFederationPlugin.SharedConfig['requiredVersion'];
|
|
53
53
|
strictVersion?: boolean;
|
|
54
54
|
import?: moduleFederationPlugin.SharedConfig['import'];
|
|
55
55
|
}> | undefined;
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as createModuleFederationError, a as getIsRolldown, b as rebaseImport, c as getPackageNameFromNodeModulePath, d as isNuxtProjectRoot, f as packageNameDecode, g as sharedCacheHelperCode, h as setPackageDetectionCwd, i as getInstalledPackageJson, l as getSharedCacheDescriptor, m as resolveImportPath, o as getPackageDetectionCwd, p as packageNameEncode, r as getInstalledPackageEntry, s as getPackageName, u as hasPackageDependency, v as mfWarn, y as normalizePathForImport } from "./pluginDts-
|
|
1
|
+
import { _ as createModuleFederationError, a as getIsRolldown, b as rebaseImport, c as getPackageNameFromNodeModulePath, d as isNuxtProjectRoot, f as packageNameDecode, g as sharedCacheHelperCode, h as setPackageDetectionCwd, i as getInstalledPackageJson, l as getSharedCacheDescriptor, m as resolveImportPath, o as getPackageDetectionCwd, p as packageNameEncode, r as getInstalledPackageEntry, s as getPackageName, u as hasPackageDependency, v as mfWarn, y as normalizePathForImport } from "./pluginDts-Bo95ELmX.js";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import * as fs$2 from "fs";
|
|
4
4
|
import { existsSync, readFileSync, realpathSync, statSync, writeFileSync } from "fs";
|
|
@@ -192,6 +192,51 @@ const COMMON_SHARED_SUBPATHS = {
|
|
|
192
192
|
],
|
|
193
193
|
zustand: ["zustand/vanilla", "zustand/react"]
|
|
194
194
|
};
|
|
195
|
+
const VITE_DEFAULT_ASSET_TYPES = [
|
|
196
|
+
"apng",
|
|
197
|
+
"bmp",
|
|
198
|
+
"png",
|
|
199
|
+
"jpe?g",
|
|
200
|
+
"jfif",
|
|
201
|
+
"pjpeg",
|
|
202
|
+
"pjp",
|
|
203
|
+
"gif",
|
|
204
|
+
"svg",
|
|
205
|
+
"ico",
|
|
206
|
+
"webp",
|
|
207
|
+
"avif",
|
|
208
|
+
"cur",
|
|
209
|
+
"jxl",
|
|
210
|
+
"mp4",
|
|
211
|
+
"webm",
|
|
212
|
+
"ogg",
|
|
213
|
+
"mp3",
|
|
214
|
+
"wav",
|
|
215
|
+
"flac",
|
|
216
|
+
"aac",
|
|
217
|
+
"opus",
|
|
218
|
+
"mov",
|
|
219
|
+
"m4a",
|
|
220
|
+
"vtt",
|
|
221
|
+
"woff2?",
|
|
222
|
+
"eot",
|
|
223
|
+
"ttf",
|
|
224
|
+
"otf",
|
|
225
|
+
"webmanifest",
|
|
226
|
+
"pdf",
|
|
227
|
+
"txt"
|
|
228
|
+
];
|
|
229
|
+
const ASSET_LIKE_IMPORT_RE = new RegExp(`\\.(${[...[
|
|
230
|
+
"css",
|
|
231
|
+
"scss",
|
|
232
|
+
"sass",
|
|
233
|
+
"less",
|
|
234
|
+
"styl",
|
|
235
|
+
"stylus"
|
|
236
|
+
], ...VITE_DEFAULT_ASSET_TYPES].join("|")})(?:[?#].*)?$`, "i");
|
|
237
|
+
function isAssetLikeImport(source) {
|
|
238
|
+
return ASSET_LIKE_IMPORT_RE.test(source);
|
|
239
|
+
}
|
|
195
240
|
function removeTrailingSlash(value) {
|
|
196
241
|
return value.endsWith("/") ? value.slice(0, -1) : value;
|
|
197
242
|
}
|
|
@@ -233,7 +278,10 @@ function getCommonSharedSubpathFromNodeModulePath(source, sharedKey) {
|
|
|
233
278
|
function resolvePublicPath(options, viteBase, originalBase) {
|
|
234
279
|
if (options.publicPath && options.publicPath !== "auto") return options.publicPath;
|
|
235
280
|
if (!originalBase) return "auto";
|
|
236
|
-
if (viteBase)
|
|
281
|
+
if (viteBase) {
|
|
282
|
+
if (viteBase === "./") return "auto";
|
|
283
|
+
return ensureTrailingSlash(viteBase);
|
|
284
|
+
}
|
|
237
285
|
return "auto";
|
|
238
286
|
}
|
|
239
287
|
//#endregion
|
|
@@ -312,7 +360,7 @@ function searchPackageVersion(sharedName) {
|
|
|
312
360
|
return typeof version === "string" ? version : void 0;
|
|
313
361
|
}
|
|
314
362
|
function inferVersionFromRequiredVersion(requiredVersion) {
|
|
315
|
-
if (
|
|
363
|
+
if (typeof requiredVersion !== "string") return void 0;
|
|
316
364
|
return requiredVersion.match(/\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?/)?.[0];
|
|
317
365
|
}
|
|
318
366
|
function getLitExportSubpathShares(sharedName) {
|
|
@@ -345,7 +393,7 @@ function normalizeShareItem(key, shareItem) {
|
|
|
345
393
|
shareConfig: {
|
|
346
394
|
import: shareItem.import,
|
|
347
395
|
singleton: shareItem.singleton || false,
|
|
348
|
-
requiredVersion: shareItem.requiredVersion
|
|
396
|
+
requiredVersion: shareItem.requiredVersion !== void 0 ? shareItem.requiredVersion : isImportFalse || shareItem.version ? "*" : version ? `^${version}` : "*",
|
|
349
397
|
strictVersion: !!shareItem.strictVersion
|
|
350
398
|
}
|
|
351
399
|
};
|
|
@@ -610,7 +658,7 @@ function getSsrCapabilities(viteMajor, command, hasRemotes) {
|
|
|
610
658
|
* @returns {string} The resulting JavaScript source code string.
|
|
611
659
|
*/
|
|
612
660
|
function serializeRuntimeOptions(options) {
|
|
613
|
-
const
|
|
661
|
+
const ancestors = /* @__PURE__ */ new WeakSet();
|
|
614
662
|
/**
|
|
615
663
|
* Recursive inner function to serialize any value into a source code string.
|
|
616
664
|
*/
|
|
@@ -628,16 +676,18 @@ function serializeRuntimeOptions(options) {
|
|
|
628
676
|
if (val instanceof Date) return `new Date(${JSON.stringify(val.toISOString())})`;
|
|
629
677
|
if (val instanceof RegExp) return `new RegExp(${JSON.stringify(val.source)}, ${JSON.stringify(val.flags)})`;
|
|
630
678
|
if (type === "object") {
|
|
631
|
-
if (
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
679
|
+
if (ancestors.has(val)) return `"__circular__"`;
|
|
680
|
+
ancestors.add(val);
|
|
681
|
+
try {
|
|
682
|
+
if (Array.isArray(val)) return `[${val.map(valueToCode).join(", ")}]`;
|
|
683
|
+
if (val instanceof Map) return `new Map([${Array.from(val.entries()).map(([k, v]) => `[${valueToCode(k)}, ${valueToCode(v)}]`).join(", ")}])`;
|
|
684
|
+
if (val instanceof Set) return `new Set([${Array.from(val.values()).map(valueToCode).join(", ")}])`;
|
|
685
|
+
const properties = [];
|
|
686
|
+
for (const key in val) if (Object.prototype.hasOwnProperty.call(val, key)) properties.push(`${JSON.stringify(key)}: ${valueToCode(val[key])}`);
|
|
687
|
+
return `{${properties.join(", ")}}`;
|
|
688
|
+
} finally {
|
|
689
|
+
ancestors.delete(val);
|
|
690
|
+
}
|
|
641
691
|
}
|
|
642
692
|
return JSON.stringify(String(val));
|
|
643
693
|
}
|
|
@@ -1001,6 +1051,25 @@ function resolveRelativeModule(filePath, specifier) {
|
|
|
1001
1051
|
if (existsSync(candidate)) return candidate;
|
|
1002
1052
|
}
|
|
1003
1053
|
}
|
|
1054
|
+
function resolveReExportModule(filePath, specifier) {
|
|
1055
|
+
if (specifier.startsWith(".")) return resolveRelativeModule(filePath, specifier);
|
|
1056
|
+
const esmEntry = getInstalledPackageEntry(specifier, {
|
|
1057
|
+
cwd: path$1.dirname(filePath),
|
|
1058
|
+
conditions: [
|
|
1059
|
+
"browser",
|
|
1060
|
+
"import",
|
|
1061
|
+
"module",
|
|
1062
|
+
"default"
|
|
1063
|
+
],
|
|
1064
|
+
resolveSubpathWithRequire: false
|
|
1065
|
+
});
|
|
1066
|
+
if (esmEntry) return esmEntry;
|
|
1067
|
+
try {
|
|
1068
|
+
return resolveFileLikeModule(createRequire$1(pathToFileURL(filePath)).resolve(specifier));
|
|
1069
|
+
} catch {
|
|
1070
|
+
return;
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1004
1073
|
function getNamedExportsViaRegex(source, filePath, visited) {
|
|
1005
1074
|
const names = /* @__PURE__ */ new Set();
|
|
1006
1075
|
visited = visited || /* @__PURE__ */ new Set();
|
|
@@ -1044,8 +1113,7 @@ function getNamedExportsViaRegex(source, filePath, visited) {
|
|
|
1044
1113
|
const starExportRegex = /export\s+\*\s+from\s+['"]([^'"]+)['"]/g;
|
|
1045
1114
|
while ((match = starExportRegex.exec(source)) !== null) {
|
|
1046
1115
|
const specifier = match[1];
|
|
1047
|
-
|
|
1048
|
-
const resolvedPath = resolveRelativeModule(filePath, specifier);
|
|
1116
|
+
const resolvedPath = resolveReExportModule(filePath, specifier);
|
|
1049
1117
|
if (!resolvedPath || visited.has(resolvedPath)) continue;
|
|
1050
1118
|
try {
|
|
1051
1119
|
const reExportNames = getNamedExportsViaRegex(readFileSync(resolvedPath, "utf-8"), resolvedPath, visited);
|
|
@@ -1363,13 +1431,18 @@ function generateLazyWorkspaceSingletonExports(namedExports, importSource, cache
|
|
|
1363
1431
|
__mfWriteSharedCache(__mfModuleCache.share, ${cacheDescriptor}, exportModule);
|
|
1364
1432
|
__mfApplyLazyShareExports(exportModule);`}
|
|
1365
1433
|
} else {
|
|
1366
|
-
(__mfModuleCache.pendingShareLoads ||= []).push(initPromise.then(() =>
|
|
1367
|
-
|
|
1434
|
+
(__mfModuleCache.pendingShareLoads ||= []).push(initPromise.then(() => {
|
|
1435
|
+
exportModule = __mfReadSharedCache(__mfModuleCache.share, ${cacheDescriptor});
|
|
1436
|
+
if (exportModule !== undefined) {
|
|
1437
|
+
__mfApplyLazyShareExports(exportModule);
|
|
1438
|
+
return;
|
|
1439
|
+
}
|
|
1440
|
+
return import(${escapeGeneratedStringLiteral(importSource)}).then((mod) => {
|
|
1368
1441
|
exportModule = __mfNormalizeShareModule(mod);
|
|
1369
1442
|
__mfWriteSharedCache(__mfModuleCache.share, ${cacheDescriptor}, exportModule);
|
|
1370
1443
|
__mfApplyLazyShareExports(exportModule);
|
|
1371
|
-
})
|
|
1372
|
-
));
|
|
1444
|
+
});
|
|
1445
|
+
}));
|
|
1373
1446
|
}
|
|
1374
1447
|
} else {
|
|
1375
1448
|
__mfApplyLazyShareExports(exportModule);
|
|
@@ -1381,7 +1454,7 @@ function prependWorkspaceSingletonSsrImport(code) {
|
|
|
1381
1454
|
if (!code.includes("if (import.meta.env.SSR)")) return code;
|
|
1382
1455
|
if (!code.includes(WORKSPACE_SINGLETON_SSR_LOCAL_SHARE)) return code;
|
|
1383
1456
|
if (code.includes("import * as __mfLocalShare")) return code;
|
|
1384
|
-
const importMatch = code.match(/initPromise\.then\(\(\)\s*=>\s*\n\s*import\((["'])(.+?)\1\)\.then\(\(mod\)\s*=>\s*\{[\s\S]*?__mfApplyLazyShareExports/);
|
|
1457
|
+
const importMatch = code.match(/initPromise\.then\(\(\)\s*=>\s*\{[\s\S]*?\breturn import\((["'])(.+?)\1\)\.then\(\(mod\)\s*=>\s*\{[\s\S]*?__mfApplyLazyShareExports/) ?? code.match(/initPromise\.then\(\(\)\s*=>\s*\n\s*import\((["'])(.+?)\1\)\.then\(\(mod\)\s*=>\s*\{[\s\S]*?__mfApplyLazyShareExports/);
|
|
1385
1458
|
if (!importMatch) return code;
|
|
1386
1459
|
const quote = importMatch[1];
|
|
1387
1460
|
return `import * as __mfLocalShare from ${quote}${importMatch[2]}${quote};\n${code}`;
|
|
@@ -1548,7 +1621,7 @@ function generateLocalSharedImportMap() {
|
|
|
1548
1621
|
return `
|
|
1549
1622
|
import {loadShare} from "@module-federation/runtime";
|
|
1550
1623
|
const importMap = {
|
|
1551
|
-
${
|
|
1624
|
+
${getOrderedUsedShares().map((pkg) => {
|
|
1552
1625
|
const shareItem = getNormalizeShareItem(pkg);
|
|
1553
1626
|
return `
|
|
1554
1627
|
${JSON.stringify(pkg)}: async () => {
|
|
@@ -1559,7 +1632,7 @@ function generateLocalSharedImportMap() {
|
|
|
1559
1632
|
}).join(",")}
|
|
1560
1633
|
}
|
|
1561
1634
|
const usedShared = {
|
|
1562
|
-
${
|
|
1635
|
+
${getOrderedUsedShares().map((key) => {
|
|
1563
1636
|
const shareItem = getNormalizeShareItem(key);
|
|
1564
1637
|
if (!shareItem) return null;
|
|
1565
1638
|
return `
|
|
@@ -1635,9 +1708,15 @@ function getOrderedUsedShares() {
|
|
|
1635
1708
|
}
|
|
1636
1709
|
function orderSharedDependenciesFirst(sharedPackages) {
|
|
1637
1710
|
const sharedKeyByPackageName = /* @__PURE__ */ new Map();
|
|
1711
|
+
const subpathKeysByPackageName = /* @__PURE__ */ new Map();
|
|
1638
1712
|
sharedPackages.forEach((pkg) => {
|
|
1639
1713
|
const packageName = getPackageName(pkg);
|
|
1640
1714
|
if (!sharedKeyByPackageName.get(packageName) || pkg === packageName) sharedKeyByPackageName.set(packageName, pkg);
|
|
1715
|
+
if (pkg !== packageName) {
|
|
1716
|
+
const subpaths = subpathKeysByPackageName.get(packageName);
|
|
1717
|
+
if (subpaths) subpaths.push(pkg);
|
|
1718
|
+
else subpathKeysByPackageName.set(packageName, [pkg]);
|
|
1719
|
+
}
|
|
1641
1720
|
});
|
|
1642
1721
|
const visiting = /* @__PURE__ */ new Set();
|
|
1643
1722
|
const visited = /* @__PURE__ */ new Set();
|
|
@@ -1646,7 +1725,8 @@ function orderSharedDependenciesFirst(sharedPackages) {
|
|
|
1646
1725
|
if (visited.has(pkg)) return;
|
|
1647
1726
|
if (visiting.has(pkg)) return;
|
|
1648
1727
|
visiting.add(pkg);
|
|
1649
|
-
const
|
|
1728
|
+
const packageName = getPackageName(pkg);
|
|
1729
|
+
const packageJson = getInstalledPackageJson(pkg)?.packageJson ?? (pkg !== packageName ? getInstalledPackageJson(packageName)?.packageJson : void 0);
|
|
1650
1730
|
const dependencies = {
|
|
1651
1731
|
...packageJson?.dependencies || {},
|
|
1652
1732
|
...packageJson?.peerDependencies || {},
|
|
@@ -1656,6 +1736,7 @@ function orderSharedDependenciesFirst(sharedPackages) {
|
|
|
1656
1736
|
const sharedDependency = sharedKeyByPackageName.get(dependency);
|
|
1657
1737
|
if (sharedDependency) visit(sharedDependency);
|
|
1658
1738
|
});
|
|
1739
|
+
if (pkg === packageName) (subpathKeysByPackageName.get(packageName) || []).forEach(visit);
|
|
1659
1740
|
visiting.delete(pkg);
|
|
1660
1741
|
visited.add(pkg);
|
|
1661
1742
|
ordered.push(pkg);
|
|
@@ -1729,8 +1810,33 @@ function hasImportFalseShared$1(options) {
|
|
|
1729
1810
|
return Object.values(options.shared ?? {}).some((share) => share?.shareConfig?.import === false);
|
|
1730
1811
|
}
|
|
1731
1812
|
function generateRuntimeSharedCacheSeedCode() {
|
|
1813
|
+
const seedOrder = getOrderedUsedShares();
|
|
1732
1814
|
return `
|
|
1733
|
-
|
|
1815
|
+
const __mfSeedOrder = ${JSON.stringify(seedOrder)};
|
|
1816
|
+
const __mfSeedKeys = __mfSeedOrder.filter((pkg) => usedShared[pkg] !== undefined);
|
|
1817
|
+
const __mfSeedPackageName = (pkg) => pkg.startsWith('@')
|
|
1818
|
+
? pkg.split('/').slice(0, 2).join('/')
|
|
1819
|
+
: pkg.split('/')[0];
|
|
1820
|
+
for (const pkg of Object.keys(usedShared)) {
|
|
1821
|
+
if (__mfSeedKeys.includes(pkg)) continue;
|
|
1822
|
+
const packageName = __mfSeedPackageName(pkg);
|
|
1823
|
+
const rootIndex = __mfSeedKeys.indexOf(packageName);
|
|
1824
|
+
if (rootIndex === -1) {
|
|
1825
|
+
__mfSeedKeys.push(pkg);
|
|
1826
|
+
continue;
|
|
1827
|
+
}
|
|
1828
|
+
let insertIndex = rootIndex;
|
|
1829
|
+
while (
|
|
1830
|
+
insertIndex > 0 &&
|
|
1831
|
+
__mfSeedPackageName(__mfSeedKeys[insertIndex - 1]) === packageName &&
|
|
1832
|
+
__mfSeedKeys[insertIndex - 1] !== packageName
|
|
1833
|
+
) {
|
|
1834
|
+
insertIndex--;
|
|
1835
|
+
}
|
|
1836
|
+
__mfSeedKeys.splice(insertIndex, 0, pkg);
|
|
1837
|
+
}
|
|
1838
|
+
for (const pkg of __mfSeedKeys) {
|
|
1839
|
+
const share = usedShared[pkg];
|
|
1734
1840
|
const cacheDescriptor = __mfGetSharedCacheDescriptor(pkg, share.shareConfig?.singleton, share.version, share.scope);
|
|
1735
1841
|
if (share.shareConfig?.import === false || __mfReadSharedCache(__mfModuleCache.share, cacheDescriptor) !== undefined) {
|
|
1736
1842
|
continue;
|
|
@@ -1762,7 +1868,7 @@ function getHostAutoInitSharedSeedItems() {
|
|
|
1762
1868
|
return getOrderedUsedShares().map((pkg) => ({
|
|
1763
1869
|
pkg,
|
|
1764
1870
|
shareItem: getShareItemForPreload(pkg)
|
|
1765
|
-
})).filter(({ shareItem }) => shareItem?.shareConfig
|
|
1871
|
+
})).filter(({ shareItem }) => shareItem?.shareConfig?.import === false).sort((a, b) => {
|
|
1766
1872
|
const priority = (pkg) => pkg === "vue" ? 0 : pkg === "pinia" ? 1 : 2;
|
|
1767
1873
|
const aIsLocal = !!getLocalProviderImportPath(a.pkg);
|
|
1768
1874
|
const bIsLocal = !!getLocalProviderImportPath(b.pkg);
|
|
@@ -1955,6 +2061,9 @@ function generateRemoteEntry(options, virtualExposesId = getVirtualExposesId(opt
|
|
|
1955
2061
|
async function getExposes(moduleName) {
|
|
1956
2062
|
const exposesMap = await getExposesMap()
|
|
1957
2063
|
if (!(moduleName in exposesMap)) throw new Error(\`[Module Federation] Module \${moduleName} does not exist in container.\`)
|
|
2064
|
+
if (__mfModuleCache.pendingShareLoads) {
|
|
2065
|
+
await Promise.all(__mfModuleCache.pendingShareLoads)
|
|
2066
|
+
}
|
|
1958
2067
|
return (exposesMap[moduleName])().then(res => () => res)
|
|
1959
2068
|
}
|
|
1960
2069
|
export {
|
|
@@ -1968,6 +2077,7 @@ let currentHostAutoInitRemoteEntryId = REMOTE_ENTRY_ID;
|
|
|
1968
2077
|
let currentHostAutoInitCommand = "build";
|
|
1969
2078
|
function generateHostAutoInitCode(remoteEntryImport, _command = "build") {
|
|
1970
2079
|
const shouldPreloadShares = getNormalizeModuleFederationOptions().shareStrategy !== "loaded-first";
|
|
2080
|
+
const hostInitShareOrder = JSON.stringify(getOrderedUsedShares());
|
|
1971
2081
|
return `
|
|
1972
2082
|
${getRuntimeModuleCacheBootstrapCode()}
|
|
1973
2083
|
let hostInitPromise;
|
|
@@ -1981,7 +2091,11 @@ function generateHostAutoInitCode(remoteEntryImport, _command = "build") {
|
|
|
1981
2091
|
const {usedShared} = await import("${getLocalSharedImportMapPath()}");
|
|
1982
2092
|
${normalizeRuntimeShareCode}
|
|
1983
2093
|
${shouldPreloadShares ? `
|
|
1984
|
-
|
|
2094
|
+
const __mfHostInitShareOrder = ${hostInitShareOrder}
|
|
2095
|
+
.concat(Object.keys(usedShared).filter((pkg) => !${hostInitShareOrder}.includes(pkg)));
|
|
2096
|
+
for (const pkg of __mfHostInitShareOrder) {
|
|
2097
|
+
const share = usedShared[pkg];
|
|
2098
|
+
if (!share) continue;
|
|
1985
2099
|
const cacheDescriptor = __mfGetSharedCacheDescriptor(pkg, share.shareConfig?.singleton, share.version, share.scope);
|
|
1986
2100
|
if (__mfReadSharedCache(__mfModuleCache.share, cacheDescriptor) !== undefined) {
|
|
1987
2101
|
continue;
|
|
@@ -3936,7 +4050,7 @@ const Manifest = () => {
|
|
|
3936
4050
|
const varRemoteEntry = varFilename ? {
|
|
3937
4051
|
name: varFilename,
|
|
3938
4052
|
path: "",
|
|
3939
|
-
type: "
|
|
4053
|
+
type: "var"
|
|
3940
4054
|
} : void 0;
|
|
3941
4055
|
const remotes = Array.from(Object.entries(getUsedRemotesMap())).flatMap(([remoteKey, modules]) => Array.from(modules).map((moduleKey) => ({
|
|
3942
4056
|
federationContainerName: options.remotes[remoteKey].entry,
|
|
@@ -4576,7 +4690,7 @@ function proxySharedModule(options) {
|
|
|
4576
4690
|
const key = findSharedKeyForSource(source, shared);
|
|
4577
4691
|
if (!key) return;
|
|
4578
4692
|
if (useDirectReactImport && key === "react") return;
|
|
4579
|
-
if (
|
|
4693
|
+
if (isAssetLikeImport(source)) return;
|
|
4580
4694
|
if (isBuildConfigImporter(importer)) return;
|
|
4581
4695
|
if (useDirectReactImport && source === "react") return;
|
|
4582
4696
|
if (importer && importer.includes("localSharedImportMap")) return;
|
|
@@ -5622,7 +5736,7 @@ function createEarlyVirtualModulesPlugin(options) {
|
|
|
5622
5736
|
if (isSharedResolverInternalImporter(importer)) return;
|
|
5623
5737
|
const key = findSharedKey(source, shared);
|
|
5624
5738
|
if (!key) return;
|
|
5625
|
-
if (source
|
|
5739
|
+
if (isAssetLikeImport(source)) return;
|
|
5626
5740
|
const shareItem = shared[key];
|
|
5627
5741
|
const isReactSingleton = source === "react" && key === "react" && shareItem.shareConfig?.singleton === true;
|
|
5628
5742
|
const isReactRequire = options?.kind?.startsWith("require") && isReactSingleton;
|
|
@@ -5658,7 +5772,7 @@ function createEarlyVirtualModulesPlugin(options) {
|
|
|
5658
5772
|
if (args.kind === "entry-point") return;
|
|
5659
5773
|
if (!args.importer || args.namespace === "mf-shared") return;
|
|
5660
5774
|
if (isSharedResolverInternalImporter(args.importer)) return;
|
|
5661
|
-
if (!findSharedKey(args.path, shared) || args.path
|
|
5775
|
+
if (!findSharedKey(args.path, shared) || isAssetLikeImport(args.path)) return;
|
|
5662
5776
|
return {
|
|
5663
5777
|
path: args.path,
|
|
5664
5778
|
namespace: "mf-shared"
|
|
@@ -5769,7 +5883,7 @@ export default __mfShared.default ?? __mfShared;`
|
|
|
5769
5883
|
const SSR_ONLY_PLUGINS = new Set(["@module-federation/vite/ssrEntryLoader"]);
|
|
5770
5884
|
function loadPluginDts(options) {
|
|
5771
5885
|
if (options.dts === false) return [];
|
|
5772
|
-
return [import("./pluginDts-
|
|
5886
|
+
return [import("./pluginDts-Bo95ELmX.js").then((n) => n.n).then(({ default: pluginDts }) => pluginDts(options))];
|
|
5773
5887
|
}
|
|
5774
5888
|
function federation(mfUserOptions) {
|
|
5775
5889
|
if (isTestEnv()) return [];
|
|
@@ -141,12 +141,47 @@ function resolveExportsEntry(exportsField, conditions = DEFAULT_EXPORT_CONDITION
|
|
|
141
141
|
if (resolved) return resolved;
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
|
+
function substituteExportsWildcard(target, patternMatch) {
|
|
145
|
+
if (typeof target === "string") return target.split("*").join(patternMatch);
|
|
146
|
+
if (Array.isArray(target)) return target.map((entry) => substituteExportsWildcard(entry, patternMatch));
|
|
147
|
+
if (target && typeof target === "object") {
|
|
148
|
+
const source = target;
|
|
149
|
+
const out = {};
|
|
150
|
+
for (const key of Object.keys(source)) out[key] = substituteExportsWildcard(source[key], patternMatch);
|
|
151
|
+
return out;
|
|
152
|
+
}
|
|
153
|
+
return target;
|
|
154
|
+
}
|
|
155
|
+
function matchExportsSubpath(record, subpath) {
|
|
156
|
+
if (subpath in record) return record[subpath];
|
|
157
|
+
let bestKey;
|
|
158
|
+
let bestBaseLength = -1;
|
|
159
|
+
let bestKeyLength = -1;
|
|
160
|
+
for (const key of Object.keys(record)) {
|
|
161
|
+
const wildcardIndex = key.indexOf("*");
|
|
162
|
+
if (wildcardIndex === -1) continue;
|
|
163
|
+
const patternBase = key.slice(0, wildcardIndex);
|
|
164
|
+
const patternTrailer = key.slice(wildcardIndex + 1);
|
|
165
|
+
if (patternTrailer.includes("*")) continue;
|
|
166
|
+
if (!subpath.startsWith(patternBase) || !subpath.endsWith(patternTrailer)) continue;
|
|
167
|
+
if (subpath.length <= patternBase.length + patternTrailer.length) continue;
|
|
168
|
+
if (patternBase.length > bestBaseLength || patternBase.length === bestBaseLength && key.length > bestKeyLength) {
|
|
169
|
+
bestKey = key;
|
|
170
|
+
bestBaseLength = patternBase.length;
|
|
171
|
+
bestKeyLength = key.length;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
if (bestKey === void 0) return void 0;
|
|
175
|
+
const patternTrailer = bestKey.slice(bestKey.indexOf("*") + 1);
|
|
176
|
+
const patternMatch = subpath.slice(bestBaseLength, subpath.length - patternTrailer.length);
|
|
177
|
+
return substituteExportsWildcard(record[bestKey], patternMatch);
|
|
178
|
+
}
|
|
144
179
|
function getPackageExportsTarget(pkg, packageName, exportsField) {
|
|
145
180
|
if (typeof exportsField === "string") return pkg === packageName ? exportsField : void 0;
|
|
146
181
|
if (!exportsField || typeof exportsField !== "object") return void 0;
|
|
147
182
|
const record = exportsField;
|
|
148
183
|
const subpath = pkg === packageName ? "." : `.${pkg.slice(packageName.length)}`;
|
|
149
|
-
if (subpath !== ".") return record
|
|
184
|
+
if (subpath !== ".") return matchExportsSubpath(record, subpath);
|
|
150
185
|
return record["."] ?? (!Object.keys(record).some((key) => key.startsWith(".")) ? record : void 0);
|
|
151
186
|
}
|
|
152
187
|
/**
|