@module-federation/vite 1.16.6 → 1.16.7

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.js CHANGED
@@ -1,4 +1,4 @@
1
- import { _ as normalizePathForImport, a as getPackageName, c as hasPackageDependency, d as packageNameEncode, f as resolveImportPath, g as mfWarn, i as getPackageDetectionCwd, l as isNuxtProjectRoot, m as createModuleFederationError, n as getInstalledPackageJson, o as getPackageNameFromNodeModulePath, p as setPackageDetectionCwd, r as getIsRolldown, s as getSharedCacheKey, t as getInstalledPackageEntry, u as packageNameDecode, v as rebaseImport } from "./packageUtils-CYnJFfPP.js";
1
+ import { _ as mfWarn, a as getIsRolldown, c as getPackageNameFromNodeModulePath, d as isNuxtProjectRoot, f as packageNameDecode, g as createModuleFederationError, h as setPackageDetectionCwd, i as getInstalledPackageJson, l as getSharedCacheKey, m as resolveImportPath, o as getPackageDetectionCwd, p as packageNameEncode, r as getInstalledPackageEntry, s as getPackageName, u as hasPackageDependency, v as normalizePathForImport, y as rebaseImport } from "./pluginDts-Cpmdbbr0.js";
2
2
  import { createRequire } from "node:module";
3
3
  import * as fs$1 from "fs";
4
4
  import { existsSync, readFileSync, realpathSync, statSync, writeFileSync } from "fs";
@@ -419,6 +419,7 @@ function getSuffix(name) {
419
419
  }
420
420
  const patternMap = {};
421
421
  const cacheMap = {};
422
+ const idCacheMap = {};
422
423
  const VITE_ID_PREFIX = "/@id/";
423
424
  const VITE_ENCODED_NULL_BYTE_PREFIX = `${VITE_ID_PREFIX}__x00__`;
424
425
  function escapeRegExp$1(value) {
@@ -453,6 +454,8 @@ var VirtualModule = class VirtualModule {
453
454
  suffix;
454
455
  inited = false;
455
456
  code;
457
+ importId;
458
+ importIdKey;
456
459
  static findName(tag, str = "") {
457
460
  if (!patternMap[tag]) patternMap[tag] = new RegExp(`(.*${packageNameEncode(tag)}(.+?)${packageNameEncode(tag)}.*)`);
458
461
  const moduleName = (normalizeVirtualModuleId(str).match(patternMap[tag]) || [])[2];
@@ -464,7 +467,7 @@ var VirtualModule = class VirtualModule {
464
467
  }
465
468
  static findById(id) {
466
469
  const normalized = normalizeVirtualModuleId(id);
467
- for (const modules of Object.values(cacheMap)) for (const module of Object.values(modules)) if (module.getImportId() === normalized) return module;
470
+ return normalized.startsWith("virtual:mf:") ? idCacheMap[normalized] : void 0;
468
471
  }
469
472
  constructor(name, tag = "__mf_v__", suffix = "") {
470
473
  this.name = name;
@@ -475,7 +478,13 @@ var VirtualModule = class VirtualModule {
475
478
  }
476
479
  getImportId() {
477
480
  const { internalName: mfName } = getNormalizeModuleFederationOptions();
478
- return `virtual:mf:${packageNameEncode(`${mfName}${this.tag}${this.name}${this.tag}`)}${this.suffix}`;
481
+ const importIdKey = `${mfName}${this.tag}${this.name}${this.tag}`;
482
+ if (this.importId && this.importIdKey === importIdKey) return this.importId;
483
+ if (this.importId) delete idCacheMap[this.importId];
484
+ this.importIdKey = importIdKey;
485
+ this.importId = `virtual:mf:${packageNameEncode(importIdKey)}${this.suffix}`;
486
+ idCacheMap[this.importId] = this;
487
+ return this.importId;
479
488
  }
480
489
  getResolvedId() {
481
490
  return `\0${this.getImportId()}`;
@@ -1084,11 +1093,15 @@ function toViteOptimizedDepVirtualId(id) {
1084
1093
  return toViteEncodedId(id);
1085
1094
  }
1086
1095
  function getCachedLoadSharePkg(id) {
1096
+ if (!id.includes("__loadShare__")) return;
1087
1097
  const normalized = normalizeVirtualModuleId(id);
1088
1098
  if (!normalized.startsWith("virtual:mf:")) return;
1089
- const pkg = VirtualModule.findName(LOAD_SHARE_TAG, normalized);
1090
- if (!pkg) return;
1091
- return pkg;
1099
+ const start = normalized.indexOf(LOAD_SHARE_TAG);
1100
+ if (start === -1) return;
1101
+ const encodedPkgStart = start + 13;
1102
+ const end = normalized.indexOf(LOAD_SHARE_TAG, encodedPkgStart);
1103
+ if (end === -1) return;
1104
+ return packageNameDecode(normalized.slice(encodedPkgStart, end));
1092
1105
  }
1093
1106
  function materializeCachedLoadShareModule(options) {
1094
1107
  const pkg = getCachedLoadSharePkg(options.id);
@@ -1263,13 +1276,8 @@ let invalidateLocalSharedImportMap;
1263
1276
  function setLocalSharedImportMapInvalidator(invalidator) {
1264
1277
  invalidateLocalSharedImportMap = invalidator;
1265
1278
  }
1266
- let prevLocalSharedImportMapContent;
1267
1279
  function writeLocalSharedImportMap() {
1268
- const nextContent = generateLocalSharedImportMap();
1269
- if (prevLocalSharedImportMapContent !== nextContent) {
1270
- prevLocalSharedImportMapContent = nextContent;
1271
- invalidateLocalSharedImportMap?.();
1272
- }
1280
+ invalidateLocalSharedImportMap?.();
1273
1281
  }
1274
1282
  function shouldUseDirectReactImport() {
1275
1283
  const isVinext = hasPackageDependency("vinext");
@@ -1380,10 +1388,36 @@ function getOrderedUsedShares() {
1380
1388
  if (!pkg.endsWith("/")) shares.add(pkg);
1381
1389
  });
1382
1390
  } catch {}
1383
- return Array.from(shares).sort((a, b) => {
1391
+ return orderSharedDependenciesFirst(Array.from(shares).sort((a, b) => {
1384
1392
  const priority = (pkg) => pkg === "react" ? 0 : pkg === "react-dom" ? 1 : pkg.startsWith("react/") ? 2 : 3;
1385
1393
  return priority(a) - priority(b) || a.localeCompare(b);
1386
- });
1394
+ }));
1395
+ }
1396
+ function orderSharedDependenciesFirst(sharedPackages) {
1397
+ const sharedKeyByPackageName = new Map(sharedPackages.map((pkg) => [getPackageName(pkg), pkg]));
1398
+ const visiting = /* @__PURE__ */ new Set();
1399
+ const visited = /* @__PURE__ */ new Set();
1400
+ const ordered = [];
1401
+ const visit = (pkg) => {
1402
+ if (visited.has(pkg)) return;
1403
+ if (visiting.has(pkg)) return;
1404
+ visiting.add(pkg);
1405
+ const packageJson = getInstalledPackageJson(pkg)?.packageJson;
1406
+ const dependencies = {
1407
+ ...packageJson?.dependencies || {},
1408
+ ...packageJson?.peerDependencies || {},
1409
+ ...packageJson?.optionalDependencies || {}
1410
+ };
1411
+ Object.keys(dependencies).forEach((dependency) => {
1412
+ const sharedDependency = sharedKeyByPackageName.get(dependency);
1413
+ if (sharedDependency) visit(sharedDependency);
1414
+ });
1415
+ visiting.delete(pkg);
1416
+ visited.add(pkg);
1417
+ ordered.push(pkg);
1418
+ };
1419
+ sharedPackages.forEach(visit);
1420
+ return ordered;
1387
1421
  }
1388
1422
  function getShareItemForPreload(pkg) {
1389
1423
  const shared = getNormalizeModuleFederationOptions().shared;
@@ -1698,13 +1732,18 @@ function resolveRemoteInitMode(shareStrategy, consumer) {
1698
1732
  function shouldDeferRemoteLoad(initMode) {
1699
1733
  return initMode === "loaded-first-client" || initMode === "loaded-first-unified";
1700
1734
  }
1701
- /** Dev SSR only build/preview client graphs must keep deferred proxies for static imports. */
1702
- function clientNeedsRealRemoteForHydration(command, enableSsrInit) {
1735
+ /** Dev client wrappers can preload remotes while exposing stable proxies. */
1736
+ function shouldEagerLoadClientRemoteInDev(command, enableSsrInit) {
1703
1737
  return enableSsrInit && command === "serve";
1704
1738
  }
1705
- function shouldIncludeDeferredProxy(initMode, consumer, clientNeedsRealRemote, deferRemoteLoad) {
1706
- if (initMode === "eager") return consumer !== "server" && (consumer === "unified" || !clientNeedsRealRemote);
1707
- if (consumer === "client" && clientNeedsRealRemote) return false;
1739
+ function getEagerDeferredClientInit() {
1740
+ return `__mfRemotePending = __mfStartRemoteLoad().then(__mfAssignRemoteModule);
1741
+ exportModule = __mfCreateDeferredRemoteProxy();`;
1742
+ }
1743
+ function shouldIncludeDeferredProxy(initMode, consumer, eagerLoadClientRemote, deferRemoteLoad) {
1744
+ if (eagerLoadClientRemote && consumer !== "server") return true;
1745
+ if (initMode === "eager") return consumer !== "server" && (consumer === "unified" || !eagerLoadClientRemote);
1746
+ if (consumer === "client" && eagerLoadClientRemote) return false;
1708
1747
  return deferRemoteLoad || consumer !== "server";
1709
1748
  }
1710
1749
  /** Codegen shared by every remote virtual module (no top-level await). */
@@ -1883,16 +1922,16 @@ function generateRemotes(id, command, enableSsrInit = false, consumer = "unified
1883
1922
  }`;
1884
1923
  const realRemoteInit = `__mfRemotePending = __mfStartRemoteLoad().then(__mfAssignRemoteModule);`;
1885
1924
  const deferredClientInit = `exportModule = __mfCreateDeferredRemoteProxy();`;
1886
- const clientNeedsRealRemote = clientNeedsRealRemoteForHydration(command, enableSsrInit);
1887
- const eagerClientInit = clientNeedsRealRemote ? realRemoteInit : deferredClientInit;
1888
- const loadedFirstClientInit = clientNeedsRealRemote ? realRemoteInit : deferredClientInit;
1925
+ const eagerLoadClientRemote = shouldEagerLoadClientRemoteInDev(command, enableSsrInit);
1926
+ const eagerClientInit = eagerLoadClientRemote ? getEagerDeferredClientInit() : deferredClientInit;
1927
+ const loadedFirstClientInit = eagerLoadClientRemote ? getEagerDeferredClientInit() : deferredClientInit;
1889
1928
  const environmentSplitInit = (clientInit, serverInit) => consumer === "client" ? clientInit : consumer === "server" ? serverInit : `if (typeof window === "undefined") {
1890
1929
  ${serverInit}
1891
1930
  } else {
1892
1931
  ${clientInit}
1893
1932
  }`;
1894
1933
  const initExportModule = initMode === "eager" ? environmentSplitInit(eagerClientInit, realRemoteInit) : environmentSplitInit(loadedFirstClientInit, realRemoteInit);
1895
- const includeProxyHelper = shouldIncludeDeferredProxy(initMode, consumer, clientNeedsRealRemote, deferRemoteLoad);
1934
+ const includeProxyHelper = shouldIncludeDeferredProxy(initMode, consumer, eagerLoadClientRemote, deferRemoteLoad);
1896
1935
  const deferredProxyCode = getDeferredProxyHelper(id);
1897
1936
  return `
1898
1937
  ${importLine}
@@ -1909,6 +1948,36 @@ function generateRemotes(id, command, enableSsrInit = false, consumer = "unified
1909
1948
  }
1910
1949
  //#endregion
1911
1950
  //#region src/plugins/pluginAddEntry.ts
1951
+ const HOST_INIT_PRELOAD_CHUNKS = [
1952
+ (name) => name === "hostInit",
1953
+ (name) => name === "remoteEntry",
1954
+ (name) => name.startsWith("_virtual_mf"),
1955
+ (name) => name === "index"
1956
+ ];
1957
+ function escapeHtmlAttr(value) {
1958
+ return value.replace(/&/g, "&").replace(/"/g, """);
1959
+ }
1960
+ function getExistingHrefSet(html) {
1961
+ return new Set(Array.from(html.matchAll(/\bhref\s*=\s*["']([^"']+)["']/gi), (match) => match[1]));
1962
+ }
1963
+ function injectHostInitPreloads(html, bundle, resolvePath) {
1964
+ const existingHrefs = getExistingHrefSet(html);
1965
+ const seenFiles = /* @__PURE__ */ new Set();
1966
+ const hrefs = [];
1967
+ for (const chunk of Object.values(bundle)) {
1968
+ if (chunk.type !== "chunk") continue;
1969
+ if (!HOST_INIT_PRELOAD_CHUNKS.some((match) => match(chunk.name))) continue;
1970
+ if (seenFiles.has(chunk.fileName)) continue;
1971
+ seenFiles.add(chunk.fileName);
1972
+ const href = resolvePath(chunk.fileName);
1973
+ if (existingHrefs.has(href)) continue;
1974
+ existingHrefs.add(href);
1975
+ hrefs.push(href);
1976
+ }
1977
+ if (hrefs.length === 0) return html;
1978
+ const tags = hrefs.map((href) => `<link rel="modulepreload" crossorigin href="${escapeHtmlAttr(href)}">`).join("");
1979
+ return html.includes("</head>") ? html.replace("</head>", `${tags}</head>`) : `${tags}${html}`;
1980
+ }
1912
1981
  function getFirstHtmlEntryFile(entryFiles) {
1913
1982
  return entryFiles.find((file) => file.endsWith(".html"));
1914
1983
  }
@@ -2215,9 +2284,9 @@ const addEntry = ({ entryName, entryPath, fileName, inject = "entry", forceClien
2215
2284
  emittedFileName = file;
2216
2285
  const lastSlash = file.lastIndexOf("/");
2217
2286
  bootstrapDir = lastSlash !== -1 ? file.slice(0, lastSlash + 1) : "";
2218
- const resolvePath = (htmlFileName) => {
2219
- if (!viteConfig.experimental?.renderBuiltUrl) return viteConfig.base + file;
2220
- const result = viteConfig.experimental.renderBuiltUrl(file, {
2287
+ const resolvePath = (builtFileName, htmlFileName) => {
2288
+ if (!viteConfig.experimental?.renderBuiltUrl) return viteConfig.base + builtFileName;
2289
+ const result = viteConfig.experimental.renderBuiltUrl(builtFileName, {
2221
2290
  hostId: htmlFileName,
2222
2291
  hostType: "html",
2223
2292
  type: "asset",
@@ -2227,11 +2296,11 @@ const addEntry = ({ entryName, entryPath, fileName, inject = "entry", forceClien
2227
2296
  if (result && typeof result === "object") {
2228
2297
  if ("runtime" in result) {
2229
2298
  mfWarn("renderBuiltUrl returned runtime code for HTML injection. Runtime code cannot be used in <script src=\"\">. Falling back to base path.");
2230
- return viteConfig.base + file;
2299
+ return viteConfig.base + builtFileName;
2231
2300
  }
2232
- if (result.relative) return file;
2301
+ if (result.relative) return builtFileName;
2233
2302
  }
2234
- return viteConfig.base + file;
2303
+ return viteConfig.base + builtFileName;
2235
2304
  };
2236
2305
  const basePrefix = viteConfig.base?.replace(/\/$/, "") ?? "";
2237
2306
  const stripBase = (p) => basePrefix && p.startsWith(basePrefix + "/") ? p.slice(basePrefix.length) : p;
@@ -2240,7 +2309,7 @@ const addEntry = ({ entryName, entryPath, fileName, inject = "entry", forceClien
2240
2309
  let htmlAsset = bundle[fileName];
2241
2310
  if (htmlAsset.type === "chunk") return;
2242
2311
  let htmlContent = htmlAsset.source.toString() || "";
2243
- const initPath = resolvePath(fileName);
2312
+ const initPath = resolvePath(file, fileName);
2244
2313
  const scriptRegex = /<script\b(?=[^>]*\btype=["']module["'])(?=[^>]*\bsrc=["']([^"']+)["'])[^>]*>\s*<\/script>/gi;
2245
2314
  let rewritten = false;
2246
2315
  htmlContent = htmlContent.replace(scriptRegex, (scriptTag, entrySrc) => {
@@ -2260,15 +2329,15 @@ const addEntry = ({ entryName, entryPath, fileName, inject = "entry", forceClien
2260
2329
  });
2261
2330
  if (!rewritten) {
2262
2331
  const svelteKitHtml = rewriteSvelteKitInlineStart(htmlContent, initPath);
2263
- if (svelteKitHtml !== htmlContent) {
2264
- htmlAsset.source = svelteKitHtml;
2265
- continue;
2266
- }
2267
- const scriptContent = `
2332
+ if (svelteKitHtml !== htmlContent) htmlContent = svelteKitHtml;
2333
+ else {
2334
+ const scriptContent = `
2268
2335
  <script type="module" src="${initPath}"><\/script>
2269
2336
  `;
2270
- htmlContent = htmlContent.replace("<head>", `<head>${scriptContent}`);
2337
+ htmlContent = htmlContent.replace("<head>", `<head>${scriptContent}`);
2338
+ }
2271
2339
  }
2340
+ if (waitsForInit) htmlContent = injectHostInitPreloads(htmlContent, bundle, (builtFileName) => resolvePath(builtFileName, fileName));
2272
2341
  htmlAsset.source = htmlContent;
2273
2342
  }
2274
2343
  },
@@ -3372,6 +3441,34 @@ function generateRemoteEntrySSR(options) {
3372
3441
  function getBuildVersion() {
3373
3442
  return process.env["MF_BUILD_VERSION"] ?? "1.0.0";
3374
3443
  }
3444
+ /**
3445
+ * Builds the manifest `metaData.types` entry.
3446
+ *
3447
+ * When type generation is enabled, the dts plugin serves the type archive
3448
+ * (`<typesFolder>.zip`) and api file (`<typesFolder>.d.ts`). Consumers using
3449
+ * `@module-federation/dts-plugin` read `metaData.types.zip` to download those
3450
+ * types and throw `Can not get <remote>'s types archive url!` when it is absent.
3451
+ * Advertising the relative paths here (resolved against `publicPath` by the
3452
+ * consumer) mirrors the webpack/rspack (`@module-federation/enhanced`) plugins.
3453
+ */
3454
+ function resolveTypesMeta(dts) {
3455
+ if (dts === false) return {
3456
+ path: "",
3457
+ name: ""
3458
+ };
3459
+ const generateTypes = typeof dts === "object" && dts ? dts.generateTypes : void 0;
3460
+ if (generateTypes === false) return {
3461
+ path: "",
3462
+ name: ""
3463
+ };
3464
+ const typesFolder = typeof generateTypes === "object" && generateTypes?.typesFolder || "@mf-types";
3465
+ return {
3466
+ path: "",
3467
+ name: "",
3468
+ zip: `${typesFolder}.zip`,
3469
+ api: `${typesFolder}.d.ts`
3470
+ };
3471
+ }
3375
3472
  const Manifest = () => {
3376
3473
  const mfOptions = getNormalizeModuleFederationOptions();
3377
3474
  const { name, filename, getPublicPath, manifest: manifestOptions, varFilename } = mfOptions;
@@ -3435,10 +3532,7 @@ const Manifest = () => {
3435
3532
  path: "",
3436
3533
  type: "var"
3437
3534
  } : void 0,
3438
- types: {
3439
- path: "",
3440
- name: ""
3441
- },
3535
+ types: resolveTypesMeta(mfOptions.dts),
3442
3536
  globalName: name,
3443
3537
  pluginVersion: "0.2.5",
3444
3538
  publicPath
@@ -3589,10 +3683,7 @@ const Manifest = () => {
3589
3683
  remoteEntry,
3590
3684
  ssrRemoteEntry,
3591
3685
  varRemoteEntry,
3592
- types: {
3593
- path: "",
3594
- name: ""
3595
- },
3686
+ types: resolveTypesMeta(options.dts),
3596
3687
  globalName: name,
3597
3688
  pluginVersion: "0.2.5",
3598
3689
  ...!!getPublicPath ? { getPublicPath } : { publicPath }
@@ -3676,7 +3767,7 @@ function resetIdleTimeout(timeout) {
3676
3767
  }, timeout * 1e3);
3677
3768
  }
3678
3769
  function pluginModuleParseEnd_default(excludeFn, options) {
3679
- const idleTimeout = options.moduleParseIdleTimeout;
3770
+ const idleTimeout = options.moduleParseIdleTimeout ?? options.moduleParseTimeout;
3680
3771
  return [
3681
3772
  {
3682
3773
  name: "_",
@@ -3711,6 +3802,9 @@ function pluginModuleParseEnd_default(excludeFn, options) {
3711
3802
  if (excludeFn(id)) return;
3712
3803
  parseEndSet.add(id);
3713
3804
  if (parseStartSet.size === parseEndSet.size && (!expectsExposesParseEnd || exposesParseEnd)) _resolve?.(1);
3805
+ },
3806
+ buildEnd() {
3807
+ _resolve?.(1);
3714
3808
  }
3715
3809
  }
3716
3810
  ];
@@ -3973,8 +4067,42 @@ function matchesSharedSource(source, key) {
3973
4067
  return source === keyBase;
3974
4068
  }
3975
4069
  function findSharedKey(source, shared) {
3976
- const keys = Object.keys(shared || {});
3977
- return keys.find((key) => source === key) ?? keys.find((key) => matchesSharedSource(source, key));
4070
+ return getSharedKeyMatcher(shared).find(source);
4071
+ }
4072
+ const emptySharedKeyMatcher = { find: () => void 0 };
4073
+ const sharedKeyMatcherCache = /* @__PURE__ */ new WeakMap();
4074
+ function getSharedKeyMatcher(shared) {
4075
+ if (!shared) return emptySharedKeyMatcher;
4076
+ const cached = sharedKeyMatcherCache.get(shared);
4077
+ if (cached) return cached;
4078
+ const keys = Object.keys(shared);
4079
+ const exactKeys = new Set(keys);
4080
+ const commonSubpathKeys = /* @__PURE__ */ new Map();
4081
+ const wildcardKeys = [];
4082
+ let vueKey;
4083
+ for (const key of keys) {
4084
+ const keyBase = key.endsWith("/") ? key.slice(0, -1) : key;
4085
+ if (!vueKey && keyBase === "vue") vueKey = key;
4086
+ if (key.endsWith("/")) wildcardKeys.push({
4087
+ key,
4088
+ base: keyBase
4089
+ });
4090
+ for (const subpath of getCommonSharedSubpaths(keyBase)) if (!commonSubpathKeys.has(subpath)) commonSubpathKeys.set(subpath, key);
4091
+ }
4092
+ const sourceCache = /* @__PURE__ */ new Map();
4093
+ const matcher = { find(source) {
4094
+ if (sourceCache.has(source)) return sourceCache.get(source);
4095
+ let result = exactKeys.has(source) ? source : void 0;
4096
+ if (!result && vueKey) {
4097
+ if (source === "vue/dist/vue.esm-bundler.js" || source === "vue/dist/vue.runtime.esm-bundler.js") result = vueKey;
4098
+ }
4099
+ if (!result) result = commonSubpathKeys.get(source);
4100
+ if (!result) result = wildcardKeys.find(({ base }) => source === base || source.startsWith(`${base}/`))?.key;
4101
+ sourceCache.set(source, result);
4102
+ return result;
4103
+ } };
4104
+ sharedKeyMatcherCache.set(shared, matcher);
4105
+ return matcher;
3978
4106
  }
3979
4107
  function findSharedKeyForSource(source, shared) {
3980
4108
  const key = findSharedKey(source, shared);
@@ -5089,7 +5217,7 @@ export default __mfShared.default ?? __mfShared;`
5089
5217
  const SSR_ONLY_PLUGINS = new Set(["@module-federation/vite/ssrEntryLoader"]);
5090
5218
  function loadPluginDts(options) {
5091
5219
  if (options.dts === false) return [];
5092
- return [import("./pluginDts-BaVhdR6i.js").then(({ default: pluginDts }) => pluginDts(options))];
5220
+ return [import("./pluginDts-Cpmdbbr0.js").then((n) => n.n).then(({ default: pluginDts }) => pluginDts(options))];
5093
5221
  }
5094
5222
  function federation(mfUserOptions) {
5095
5223
  if (isTestEnv()) return [];
@@ -5200,7 +5328,7 @@ function federation(mfUserOptions) {
5200
5328
  pluginProxyRemotes_default(options),
5201
5329
  pluginRemoteNamedExports(options),
5202
5330
  ...pluginModuleParseEnd_default((id) => {
5203
- return id.includes(getHostAutoInitImportId()) || id.includes(remoteEntryId) || id.includes(virtualExposesId) || id.includes(getLocalSharedImportMapPath());
5331
+ return id.includes(getHostAutoInitImportId()) || id.includes(remoteEntryId) || id.includes(virtualExposesId) || id.includes(getLocalSharedImportMapPath()) || id.includes("__loadShare__") || id.includes("__prebuild__");
5204
5332
  }, {
5205
5333
  moduleParseTimeout: options.moduleParseTimeout,
5206
5334
  moduleParseIdleTimeout: options.moduleParseIdleTimeout,
@@ -5482,12 +5610,12 @@ function federation(mfUserOptions) {
5482
5610
  const prefixToRoot = chunkDir === "." ? "" : `${normalizePathForImport(path$1.relative(chunkDir, "."))}/`;
5483
5611
  const replacementExpr = prefixToRoot ? `${escapeUnsafeJsSourceChars(JSON.stringify(prefixToRoot))}+$1` : "$1";
5484
5612
  const replacement = `=function($1){return new URL(${replacementExpr},import.meta.url).href}`;
5485
- const replaced = chunk.code.replace(/=\(?(\w+)(?:,\w+)?\)?\s*=>\s*[`"'][./][^`"']*[`"']\s*\+\s*\1/, replacement);
5613
+ const replaced = chunk.code.replace(/=\s*\(?(\w+)(?:,\w+)?\)?\s*=>\s*[`"'][./][^`"']*[`"']\s*\+\s*\1/, replacement);
5486
5614
  if (replaced !== chunk.code) {
5487
5615
  chunk.code = replaced;
5488
5616
  continue;
5489
5617
  }
5490
- chunk.code = chunk.code.replace(/=function\((\w+)(?:,\w+)?\)\{return\s*[`"'][./][^`"']*[`"']\s*\+\s*\1\s*\}/, replacement);
5618
+ chunk.code = chunk.code.replace(/=\s*function\((\w+)(?:,\w+)?\)\s*\{\s*return\s*[`"'][./][^`"']*[`"']\s*\+\s*\1;?\s*\}/, replacement);
5491
5619
  chunk.code = chunk.code.replace(/=function\((\w+)(?:,\w+)?\)\{return new URL\("\.\.\/"\+\1,import\.meta\.url\)\.href\}/, replacement);
5492
5620
  chunk.code = chunk.code.replace(/new URL\("\.\.\/"\+(\w+),import\.meta\.url\)\.href/g, `new URL(${replacementExpr},import.meta.url).href`);
5493
5621
  }