@module-federation/bridge-react 0.19.1 → 0.21.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/__tests__/bridge.spec.tsx +37 -14
  3. package/dist/{bridge-base-Ds850AOx.js → bridge-base-B2malZDo.js} +6 -4
  4. package/dist/{bridge-base-BwHtOqw_.mjs → bridge-base-DRFFglgm.mjs} +6 -4
  5. package/dist/data-fetch-server-middleware.cjs.js +2 -2
  6. package/dist/data-fetch-server-middleware.es.js +2 -2
  7. package/dist/data-fetch-utils.cjs.js +2 -2
  8. package/dist/data-fetch-utils.es.js +4 -4
  9. package/dist/{index-eN2xRRXs.js → index-DRSBaSu3.js} +1 -1
  10. package/dist/{index-rAO0Wr0M.mjs → index-DyQNwY2M.mjs} +1 -1
  11. package/dist/index.cjs.js +6 -6
  12. package/dist/index.es.js +6 -6
  13. package/dist/{index.esm-Ju4RY-yW.js → index.esm-BWaKho-8.js} +108 -46
  14. package/dist/{index.esm-CtI0uQUR.mjs → index.esm-CPwSeCvw.mjs} +113 -51
  15. package/dist/{lazy-load-component-plugin-vtpWwn-P.js → lazy-load-component-plugin-B-nqmULm.js} +2 -2
  16. package/dist/{lazy-load-component-plugin-Dmzr-hGo.mjs → lazy-load-component-plugin-D_--Azke.mjs} +2 -2
  17. package/dist/lazy-load-component-plugin.cjs.js +2 -2
  18. package/dist/lazy-load-component-plugin.es.js +2 -2
  19. package/dist/lazy-utils.cjs.js +2 -2
  20. package/dist/lazy-utils.es.js +2 -2
  21. package/dist/{prefetch-HjsWsmMr.js → prefetch-C8kORtvg.js} +63 -139
  22. package/dist/{prefetch-DtZwviM-.mjs → prefetch-Cxo6GKct.mjs} +63 -139
  23. package/dist/router-v5.cjs.js +1 -1
  24. package/dist/router-v5.es.js +1 -1
  25. package/dist/router-v6.cjs.js +1 -1
  26. package/dist/router-v6.es.js +1 -1
  27. package/dist/router-v7.cjs.js +83 -0
  28. package/dist/router-v7.d.ts +20 -0
  29. package/dist/router-v7.es.js +61 -0
  30. package/dist/router.cjs.js +1 -1
  31. package/dist/router.es.js +1 -1
  32. package/dist/{utils-VSOJTX_o.mjs → utils-Bx_8GGd-.mjs} +1 -1
  33. package/dist/{utils-vIpCrZmn.js → utils-tM9yE73c.js} +1 -1
  34. package/dist/v18.cjs.js +1 -1
  35. package/dist/v18.es.js +1 -1
  36. package/dist/v19.cjs.js +1 -1
  37. package/dist/v19.es.js +1 -1
  38. package/package.json +22 -7
  39. package/src/provider/versions/bridge-base.tsx +7 -2
  40. package/src/provider/versions/legacy.ts +2 -1
  41. package/src/router/v7.tsx +75 -0
  42. package/vite.config.ts +24 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # @module-federation/bridge-react
2
2
 
3
+ ## 0.21.0
4
+
5
+ ### Minor Changes
6
+
7
+ - d225658: feat: Add React Router v7 Support to Module Federation Bridge
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [d1e90a4]
12
+ - @module-federation/sdk@0.21.0
13
+ - @module-federation/bridge-shared@0.21.0
14
+
15
+ ## 0.20.0
16
+
17
+ ### Patch Changes
18
+
19
+ - 0008621: test(bridge-react): stabilize async assertions for bridge tests
20
+ - Updated dependencies [37346d4]
21
+ - Updated dependencies [639a83b]
22
+ - @module-federation/sdk@0.20.0
23
+ - @module-federation/bridge-shared@0.20.0
24
+
3
25
  ## 0.19.1
4
26
 
5
27
  ### Patch Changes
@@ -7,7 +7,7 @@ import {
7
7
  screen,
8
8
  waitFor,
9
9
  } from '@testing-library/react';
10
- import { createContainer, getHtml, sleep } from './util';
10
+ import { createContainer, getHtml } from './util';
11
11
 
12
12
  describe('bridge', () => {
13
13
  let containerInfo: ReturnType<typeof createContainer>;
@@ -31,9 +31,13 @@ describe('bridge', () => {
31
31
  dom: containerInfo?.container,
32
32
  });
33
33
 
34
- await sleep(200);
35
- expect(document.querySelector('#container')!.innerHTML).toContain(
36
- '<div>life cycle render</div>',
34
+ await waitFor(
35
+ () => {
36
+ expect(document.querySelector('#container')?.innerHTML).toContain(
37
+ '<div>life cycle render</div>',
38
+ );
39
+ },
40
+ { timeout: 2000 },
37
41
  );
38
42
 
39
43
  lifeCycle.destroy({
@@ -41,7 +45,14 @@ describe('bridge', () => {
41
45
  moduleName: 'test',
42
46
  });
43
47
 
44
- expect(document.querySelector('#container')!.innerHTML).toContain('');
48
+ await waitFor(
49
+ () => {
50
+ expect(
51
+ (document.querySelector('#container')?.innerHTML || '').trim(),
52
+ ).toBe('');
53
+ },
54
+ { timeout: 2000 },
55
+ );
45
56
  });
46
57
 
47
58
  it('createRemoteAppComponent', async () => {
@@ -66,9 +77,13 @@ describe('bridge', () => {
66
77
  );
67
78
  expect(getHtml(container)).toMatch('loading');
68
79
 
69
- await sleep(200);
70
- expect(getHtml(container)).toMatch('life cycle render');
71
- expect(getHtml(container)).toMatch('hello world');
80
+ await waitFor(
81
+ () => {
82
+ expect(getHtml(container)).toMatch('life cycle render');
83
+ expect(getHtml(container)).toMatch('hello world');
84
+ },
85
+ { timeout: 2000 },
86
+ );
72
87
  });
73
88
 
74
89
  it('createRemoteAppComponent and obtain ref property', async () => {
@@ -97,10 +112,14 @@ describe('bridge', () => {
97
112
  );
98
113
  expect(getHtml(container)).toMatch('loading');
99
114
 
100
- await sleep(200);
101
- expect(getHtml(container)).toMatch('life cycle render');
102
- expect(getHtml(container)).toMatch('hello world');
103
- expect(ref.current).not.toBeNull();
115
+ await waitFor(
116
+ () => {
117
+ expect(getHtml(container)).toMatch('life cycle render');
118
+ expect(getHtml(container)).toMatch('hello world');
119
+ expect(ref.current).not.toBeNull();
120
+ },
121
+ { timeout: 2000 },
122
+ );
104
123
  });
105
124
 
106
125
  it('createRemoteAppComponent with custom createRoot prop', async () => {
@@ -131,7 +150,11 @@ describe('bridge', () => {
131
150
  const { container } = render(<RemoteComponent />);
132
151
  expect(getHtml(container)).toMatch('loading');
133
152
 
134
- await sleep(200);
135
- expect(renderMock).toHaveBeenCalledTimes(1);
153
+ await waitFor(
154
+ () => {
155
+ expect(renderMock).toHaveBeenCalledTimes(1);
156
+ },
157
+ { timeout: 2000 },
158
+ );
136
159
  });
137
160
  });
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  const React = require("react");
3
- const index = require("./index-eN2xRRXs.js");
3
+ const index = require("./index-DRSBaSu3.js");
4
4
  const plugin = require("./plugin.cjs.js");
5
5
  function _interopNamespaceDefault(e) {
6
6
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
@@ -156,7 +156,7 @@ function createBaseBridgeComponent({
156
156
  ...rootOptions
157
157
  };
158
158
  const beforeBridgeRenderRes = ((_c = (_b = (_a = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.beforeBridgeRender) == null ? void 0 : _c.emit(info)) || {};
159
- const rootComponentWithErrorBoundary = /* @__PURE__ */ React__namespace.createElement(
159
+ const BridgeWrapper = ({ basename: basename2 }) => /* @__PURE__ */ React__namespace.createElement(
160
160
  ErrorBoundary,
161
161
  {
162
162
  FallbackComponent: fallback
@@ -166,16 +166,18 @@ function createBaseBridgeComponent({
166
166
  {
167
167
  appInfo: {
168
168
  moduleName,
169
- basename,
169
+ basename: basename2,
170
170
  memoryRoute
171
171
  },
172
172
  propsInfo: {
173
173
  ...propsInfo,
174
+ basename: basename2,
174
175
  ...beforeBridgeRenderRes == null ? void 0 : beforeBridgeRenderRes.extraProps
175
176
  }
176
177
  }
177
178
  )
178
179
  );
180
+ const rootComponentWithErrorBoundary = /* @__PURE__ */ React__namespace.createElement(BridgeWrapper, { basename });
179
181
  if (bridgeInfo.render) {
180
182
  await Promise.resolve(
181
183
  bridgeInfo.render(rootComponentWithErrorBoundary, dom)
@@ -201,7 +203,7 @@ function createBaseBridgeComponent({
201
203
  if ("unmount" in root) {
202
204
  root.unmount();
203
205
  } else {
204
- console.warn("Root does not have unmount method");
206
+ index.LoggerInstance.warn("Root does not have unmount method");
205
207
  }
206
208
  rootMap.delete(dom);
207
209
  }
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
2
  import { Component, createElement, createContext } from "react";
3
- import { L as LoggerInstance, R as RouterContext } from "./index-rAO0Wr0M.mjs";
3
+ import { L as LoggerInstance, R as RouterContext } from "./index-DyQNwY2M.mjs";
4
4
  import { federationRuntime } from "./plugin.es.js";
5
5
  const ErrorBoundaryContext = createContext(null);
6
6
  const initialState = {
@@ -139,7 +139,7 @@ function createBaseBridgeComponent({
139
139
  ...rootOptions
140
140
  };
141
141
  const beforeBridgeRenderRes = ((_c = (_b = (_a = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.beforeBridgeRender) == null ? void 0 : _c.emit(info)) || {};
142
- const rootComponentWithErrorBoundary = /* @__PURE__ */ React.createElement(
142
+ const BridgeWrapper = ({ basename: basename2 }) => /* @__PURE__ */ React.createElement(
143
143
  ErrorBoundary,
144
144
  {
145
145
  FallbackComponent: fallback
@@ -149,16 +149,18 @@ function createBaseBridgeComponent({
149
149
  {
150
150
  appInfo: {
151
151
  moduleName,
152
- basename,
152
+ basename: basename2,
153
153
  memoryRoute
154
154
  },
155
155
  propsInfo: {
156
156
  ...propsInfo,
157
+ basename: basename2,
157
158
  ...beforeBridgeRenderRes == null ? void 0 : beforeBridgeRenderRes.extraProps
158
159
  }
159
160
  }
160
161
  )
161
162
  );
163
+ const rootComponentWithErrorBoundary = /* @__PURE__ */ React.createElement(BridgeWrapper, { basename });
162
164
  if (bridgeInfo.render) {
163
165
  await Promise.resolve(
164
166
  bridgeInfo.render(rootComponentWithErrorBoundary, dom)
@@ -184,7 +186,7 @@ function createBaseBridgeComponent({
184
186
  if ("unmount" in root) {
185
187
  root.unmount();
186
188
  } else {
187
- console.warn("Root does not have unmount method");
189
+ LoggerInstance.warn("Root does not have unmount method");
188
190
  }
189
191
  rootMap.delete(dom);
190
192
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
- const lazyUtils = require("./utils-vIpCrZmn.js");
3
- const index_esm = require("./index.esm-Ju4RY-yW.js");
2
+ const lazyUtils = require("./utils-tM9yE73c.js");
3
+ const index_esm = require("./index.esm-BWaKho-8.js");
4
4
  function wrapSetTimeout(targetPromise, delay = 2e4, id) {
5
5
  if (targetPromise && typeof targetPromise.then === "function") {
6
6
  return new Promise((resolve, reject) => {
@@ -1,5 +1,5 @@
1
- import { D as DATA_FETCH_QUERY, l as logger, g as getDataFetchMap, i as initDataFetchMap, M as MF_DATA_FETCH_STATUS, f as fetchData, a as loadDataFetchModule } from "./utils-VSOJTX_o.mjs";
2
- import { M as MANIFEST_EXT, S as SEPARATOR } from "./index.esm-CtI0uQUR.mjs";
1
+ import { D as DATA_FETCH_QUERY, l as logger, g as getDataFetchMap, i as initDataFetchMap, M as MF_DATA_FETCH_STATUS, f as fetchData, a as loadDataFetchModule } from "./utils-Bx_8GGd-.mjs";
2
+ import { M as MANIFEST_EXT, S as SEPARATOR } from "./index.esm-CPwSeCvw.mjs";
3
3
  function wrapSetTimeout(targetPromise, delay = 2e4, id) {
4
4
  if (targetPromise && typeof targetPromise.then === "function") {
5
5
  return new Promise((resolve, reject) => {
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const lazyUtils = require("./utils-vIpCrZmn.js");
4
- const prefetch = require("./prefetch-HjsWsmMr.js");
3
+ const lazyUtils = require("./utils-tM9yE73c.js");
4
+ const prefetch = require("./prefetch-C8kORtvg.js");
5
5
  async function callDataFetch() {
6
6
  const dataFetch = globalThis[lazyUtils.DATA_FETCH_FUNCTION];
7
7
  if (dataFetch) {
@@ -1,7 +1,7 @@
1
- import { x as DATA_FETCH_FUNCTION } from "./utils-VSOJTX_o.mjs";
2
- import { C, b, e, h, c, d, r } from "./utils-VSOJTX_o.mjs";
3
- import { d as dataFetchFunction } from "./prefetch-DtZwviM-.mjs";
4
- import { i, p } from "./prefetch-DtZwviM-.mjs";
1
+ import { x as DATA_FETCH_FUNCTION } from "./utils-Bx_8GGd-.mjs";
2
+ import { C, b, e, h, c, d, r } from "./utils-Bx_8GGd-.mjs";
3
+ import { d as dataFetchFunction } from "./prefetch-Cxo6GKct.mjs";
4
+ import { i, p } from "./prefetch-Cxo6GKct.mjs";
5
5
  async function callDataFetch() {
6
6
  const dataFetch = globalThis[DATA_FETCH_FUNCTION];
7
7
  if (dataFetch) {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  const React = require("react");
3
- const index_esm = require("./index.esm-Ju4RY-yW.js");
3
+ const index_esm = require("./index.esm-BWaKho-8.js");
4
4
  const RouterContext = React.createContext(null);
5
5
  const LoggerInstance = index_esm.createLogger(
6
6
  "[ Module Federation Bridge React ]"
@@ -1,5 +1,5 @@
1
1
  import React__default from "react";
2
- import { c as createLogger } from "./index.esm-CtI0uQUR.mjs";
2
+ import { c as createLogger } from "./index.esm-CPwSeCvw.mjs";
3
3
  const RouterContext = React__default.createContext(null);
4
4
  const LoggerInstance = createLogger(
5
5
  "[ Module Federation Bridge React ]"
package/dist/index.cjs.js CHANGED
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const bridgeBase = require("./bridge-base-Ds850AOx.js");
3
+ const bridgeBase = require("./bridge-base-B2malZDo.js");
4
4
  const ReactDOM = require("react-dom");
5
+ const index = require("./index-DRSBaSu3.js");
5
6
  const React = require("react");
6
- const index = require("./index-eN2xRRXs.js");
7
7
  const ReactRouterDOM = require("react-router-dom");
8
8
  const plugin = require("./plugin.cjs.js");
9
- const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-vtpWwn-P.js");
10
- const lazyUtils = require("./utils-vIpCrZmn.js");
9
+ const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-B-nqmULm.js");
10
+ const lazyUtils = require("./utils-tM9yE73c.js");
11
11
  const dataFetchUtils = require("./data-fetch-utils.cjs.js");
12
- const prefetch = require("./prefetch-HjsWsmMr.js");
12
+ const prefetch = require("./prefetch-C8kORtvg.js");
13
13
  function _interopNamespaceDefault(e2) {
14
14
  const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
15
15
  if (e2) {
@@ -39,7 +39,7 @@ function createReact16Or17Root(container) {
39
39
  );
40
40
  }
41
41
  if (isReact18) {
42
- console.warn(
42
+ index.LoggerInstance.warn(
43
43
  `[Bridge-React] React 18 detected in legacy mode. For better compatibility, please use the version-specific import: import { createBridgeComponent } from '@module-federation/bridge-react/v18'`
44
44
  );
45
45
  }
package/dist/index.es.js CHANGED
@@ -1,13 +1,13 @@
1
- import { c as createBaseBridgeComponent, E as ErrorBoundary } from "./bridge-base-BwHtOqw_.mjs";
1
+ import { c as createBaseBridgeComponent, E as ErrorBoundary } from "./bridge-base-DRFFglgm.mjs";
2
2
  import ReactDOM from "react-dom";
3
+ import { L as LoggerInstance, p as pathJoin, g as getRootDomDefaultClassName } from "./index-DyQNwY2M.mjs";
3
4
  import React__default, { forwardRef, useContext, useState, useEffect, useRef } from "react";
4
- import { p as pathJoin, L as LoggerInstance, g as getRootDomDefaultClassName } from "./index-rAO0Wr0M.mjs";
5
5
  import * as ReactRouterDOM from "react-router-dom";
6
6
  import { federationRuntime } from "./plugin.es.js";
7
- import { b, a, c, l } from "./lazy-load-component-plugin-Dmzr-hGo.mjs";
8
- import { C, b as b2, E, e, h, c as c2, d, r, s } from "./utils-VSOJTX_o.mjs";
7
+ import { b, a, c, l } from "./lazy-load-component-plugin-D_--Azke.mjs";
8
+ import { C, b as b2, E, e, h, c as c2, d, r, s } from "./utils-Bx_8GGd-.mjs";
9
9
  import { callDataFetch } from "./data-fetch-utils.es.js";
10
- import { p } from "./prefetch-DtZwviM-.mjs";
10
+ import { p } from "./prefetch-Cxo6GKct.mjs";
11
11
  function createReact16Or17Root(container) {
12
12
  return {
13
13
  render(children) {
@@ -20,7 +20,7 @@ function createReact16Or17Root(container) {
20
20
  );
21
21
  }
22
22
  if (isReact18) {
23
- console.warn(
23
+ LoggerInstance.warn(
24
24
  `[Bridge-React] React 18 detected in legacy mode. For better compatibility, please use the version-specific import: import { createBridgeComponent } from '@module-federation/bridge-react/v18'`
25
25
  );
26
26
  }
@@ -1,14 +1,4 @@
1
1
  "use strict";
2
- function _extends() {
3
- _extends = Object.assign || function assign(target) {
4
- for (var i = 1; i < arguments.length; i++) {
5
- var source = arguments[i];
6
- for (var key in source) if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
7
- }
8
- return target;
9
- };
10
- return _extends.apply(this, arguments);
11
- }
12
2
  const MANIFEST_EXT = ".json";
13
3
  const BROWSER_LOG_KEY = "FEDERATION_DEBUG";
14
4
  const SEPARATOR = ":";
@@ -52,40 +42,120 @@ const composeKeyWithSeparator = function(...args) {
52
42
  const warn = (msg) => {
53
43
  console.warn(`${LOG_CATEGORY}: ${msg}`);
54
44
  };
55
- let Logger = class Logger2 {
45
+ const PREFIX = "[ Module Federation ]";
46
+ const DEFAULT_DELEGATE = console;
47
+ const LOGGER_STACK_SKIP_TOKENS = [
48
+ "logger.ts",
49
+ "logger.js",
50
+ "captureStackTrace",
51
+ "Logger.emit",
52
+ "Logger.log",
53
+ "Logger.info",
54
+ "Logger.warn",
55
+ "Logger.error",
56
+ "Logger.debug"
57
+ ];
58
+ function captureStackTrace() {
59
+ try {
60
+ const stack = new Error().stack;
61
+ if (!stack) {
62
+ return void 0;
63
+ }
64
+ const [, ...rawLines] = stack.split("\n");
65
+ const filtered = rawLines.filter((line) => !LOGGER_STACK_SKIP_TOKENS.some((token) => line.includes(token)));
66
+ if (!filtered.length) {
67
+ return void 0;
68
+ }
69
+ const stackPreview = filtered.slice(0, 5).join("\n");
70
+ return `Stack trace:
71
+ ${stackPreview}`;
72
+ } catch {
73
+ return void 0;
74
+ }
75
+ }
76
+ class Logger {
77
+ constructor(prefix, delegate = DEFAULT_DELEGATE) {
78
+ this.prefix = prefix;
79
+ this.delegate = delegate ?? DEFAULT_DELEGATE;
80
+ }
56
81
  setPrefix(prefix) {
57
82
  this.prefix = prefix;
58
83
  }
84
+ setDelegate(delegate) {
85
+ this.delegate = delegate ?? DEFAULT_DELEGATE;
86
+ }
87
+ emit(method, args) {
88
+ const delegate = this.delegate;
89
+ const debugMode = isDebugMode();
90
+ const stackTrace = debugMode ? captureStackTrace() : void 0;
91
+ const enrichedArgs = stackTrace ? [...args, stackTrace] : args;
92
+ const order = (() => {
93
+ switch (method) {
94
+ case "log":
95
+ return ["log", "info"];
96
+ case "info":
97
+ return ["info", "log"];
98
+ case "warn":
99
+ return ["warn", "info", "log"];
100
+ case "error":
101
+ return ["error", "warn", "log"];
102
+ case "debug":
103
+ default:
104
+ return ["debug", "log"];
105
+ }
106
+ })();
107
+ for (const candidate of order) {
108
+ const handler = delegate[candidate];
109
+ if (typeof handler === "function") {
110
+ handler.call(delegate, this.prefix, ...enrichedArgs);
111
+ return;
112
+ }
113
+ }
114
+ for (const candidate of order) {
115
+ const handler = DEFAULT_DELEGATE[candidate];
116
+ if (typeof handler === "function") {
117
+ handler.call(DEFAULT_DELEGATE, this.prefix, ...enrichedArgs);
118
+ return;
119
+ }
120
+ }
121
+ }
59
122
  log(...args) {
60
- console.log(this.prefix, ...args);
123
+ this.emit("log", args);
61
124
  }
62
125
  warn(...args) {
63
- console.log(this.prefix, ...args);
126
+ this.emit("warn", args);
64
127
  }
65
128
  error(...args) {
66
- console.log(this.prefix, ...args);
129
+ this.emit("error", args);
67
130
  }
68
131
  success(...args) {
69
- console.log(this.prefix, ...args);
132
+ this.emit("info", args);
70
133
  }
71
134
  info(...args) {
72
- console.log(this.prefix, ...args);
135
+ this.emit("info", args);
73
136
  }
74
137
  ready(...args) {
75
- console.log(this.prefix, ...args);
138
+ this.emit("info", args);
76
139
  }
77
140
  debug(...args) {
78
141
  if (isDebugMode()) {
79
- console.log(this.prefix, ...args);
142
+ this.emit("debug", args);
80
143
  }
81
144
  }
82
- constructor(prefix) {
83
- this.prefix = prefix;
84
- }
85
- };
145
+ }
86
146
  function createLogger(prefix) {
87
147
  return new Logger(prefix);
88
148
  }
149
+ function createInfrastructureLogger(prefix) {
150
+ const infrastructureLogger = new Logger(prefix);
151
+ Object.defineProperty(infrastructureLogger, "__mf_infrastructure_logger__", {
152
+ value: true,
153
+ enumerable: false,
154
+ configurable: false
155
+ });
156
+ return infrastructureLogger;
157
+ }
158
+ createInfrastructureLogger(PREFIX);
89
159
  async function safeWrapper(callback, disableWarn) {
90
160
  try {
91
161
  const res2 = await callback();
@@ -185,10 +255,7 @@ function createScript(info) {
185
255
  timeoutId = setTimeout(() => {
186
256
  onScriptComplete(null, new Error(`Remote script "${info.url}" time-outed.`));
187
257
  }, timeout);
188
- return {
189
- script: script2,
190
- needAttach
191
- };
258
+ return { script: script2, needAttach };
192
259
  }
193
260
  function createLink(info) {
194
261
  let link = null;
@@ -250,10 +317,7 @@ function createLink(info) {
250
317
  };
251
318
  link.onerror = onLinkComplete.bind(null, link.onerror);
252
319
  link.onload = onLinkComplete.bind(null, link.onload);
253
- return {
254
- link,
255
- needAttach
256
- };
320
+ return { link, needAttach };
257
321
  }
258
322
  function loadScript(url2, info) {
259
323
  const { attrs: attrs2 = {}, createScriptHook } = info;
@@ -262,9 +326,10 @@ function loadScript(url2, info) {
262
326
  url: url2,
263
327
  cb: resolve,
264
328
  onErrorCallback: reject,
265
- attrs: _extends({
266
- fetchpriority: "high"
267
- }, attrs2),
329
+ attrs: {
330
+ fetchpriority: "high",
331
+ ...attrs2
332
+ },
268
333
  createScriptHook,
269
334
  needDeleteScript: true
270
335
  });
@@ -325,27 +390,24 @@ const createScriptNode = typeof ENV_TARGET === "undefined" || ENV_TARGET !== "we
325
390
  return typeof fetch === "undefined" ? loadNodeFetch() : fetch;
326
391
  };
327
392
  const handleScriptFetch = async (f, urlObj) => {
393
+ var _a;
328
394
  try {
329
- var _vm_constants;
330
395
  const res = await f(urlObj.href);
331
396
  const data = await res.text();
332
397
  const [path, vm] = await Promise.all([
333
398
  importNodeModule("path"),
334
399
  importNodeModule("vm")
335
400
  ]);
336
- const scriptContext = {
337
- exports: {},
338
- module: {
339
- exports: {}
340
- }
341
- };
401
+ const scriptContext = { exports: {}, module: { exports: {} } };
342
402
  const urlDirname = urlObj.pathname.split("/").slice(0, -1).join("/");
343
403
  const filename = path.basename(urlObj.pathname);
344
- var _vm_constants_USE_MAIN_CONTEXT_DEFAULT_LOADER;
345
404
  const script = new vm.Script(`(function(exports, module, require, __dirname, __filename) {${data}
346
405
  })`, {
347
406
  filename,
348
- importModuleDynamically: (_vm_constants_USE_MAIN_CONTEXT_DEFAULT_LOADER = (_vm_constants = vm.constants) == null ? void 0 : _vm_constants.USE_MAIN_CONTEXT_DEFAULT_LOADER) != null ? _vm_constants_USE_MAIN_CONTEXT_DEFAULT_LOADER : importNodeModule
407
+ importModuleDynamically: (
408
+ //@ts-ignore
409
+ ((_a = vm.constants) == null ? void 0 : _a.USE_MAIN_CONTEXT_DEFAULT_LOADER) ?? importNodeModule
410
+ )
349
411
  });
350
412
  script.runInThisContext()(scriptContext.exports, scriptContext.module, eval("require"), urlDirname, filename);
351
413
  const exportedInterface = scriptContext.module.exports || scriptContext.exports;
@@ -381,11 +443,11 @@ const createScriptNode = typeof ENV_TARGET === "undefined" || ENV_TARGET !== "we
381
443
  const loadScriptNode = typeof ENV_TARGET === "undefined" || ENV_TARGET !== "web" ? (url2, info) => {
382
444
  return new Promise((resolve, reject) => {
383
445
  createScriptNode(url2, (error, scriptContext2) => {
446
+ var _a, _b;
384
447
  if (error) {
385
448
  reject(error);
386
449
  } else {
387
- var _info_attrs, _info_attrs1;
388
- const remoteEntryKey = (info == null ? void 0 : (_info_attrs = info.attrs) == null ? void 0 : _info_attrs["globalName"]) || `__FEDERATION_${info == null ? void 0 : (_info_attrs1 = info.attrs) == null ? void 0 : _info_attrs1["name"]}:custom__`;
450
+ const remoteEntryKey = ((_a = info == null ? void 0 : info.attrs) == null ? void 0 : _a["globalName"]) || `__FEDERATION_${(_b = info == null ? void 0 : info.attrs) == null ? void 0 : _b["name"]}:custom__`;
389
451
  const entryExports = globalThis[remoteEntryKey] = scriptContext2;
390
452
  resolve(entryExports);
391
453
  }
@@ -399,8 +461,8 @@ async function loadModule(url2, options) {
399
461
  if (esmModuleCache.has(url2)) {
400
462
  return esmModuleCache.get(url2);
401
463
  }
402
- const { fetch: fetch1, vm: vm2 } = options;
403
- const response = await fetch1(url2);
464
+ const { fetch: fetch2, vm: vm2 } = options;
465
+ const response = await fetch2(url2);
404
466
  const code = await response.text();
405
467
  const module2 = new vm2.SourceTextModule(code, {
406
468
  // @ts-ignore