@module-federation/bridge-react 2.6.0 → 2.7.0

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/dist/base.cjs.js CHANGED
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const createHelpers = require("./createHelpers-DNBacpxb.js");
4
- const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-DG4e3Tib.js");
4
+ const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-BjMVNoep.js");
5
5
  const lazyUtils = require("./utils-CFTy4LVE.js");
6
6
  const dataFetchUtils = require("./data-fetch-utils.cjs.js");
7
- const prefetch = require("./prefetch-CG2l-06N.js");
7
+ const prefetch = require("./prefetch-DLhPTofn.js");
8
8
  const createRemoteAppComponent = createHelpers.createRemoteAppComponentFactory(createHelpers.RemoteAppWrapper);
9
9
  const createRemoteComponent = createHelpers.createDeprecatedRemoteComponentFactory(
10
10
  createRemoteAppComponent
package/dist/base.es.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { c as createRemoteAppComponentFactory, a as createDeprecatedRemoteComponentFactory, R as RemoteAppWrapper } from "./createHelpers-BY5Uj9_Z.mjs";
2
2
  import { b } from "./createHelpers-BY5Uj9_Z.mjs";
3
- import { a, c, b as b2, l } from "./lazy-load-component-plugin-BYI941I2.mjs";
3
+ import { a, c, b as b2, l } from "./lazy-load-component-plugin-aj97Vt-4.mjs";
4
4
  import { C, a as a2, E, c as c2, b as b3, d, g, r, s } from "./utils-DGS4pYp8.mjs";
5
5
  import { callDataFetch } from "./data-fetch-utils.es.js";
6
- import { p } from "./prefetch-DzO9_QQ-.mjs";
6
+ import { p } from "./prefetch-BwRDb4SJ.mjs";
7
7
  const createRemoteAppComponent = createRemoteAppComponentFactory(RemoteAppWrapper);
8
8
  const createRemoteComponent = createDeprecatedRemoteComponentFactory(
9
9
  createRemoteAppComponent
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const lazyUtils = require("./utils-CFTy4LVE.js");
4
- const prefetch = require("./prefetch-CG2l-06N.js");
4
+ const prefetch = require("./prefetch-DLhPTofn.js");
5
5
  async function callDataFetch() {
6
6
  const dataFetch = globalThis[lazyUtils.DATA_FETCH_FUNCTION];
7
7
  if (dataFetch) {
@@ -1,7 +1,7 @@
1
1
  import { y as DATA_FETCH_FUNCTION } from "./utils-DGS4pYp8.mjs";
2
2
  import { C, a, c, b, d, g, r } from "./utils-DGS4pYp8.mjs";
3
- import { d as dataFetchFunction } from "./prefetch-DzO9_QQ-.mjs";
4
- import { i, p } from "./prefetch-DzO9_QQ-.mjs";
3
+ import { d as dataFetchFunction } from "./prefetch-BwRDb4SJ.mjs";
4
+ import { i, p } from "./prefetch-BwRDb4SJ.mjs";
5
5
  async function callDataFetch() {
6
6
  const dataFetch = globalThis[DATA_FETCH_FUNCTION];
7
7
  if (dataFetch) {
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-DG4e3Tib.js");
3
+ const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-BjMVNoep.js");
4
4
  const lazyUtils = require("./utils-CFTy4LVE.js");
5
5
  const dataFetchUtils = require("./data-fetch-utils.cjs.js");
6
- const prefetch = require("./prefetch-CG2l-06N.js");
6
+ const prefetch = require("./prefetch-DLhPTofn.js");
7
7
  exports.autoFetchDataPlugin = lazyLoadComponentPlugin.autoFetchData;
8
8
  exports.collectSSRAssets = lazyLoadComponentPlugin.collectSSRAssets;
9
9
  exports.createLazyComponent = lazyLoadComponentPlugin.createLazyComponent;
@@ -1,7 +1,7 @@
1
- import { a, c, b, l } from "./lazy-load-component-plugin-BYI941I2.mjs";
1
+ import { a, c, b, l } from "./lazy-load-component-plugin-aj97Vt-4.mjs";
2
2
  import { C, a as a2, E, c as c2, b as b2, d, f, g, r, s } from "./utils-DGS4pYp8.mjs";
3
3
  import { callDataFetch } from "./data-fetch-utils.es.js";
4
- import { p } from "./prefetch-DzO9_QQ-.mjs";
4
+ import { p } from "./prefetch-BwRDb4SJ.mjs";
5
5
  export {
6
6
  C as CacheSize,
7
7
  a2 as CacheTime,
package/dist/index.cjs.js CHANGED
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const createHelpers = require("./createHelpers-DNBacpxb.js");
4
- const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-DG4e3Tib.js");
4
+ const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-BjMVNoep.js");
5
5
  const lazyUtils = require("./utils-CFTy4LVE.js");
6
6
  const dataFetchUtils = require("./data-fetch-utils.cjs.js");
7
7
  const React = require("react");
8
8
  const ReactRouterDOM = require("react-router-dom");
9
9
  const index = require("./index-DbjGCKOr.js");
10
- const prefetch = require("./prefetch-CG2l-06N.js");
10
+ const prefetch = require("./prefetch-DLhPTofn.js");
11
11
  function _interopNamespaceDefault(e2) {
12
12
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
13
13
  if (e2) {
package/dist/index.es.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import { R as RemoteAppWrapper, c as createRemoteAppComponentFactory, a as createDeprecatedRemoteComponentFactory } from "./createHelpers-BY5Uj9_Z.mjs";
2
2
  import { b } from "./createHelpers-BY5Uj9_Z.mjs";
3
- import { a, c, b as b2, l } from "./lazy-load-component-plugin-BYI941I2.mjs";
3
+ import { a, c, b as b2, l } from "./lazy-load-component-plugin-aj97Vt-4.mjs";
4
4
  import { C, a as a2, E, c as c2, b as b3, d, g, r, s } from "./utils-DGS4pYp8.mjs";
5
5
  import { callDataFetch } from "./data-fetch-utils.es.js";
6
6
  import React__default, { forwardRef, useContext, useState, useEffect } from "react";
7
7
  import * as ReactRouterDOM from "react-router-dom";
8
8
  import { p as pathJoin, L as LoggerInstance } from "./index-Bs2NxD2z.mjs";
9
- import { p } from "./prefetch-DzO9_QQ-.mjs";
9
+ import { p } from "./prefetch-BwRDb4SJ.mjs";
10
10
  function e() {
11
11
  const t = new PopStateEvent("popstate", { state: window.history.state });
12
12
  window.dispatchEvent(t);
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const prefetch = require("./prefetch-CG2l-06N.js");
2
+ const prefetch = require("./prefetch-DLhPTofn.js");
3
3
  const lazyUtils = require("./utils-CFTy4LVE.js");
4
4
  const React = require("react");
5
5
  const autoFetchData = () => {
@@ -1,4 +1,4 @@
1
- import { i as injectDataFetch, p as prefetch } from "./prefetch-DzO9_QQ-.mjs";
1
+ import { i as injectDataFetch, p as prefetch } from "./prefetch-BwRDb4SJ.mjs";
2
2
  import { i as initDataFetchMap, k as isDataLoaderExpose, m as getDataFetchInfo, n as getDataFetchMapKey, l as logger, o as getDataFetchItem, p as DATA_FETCH_CLIENT_SUFFIX, q as MF_DATA_FETCH_TYPE, t as isCSROnly, M as MF_DATA_FETCH_STATUS, j as loadDataFetchModule, e as getDataFetchMap, u as isServerEnv, v as getDataFetchIdWithErrorMsgs, w as DATA_FETCH_ERROR_PREFIX, E as ERROR_TYPE, x as wrapDataFetchId, L as LOAD_REMOTE_ERROR_PREFIX, y as DATA_FETCH_FUNCTION, z as getLoadedRemoteInfos, h as fetchData$1, A as setDataFetchItemLoadedStatus, F as FS_HREF } from "./utils-DGS4pYp8.mjs";
3
3
  import React__default, { useRef, useState, Suspense, useEffect } from "react";
4
4
  const autoFetchData = () => {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
- const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-DG4e3Tib.js");
4
- require("./prefetch-CG2l-06N.js");
3
+ const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-BjMVNoep.js");
4
+ require("./prefetch-DLhPTofn.js");
5
5
  exports.default = lazyLoadComponentPlugin.lazyLoadComponentPlugin;
6
6
  exports.lazyLoadComponentPlugin = lazyLoadComponentPlugin.lazyLoadComponentPlugin;
@@ -1,5 +1,5 @@
1
- import { l, l as l2 } from "./lazy-load-component-plugin-BYI941I2.mjs";
2
- import "./prefetch-DzO9_QQ-.mjs";
1
+ import { l, l as l2 } from "./lazy-load-component-plugin-aj97Vt-4.mjs";
2
+ import "./prefetch-BwRDb4SJ.mjs";
3
3
  export {
4
4
  l as default,
5
5
  l2 as lazyLoadComponentPlugin
@@ -215,16 +215,12 @@ function importNodeModule(name) {
215
215
  sdkImportCache.set(name, promise);
216
216
  return promise;
217
217
  }
218
- const loadNodeFetch = async () => {
219
- const fetchModule = await importNodeModule("node-fetch");
220
- return fetchModule.default || fetchModule;
221
- };
222
218
  const lazyLoaderHookFetch = async (input, init, loaderHook) => {
223
219
  const hook = (url, init2) => {
224
220
  return loaderHook.lifecycle.fetch.emit(url, init2);
225
221
  };
226
222
  const res = await hook(input, init || {});
227
- if (!res || !(res instanceof Response)) return (typeof fetch === "undefined" ? await loadNodeFetch() : fetch)(input, init || {});
223
+ if (!res || !(res instanceof Response)) return fetch(input, init || {});
228
224
  return res;
229
225
  };
230
226
  const createScriptNode = typeof ENV_TARGET === "undefined" || ENV_TARGET !== "web" ? (url, cb, attrs, loaderHook) => {
@@ -242,7 +238,7 @@ const createScriptNode = typeof ENV_TARGET === "undefined" || ENV_TARGET !== "we
242
238
  }
243
239
  const getFetch = async () => {
244
240
  if (loaderHook == null ? void 0 : loaderHook.fetch) return (input, init) => lazyLoaderHookFetch(input, init, loaderHook);
245
- return typeof fetch === "undefined" ? loadNodeFetch() : fetch;
241
+ return fetch;
246
242
  };
247
243
  const handleScriptFetch = async (f, urlObj2) => {
248
244
  var _a;
@@ -306,20 +302,82 @@ const loadScriptNode = typeof ENV_TARGET === "undefined" || ENV_TARGET !== "web"
306
302
  throw new Error("loadScriptNode is disabled in non-Node.js environment");
307
303
  };
308
304
  const esmModuleCache = /* @__PURE__ */ new Map();
305
+ const isFetchableRemoteModuleUrl = (url) => url.startsWith("http:") || url.startsWith("https:");
306
+ const isBareModuleSpecifier = (specifier) => !specifier.startsWith("./") && !specifier.startsWith("../") && !specifier.startsWith("/") && !specifier.includes(":");
307
+ function encodeRemoteModulePath(url) {
308
+ const remoteUrl = new URL(url);
309
+ const encodedProtocol = encodeURIComponent(remoteUrl.protocol.slice(0, -1));
310
+ const encodedHost = encodeURIComponent(remoteUrl.host);
311
+ const encodedPathname = remoteUrl.pathname.split("/").map((segment) => encodeURIComponent(segment)).join("/");
312
+ const encodedSearchHash = encodeURIComponent(`${remoteUrl.search}${remoteUrl.hash}`);
313
+ return `/${encodedProtocol}/${encodedHost}${encodedPathname}${encodedSearchHash ? `/${encodedSearchHash}` : ""}`;
314
+ }
315
+ function createImportMetaUrl(url, baseFileUrl) {
316
+ const baseUrl = baseFileUrl.endsWith("/") ? baseFileUrl : `${baseFileUrl}/`;
317
+ return new URL(`__module_federation_remote__${encodeRemoteModulePath(url)}`, baseUrl).href;
318
+ }
319
+ async function isNodeBuiltinSpecifier(specifier) {
320
+ if (specifier.startsWith("node:")) return true;
321
+ if (!isBareModuleSpecifier(specifier)) return false;
322
+ return (await importNodeModule("node:module")).builtinModules.includes(specifier);
323
+ }
324
+ function getSyntheticModuleExports(moduleExports) {
325
+ const namespaceObject = moduleExports && (typeof moduleExports === "object" || typeof moduleExports === "function") ? moduleExports : { default: moduleExports };
326
+ const effectiveExports = { ...namespaceObject };
327
+ if (!Object.prototype.hasOwnProperty.call(effectiveExports, "default")) effectiveExports.default = namespaceObject;
328
+ return effectiveExports;
329
+ }
330
+ async function createSyntheticModuleFromExports(identifier, moduleExports, vm) {
331
+ if (typeof vm.SyntheticModule !== "function") throw new Error("vm.SyntheticModule is required to load Node.js built-in modules in ESM remote entries.");
332
+ const effectiveExports = getSyntheticModuleExports(moduleExports);
333
+ const exportNames = Object.keys(effectiveExports);
334
+ const syntheticModule = new vm.SyntheticModule(exportNames, function setSyntheticModuleExports() {
335
+ for (const name of exportNames) this.setExport(name, effectiveExports[name]);
336
+ }, { identifier });
337
+ esmModuleCache.set(identifier, syntheticModule);
338
+ await syntheticModule.link(async () => {
339
+ throw new Error(`Node.js built-in module "${identifier}" should not request child modules.`);
340
+ });
341
+ await syntheticModule.evaluate();
342
+ return syntheticModule;
343
+ }
344
+ async function loadNodeBuiltinModule(specifier, vm) {
345
+ const cacheKey = `node-builtin:${specifier}`;
346
+ if (esmModuleCache.has(cacheKey)) return esmModuleCache.get(cacheKey);
347
+ return createSyntheticModuleFromExports(cacheKey, await importNodeModule(specifier), vm);
348
+ }
349
+ async function loadResolvedModule(specifier, parentUrl, options) {
350
+ if (await isNodeBuiltinSpecifier(specifier)) return loadNodeBuiltinModule(specifier, options.vm);
351
+ if (isBareModuleSpecifier(specifier)) throw new Error(`Unsupported ESM module specifier "${specifier}". Only relative or absolute http(s) remote modules and Node.js built-in modules are supported.`);
352
+ const resolvedUrl = new URL(specifier, parentUrl).href;
353
+ if (!isFetchableRemoteModuleUrl(resolvedUrl)) throw new Error(`Unsupported ESM module specifier "${specifier}" resolved to "${resolvedUrl}". Only http(s) remote modules and Node.js built-in modules are supported.`);
354
+ return loadModule(resolvedUrl, options);
355
+ }
356
+ async function evaluateDynamicModule(module) {
357
+ if (module.status === "linked") await module.evaluate();
358
+ if (module.status === "errored") throw module.error;
359
+ return module;
360
+ }
309
361
  async function loadModule(url, options) {
310
362
  if (esmModuleCache.has(url)) return esmModuleCache.get(url);
311
363
  const { fetch: fetch2, vm } = options;
364
+ if (!isFetchableRemoteModuleUrl(url)) throw new Error(`Unsupported ESM module URL "${url}". Only http(s) remote modules and Node.js built-in modules are supported.`);
312
365
  const code = await (await fetch2(url)).text();
313
- const module = new vm.SourceTextModule(code, { importModuleDynamically: async (specifier, script) => {
314
- const resolvedUrl = new URL(specifier, url).href;
315
- return loadModule(resolvedUrl, options);
316
- } });
317
- esmModuleCache.set(url, module);
318
- await module.link(async (specifier) => {
319
- const resolvedUrl = new URL(specifier, url).href;
320
- return await loadModule(resolvedUrl, options);
366
+ const cwdFileUrl = (await importNodeModule("node:url")).pathToFileURL(process.cwd()).href;
367
+ const sourceTextModule = new vm.SourceTextModule(code, {
368
+ identifier: url,
369
+ initializeImportMeta: (meta) => {
370
+ meta.url = createImportMetaUrl(url, cwdFileUrl);
371
+ },
372
+ importModuleDynamically: async (specifier) => {
373
+ return evaluateDynamicModule(await loadResolvedModule(specifier, url, options));
374
+ }
321
375
  });
322
- return module;
376
+ esmModuleCache.set(url, sourceTextModule);
377
+ await sourceTextModule.link(async (specifier) => {
378
+ return loadResolvedModule(specifier, url, options);
379
+ });
380
+ return sourceTextModule;
323
381
  }
324
382
  const dataFetchFunction = async function(options) {
325
383
  var _a, _b;
@@ -216,16 +216,12 @@ function importNodeModule(name) {
216
216
  sdkImportCache.set(name, promise);
217
217
  return promise;
218
218
  }
219
- const loadNodeFetch = async () => {
220
- const fetchModule = await importNodeModule("node-fetch");
221
- return fetchModule.default || fetchModule;
222
- };
223
219
  const lazyLoaderHookFetch = async (input, init, loaderHook) => {
224
220
  const hook = (url, init2) => {
225
221
  return loaderHook.lifecycle.fetch.emit(url, init2);
226
222
  };
227
223
  const res = await hook(input, init || {});
228
- if (!res || !(res instanceof Response)) return (typeof fetch === "undefined" ? await loadNodeFetch() : fetch)(input, init || {});
224
+ if (!res || !(res instanceof Response)) return fetch(input, init || {});
229
225
  return res;
230
226
  };
231
227
  const createScriptNode = typeof ENV_TARGET === "undefined" || ENV_TARGET !== "web" ? (url, cb, attrs, loaderHook) => {
@@ -243,7 +239,7 @@ const createScriptNode = typeof ENV_TARGET === "undefined" || ENV_TARGET !== "we
243
239
  }
244
240
  const getFetch = async () => {
245
241
  if (loaderHook == null ? void 0 : loaderHook.fetch) return (input, init) => lazyLoaderHookFetch(input, init, loaderHook);
246
- return typeof fetch === "undefined" ? loadNodeFetch() : fetch;
242
+ return fetch;
247
243
  };
248
244
  const handleScriptFetch = async (f, urlObj2) => {
249
245
  var _a;
@@ -307,20 +303,82 @@ const loadScriptNode = typeof ENV_TARGET === "undefined" || ENV_TARGET !== "web"
307
303
  throw new Error("loadScriptNode is disabled in non-Node.js environment");
308
304
  };
309
305
  const esmModuleCache = /* @__PURE__ */ new Map();
306
+ const isFetchableRemoteModuleUrl = (url) => url.startsWith("http:") || url.startsWith("https:");
307
+ const isBareModuleSpecifier = (specifier) => !specifier.startsWith("./") && !specifier.startsWith("../") && !specifier.startsWith("/") && !specifier.includes(":");
308
+ function encodeRemoteModulePath(url) {
309
+ const remoteUrl = new URL(url);
310
+ const encodedProtocol = encodeURIComponent(remoteUrl.protocol.slice(0, -1));
311
+ const encodedHost = encodeURIComponent(remoteUrl.host);
312
+ const encodedPathname = remoteUrl.pathname.split("/").map((segment) => encodeURIComponent(segment)).join("/");
313
+ const encodedSearchHash = encodeURIComponent(`${remoteUrl.search}${remoteUrl.hash}`);
314
+ return `/${encodedProtocol}/${encodedHost}${encodedPathname}${encodedSearchHash ? `/${encodedSearchHash}` : ""}`;
315
+ }
316
+ function createImportMetaUrl(url, baseFileUrl) {
317
+ const baseUrl = baseFileUrl.endsWith("/") ? baseFileUrl : `${baseFileUrl}/`;
318
+ return new URL(`__module_federation_remote__${encodeRemoteModulePath(url)}`, baseUrl).href;
319
+ }
320
+ async function isNodeBuiltinSpecifier(specifier) {
321
+ if (specifier.startsWith("node:")) return true;
322
+ if (!isBareModuleSpecifier(specifier)) return false;
323
+ return (await importNodeModule("node:module")).builtinModules.includes(specifier);
324
+ }
325
+ function getSyntheticModuleExports(moduleExports) {
326
+ const namespaceObject = moduleExports && (typeof moduleExports === "object" || typeof moduleExports === "function") ? moduleExports : { default: moduleExports };
327
+ const effectiveExports = { ...namespaceObject };
328
+ if (!Object.prototype.hasOwnProperty.call(effectiveExports, "default")) effectiveExports.default = namespaceObject;
329
+ return effectiveExports;
330
+ }
331
+ async function createSyntheticModuleFromExports(identifier, moduleExports, vm) {
332
+ if (typeof vm.SyntheticModule !== "function") throw new Error("vm.SyntheticModule is required to load Node.js built-in modules in ESM remote entries.");
333
+ const effectiveExports = getSyntheticModuleExports(moduleExports);
334
+ const exportNames = Object.keys(effectiveExports);
335
+ const syntheticModule = new vm.SyntheticModule(exportNames, function setSyntheticModuleExports() {
336
+ for (const name of exportNames) this.setExport(name, effectiveExports[name]);
337
+ }, { identifier });
338
+ esmModuleCache.set(identifier, syntheticModule);
339
+ await syntheticModule.link(async () => {
340
+ throw new Error(`Node.js built-in module "${identifier}" should not request child modules.`);
341
+ });
342
+ await syntheticModule.evaluate();
343
+ return syntheticModule;
344
+ }
345
+ async function loadNodeBuiltinModule(specifier, vm) {
346
+ const cacheKey = `node-builtin:${specifier}`;
347
+ if (esmModuleCache.has(cacheKey)) return esmModuleCache.get(cacheKey);
348
+ return createSyntheticModuleFromExports(cacheKey, await importNodeModule(specifier), vm);
349
+ }
350
+ async function loadResolvedModule(specifier, parentUrl, options) {
351
+ if (await isNodeBuiltinSpecifier(specifier)) return loadNodeBuiltinModule(specifier, options.vm);
352
+ if (isBareModuleSpecifier(specifier)) throw new Error(`Unsupported ESM module specifier "${specifier}". Only relative or absolute http(s) remote modules and Node.js built-in modules are supported.`);
353
+ const resolvedUrl = new URL(specifier, parentUrl).href;
354
+ if (!isFetchableRemoteModuleUrl(resolvedUrl)) throw new Error(`Unsupported ESM module specifier "${specifier}" resolved to "${resolvedUrl}". Only http(s) remote modules and Node.js built-in modules are supported.`);
355
+ return loadModule(resolvedUrl, options);
356
+ }
357
+ async function evaluateDynamicModule(module2) {
358
+ if (module2.status === "linked") await module2.evaluate();
359
+ if (module2.status === "errored") throw module2.error;
360
+ return module2;
361
+ }
310
362
  async function loadModule(url, options) {
311
363
  if (esmModuleCache.has(url)) return esmModuleCache.get(url);
312
364
  const { fetch: fetch2, vm } = options;
365
+ if (!isFetchableRemoteModuleUrl(url)) throw new Error(`Unsupported ESM module URL "${url}". Only http(s) remote modules and Node.js built-in modules are supported.`);
313
366
  const code = await (await fetch2(url)).text();
314
- const module2 = new vm.SourceTextModule(code, { importModuleDynamically: async (specifier, script) => {
315
- const resolvedUrl = new URL(specifier, url).href;
316
- return loadModule(resolvedUrl, options);
317
- } });
318
- esmModuleCache.set(url, module2);
319
- await module2.link(async (specifier) => {
320
- const resolvedUrl = new URL(specifier, url).href;
321
- return await loadModule(resolvedUrl, options);
367
+ const cwdFileUrl = (await importNodeModule("node:url")).pathToFileURL(process.cwd()).href;
368
+ const sourceTextModule = new vm.SourceTextModule(code, {
369
+ identifier: url,
370
+ initializeImportMeta: (meta) => {
371
+ meta.url = createImportMetaUrl(url, cwdFileUrl);
372
+ },
373
+ importModuleDynamically: async (specifier) => {
374
+ return evaluateDynamicModule(await loadResolvedModule(specifier, url, options));
375
+ }
322
376
  });
323
- return module2;
377
+ esmModuleCache.set(url, sourceTextModule);
378
+ await sourceTextModule.link(async (specifier) => {
379
+ return loadResolvedModule(specifier, url, options);
380
+ });
381
+ return sourceTextModule;
324
382
  }
325
383
  const dataFetchFunction = async function(options) {
326
384
  var _a, _b;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/bridge-react",
3
- "version": "2.6.0",
3
+ "version": "2.7.0",
4
4
  "sideEffects": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -140,7 +140,7 @@
140
140
  },
141
141
  "dependencies": {
142
142
  "lru-cache": "10.4.3",
143
- "@module-federation/sdk": "2.6.0"
143
+ "@module-federation/sdk": "2.7.0"
144
144
  },
145
145
  "peerDependencies": {
146
146
  "react": ">=16.9.0",
@@ -158,6 +158,7 @@
158
158
  },
159
159
  "devDependencies": {
160
160
  "react-error-boundary": "^4.1.2",
161
+ "@rsbuild/plugin-react": "2.1.0",
161
162
  "@testing-library/react": "15.0.7",
162
163
  "@testing-library/jest-dom": "6.6.3",
163
164
  "@types/react": "18.2.79",
@@ -169,19 +170,20 @@
169
170
  "react-dom": "18.3.1",
170
171
  "react-router-dom": "6.30.3",
171
172
  "react-router": "7.16.0",
172
- "typescript": "^5.2.2",
173
+ "typescript": "^6.0.3",
173
174
  "vite": "^5.4.21",
174
175
  "vite-plugin-dts": "^4.3.0",
175
- "hono": "4.12.25",
176
- "vitest": "1.6.0",
177
- "@module-federation/bridge-shared": "2.6.0",
178
- "@module-federation/runtime": "2.6.0",
179
- "@module-federation/runtime-core": "2.6.0"
176
+ "hono": "4.12.26",
177
+ "@module-federation/bridge-shared": "2.7.0",
178
+ "@module-federation/runtime-core": "2.7.0",
179
+ "@module-federation/runtime": "2.7.0"
180
180
  },
181
181
  "scripts": {
182
182
  "dev": "vite",
183
183
  "build": "vite build",
184
184
  "preview": "vite preview",
185
- "test": "pnpm exec jest --config jest.config.ts --passWithNoTests"
185
+ "test": "pnpm run test:jest && pnpm run test:rstest",
186
+ "test:jest": "pnpm exec jest --config jest.config.ts --passWithNoTests",
187
+ "test:rstest": "pnpm exec rstest --passWithNoTests"
186
188
  }
187
189
  }