@module-federation/bridge-react 0.0.0-perf-devtools-20260108034446 → 0.0.0-perf-website-code-usage-20260914033703

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 (161) hide show
  1. package/dist/base.cjs.js +4 -4
  2. package/dist/base.d.ts +8 -311
  3. package/dist/base.es.js +11 -11
  4. package/dist/{bridge-base-CPSTBjEp.mjs → bridge-base-CHnL6Q9P.mjs} +63 -103
  5. package/dist/{bridge-base-RStDxH71.js → bridge-base-DSYKAGGD.js} +63 -102
  6. package/dist/{createHelpers-Ui5pt7je.mjs → createHelpers-D3Sg5lKp.mjs} +32 -17
  7. package/dist/{createHelpers-B_L612IN.js → createHelpers-D6thyyLv.js} +30 -15
  8. package/dist/data-fetch-server-middleware.cjs.js +4 -4
  9. package/dist/data-fetch-server-middleware.d.ts +1 -15
  10. package/dist/data-fetch-server-middleware.es.js +2 -2
  11. package/dist/data-fetch-utils.cjs.js +2 -2
  12. package/dist/data-fetch-utils.d.ts +1 -81
  13. package/dist/data-fetch-utils.es.js +7 -7
  14. package/dist/data-fetch.cjs.js +22 -0
  15. package/dist/data-fetch.d.ts +4 -0
  16. package/dist/data-fetch.es.js +22 -0
  17. package/dist/error-boundary.d.ts +17 -0
  18. package/dist/error-boundary.spec.d.ts +1 -0
  19. package/dist/{index-DyQNwY2M.mjs → index-Bs2NxD2z.mjs} +1 -1
  20. package/dist/{index-DRSBaSu3.js → index-DbjGCKOr.js} +2 -2
  21. package/dist/index.cjs.js +27 -6
  22. package/dist/index.d.ts +12 -299
  23. package/dist/index.es.js +34 -13
  24. package/dist/lazy/AwaitDataFetch.d.ts +24 -0
  25. package/dist/lazy/HydratedStylesheetAssets.d.ts +4 -0
  26. package/dist/lazy/constant.d.ts +26 -0
  27. package/dist/lazy/createLazyComponent.d.ts +28 -0
  28. package/dist/lazy/data-fetch/cache.d.ts +34 -0
  29. package/dist/lazy/data-fetch/cache.spec.d.ts +1 -0
  30. package/dist/lazy/data-fetch/call-data-fetch.d.ts +1 -0
  31. package/dist/lazy/data-fetch/data-fetch-server-middleware.d.ts +3 -0
  32. package/{src/lazy/data-fetch/index.ts → dist/lazy/data-fetch/index.d.ts} +1 -11
  33. package/dist/lazy/data-fetch/inject-data-fetch.d.ts +4 -0
  34. package/dist/lazy/data-fetch/prefetch.d.ts +9 -0
  35. package/dist/lazy/data-fetch/runtime-plugin.d.ts +3 -0
  36. package/dist/lazy/index.d.ts +9 -0
  37. package/dist/lazy/logger.d.ts +2 -0
  38. package/dist/lazy/types.d.ts +60 -0
  39. package/dist/lazy/utils.d.ts +48 -0
  40. package/dist/lazy/wrapNoSSR.d.ts +9 -0
  41. package/dist/{lazy-load-component-plugin-BvnyaA6i.js → lazy-load-component-plugin-DSURjnZ0.js} +170 -44
  42. package/dist/{lazy-load-component-plugin-CVcFMRce.mjs → lazy-load-component-plugin-NZphPG7_.mjs} +174 -48
  43. package/dist/lazy-load-component-plugin.cjs.js +2 -2
  44. package/dist/lazy-load-component-plugin.d.ts +2 -16
  45. package/dist/lazy-load-component-plugin.es.js +2 -2
  46. package/dist/lazy-utils.cjs.js +2 -2
  47. package/dist/lazy-utils.d.ts +1 -149
  48. package/dist/lazy-utils.es.js +19 -19
  49. package/dist/logger-DwWkXsWl.mjs +139 -0
  50. package/dist/logger-Dxblx6P-.js +138 -0
  51. package/dist/plugin.d.ts +2 -22
  52. package/dist/plugins/lazy-load-component-plugin.d.ts +12 -0
  53. package/dist/plugins/lazy-load-component-plugin.spec.d.ts +1 -0
  54. package/dist/prefetch-Bxf6DSx_.js +1477 -0
  55. package/dist/prefetch-TKq_EK_q.mjs +1478 -0
  56. package/dist/provider/context.d.ts +3 -0
  57. package/dist/provider/plugin.d.ts +7 -0
  58. package/dist/provider/versions/bridge-base.d.ts +5 -0
  59. package/dist/provider/versions/legacy.d.ts +26 -0
  60. package/dist/provider/versions/v18.d.ts +19 -0
  61. package/dist/provider/versions/v19.d.ts +21 -0
  62. package/dist/remote/RemoteAppWrapper.d.ts +7 -0
  63. package/dist/remote/base-component/create.d.ts +9 -0
  64. package/dist/remote/base-component/index.d.ts +5 -0
  65. package/dist/remote/createHelpers.d.ts +17 -0
  66. package/dist/remote/router-component/component.d.ts +8 -0
  67. package/dist/remote/router-component/create.d.ts +9 -0
  68. package/dist/remote/router-component/index.d.ts +5 -0
  69. package/dist/router/default.d.ts +7 -0
  70. package/dist/router/v5.d.ts +4 -0
  71. package/dist/router/v6.d.ts +7 -0
  72. package/dist/router/v7.d.ts +6 -0
  73. package/dist/router-v5.cjs.js +5 -3
  74. package/dist/router-v5.d.ts +1 -18
  75. package/dist/router-v5.es.js +5 -3
  76. package/dist/router-v6.cjs.js +1 -1
  77. package/dist/router-v6.d.ts +1 -20
  78. package/dist/router-v6.es.js +1 -1
  79. package/dist/router-v7.cjs.js +5 -3
  80. package/dist/router-v7.d.ts +1 -20
  81. package/dist/router-v7.es.js +5 -3
  82. package/dist/router.cjs.js +1 -1
  83. package/dist/router.d.ts +1 -20
  84. package/dist/router.es.js +1 -1
  85. package/dist/shared/size-limited-cache.d.ts +29 -0
  86. package/dist/shared/size-limited-cache.spec.d.ts +1 -0
  87. package/dist/size-limited-cache.cjs.js +82 -0
  88. package/dist/size-limited-cache.d.ts +1 -0
  89. package/dist/size-limited-cache.es.js +82 -0
  90. package/dist/types.d.ts +137 -0
  91. package/dist/utils/index.d.ts +4 -0
  92. package/dist/utils-5dGErM3C.js +588 -0
  93. package/dist/utils-BBP3hEeV.mjs +589 -0
  94. package/dist/v18.cjs.js +1 -1
  95. package/dist/v18.d.ts +3 -114
  96. package/dist/v18.es.js +1 -1
  97. package/dist/v19.cjs.js +1 -1
  98. package/dist/v19.d.ts +3 -115
  99. package/dist/v19.es.js +1 -1
  100. package/package.json +35 -14
  101. package/CHANGELOG.md +0 -735
  102. package/__tests__/bridge.spec.tsx +0 -160
  103. package/__tests__/createLazyComponent.spec.tsx +0 -209
  104. package/__tests__/prefetch.spec.ts +0 -156
  105. package/__tests__/router.spec.tsx +0 -82
  106. package/__tests__/setupTests.ts +0 -8
  107. package/__tests__/util.ts +0 -36
  108. package/dist/index.esm-BWaKho-8.js +0 -491
  109. package/dist/index.esm-CPwSeCvw.mjs +0 -492
  110. package/dist/prefetch-CK3EZdY4.mjs +0 -1273
  111. package/dist/prefetch-MiXeF8KH.js +0 -1272
  112. package/dist/utils-dUgb9Jkm.mjs +0 -2016
  113. package/dist/utils-tM9yE73c.js +0 -2015
  114. package/jest.config.ts +0 -21
  115. package/project.json +0 -23
  116. package/src/base.ts +0 -50
  117. package/src/index.ts +0 -50
  118. package/src/lazy/AwaitDataFetch.tsx +0 -215
  119. package/src/lazy/constant.ts +0 -30
  120. package/src/lazy/createLazyComponent.tsx +0 -411
  121. package/src/lazy/data-fetch/cache.ts +0 -291
  122. package/src/lazy/data-fetch/call-data-fetch.ts +0 -13
  123. package/src/lazy/data-fetch/data-fetch-server-middleware.ts +0 -196
  124. package/src/lazy/data-fetch/inject-data-fetch.ts +0 -109
  125. package/src/lazy/data-fetch/prefetch.ts +0 -112
  126. package/src/lazy/data-fetch/runtime-plugin.ts +0 -115
  127. package/src/lazy/index.ts +0 -35
  128. package/src/lazy/logger.ts +0 -6
  129. package/src/lazy/types.ts +0 -75
  130. package/src/lazy/utils.ts +0 -372
  131. package/src/lazy/wrapNoSSR.tsx +0 -10
  132. package/src/modern-app-env.d.ts +0 -2
  133. package/src/plugins/lazy-load-component-plugin.spec.ts +0 -21
  134. package/src/plugins/lazy-load-component-plugin.ts +0 -57
  135. package/src/provider/context.tsx +0 -4
  136. package/src/provider/plugin.ts +0 -22
  137. package/src/provider/versions/bridge-base.tsx +0 -150
  138. package/src/provider/versions/legacy.ts +0 -87
  139. package/src/provider/versions/v18.ts +0 -47
  140. package/src/provider/versions/v19.ts +0 -48
  141. package/src/remote/RemoteAppWrapper.tsx +0 -108
  142. package/src/remote/base-component/create.tsx +0 -23
  143. package/src/remote/base-component/index.tsx +0 -10
  144. package/src/remote/createHelpers.tsx +0 -130
  145. package/src/remote/router-component/component.tsx +0 -104
  146. package/src/remote/router-component/create.tsx +0 -23
  147. package/src/remote/router-component/index.tsx +0 -10
  148. package/src/router/default.tsx +0 -73
  149. package/src/router/v5.tsx +0 -43
  150. package/src/router/v6.tsx +0 -74
  151. package/src/router/v7.tsx +0 -75
  152. package/src/types.ts +0 -147
  153. package/src/utils/index.ts +0 -44
  154. package/src/v18.ts +0 -9
  155. package/src/v19.ts +0 -9
  156. package/tsconfig.json +0 -42
  157. package/tsconfig.node.json +0 -11
  158. package/tsconfig.spec.json +0 -26
  159. package/vite.config.ts +0 -112
  160. package/vitest.config.ts +0 -27
  161. /package/{src/remote/base-component/component.tsx → dist/remote/base-component/component.d.ts} +0 -0
@@ -1,5 +1,5 @@
1
- import { l, l as l2 } from "./lazy-load-component-plugin-CVcFMRce.mjs";
2
- import "./prefetch-CK3EZdY4.mjs";
1
+ import { l, l as l2 } from "./lazy-load-component-plugin-NZphPG7_.mjs";
2
+ import "./prefetch-TKq_EK_q.mjs";
3
3
  export {
4
4
  l as default,
5
5
  l2 as lazyLoadComponentPlugin
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- require("./index.esm-BWaKho-8.js");
4
- const lazyUtils = require("./utils-tM9yE73c.js");
3
+ require("./logger-Dxblx6P-.js");
4
+ const lazyUtils = require("./utils-5dGErM3C.js");
5
5
  exports.callAllDowngrade = lazyUtils.callAllDowngrade;
6
6
  exports.callDowngrade = lazyUtils.callDowngrade;
7
7
  exports.fetchData = lazyUtils.fetchData;
@@ -1,149 +1 @@
1
- import { GlobalModuleInfo } from '@module-federation/sdk';
2
- import { LRUCache } from 'lru-cache';
3
- import { ManifestProvider } from '@module-federation/sdk';
4
- import { ModuleFederation } from '@module-federation/runtime';
5
- import { ModuleInfo } from '@module-federation/sdk';
6
- import { PureEntryProvider } from '@module-federation/sdk';
7
- import { RemoteEntryType } from '@module-federation/sdk';
8
-
9
- declare interface CacheConfig {
10
- maxSize?: number;
11
- unstable_shouldDisable?: ({ request, }: {
12
- request: Request;
13
- }) => boolean | Promise<boolean>;
14
- }
15
-
16
- declare interface CacheItem<T> {
17
- data: T;
18
- timestamp: number;
19
- isRevalidating?: boolean;
20
- }
21
-
22
- export declare function callAllDowngrade(): void;
23
-
24
- export declare function callDowngrade(id: string, params?: DataFetchParams, remoteInfo?: NoSSRRemoteInfo): Promise<unknown>;
25
-
26
- declare type DataFetch<T> = (params: DataFetchParams) => Promise<T>;
27
-
28
- declare type DataFetchParams = {
29
- isDowngrade: boolean;
30
- _id?: string;
31
- } & Record<string, unknown>;
32
-
33
- export declare function fetchData(id: string, params: DataFetchParams, remoteInfo?: NoSSRRemoteInfo): Promise<unknown | undefined>;
34
-
35
- export declare const flushDataFetch: () => void;
36
-
37
- export declare function getDataFetchCache(): MF_DATA_FETCH_CACHE;
38
-
39
- export declare const getDataFetchIdWithErrorMsgs: (errMsgs: string) => string | undefined;
40
-
41
- export declare const getDataFetchInfo: ({ name, alias, id, remoteSnapshot, }: {
42
- id: string;
43
- name: string;
44
- remoteSnapshot: GlobalModuleInfo[string];
45
- alias?: string;
46
- }) => {
47
- dataFetchName: string;
48
- dataFetchId: string;
49
- dataFetchKey: string;
50
- } | undefined;
51
-
52
- export declare function getDataFetchItem(id: string): MF_DATA_FETCH_MAP_VALUE;
53
-
54
- export declare function getDataFetchMap(): MF_DATA_FETCH_MAP;
55
-
56
- export declare function getDataFetchMapKey(dataFetchInfo?: ReturnType<typeof getDataFetchInfo>, hostInfo?: {
57
- name: string;
58
- version?: string;
59
- }): string | undefined;
60
-
61
- export declare function getDowngradeTag(): MF_SSR_DOWNGRADE;
62
-
63
- export declare function getLoadedRemoteInfos(id: string, instance: ModuleFederation | null): {
64
- snapshot: ModuleInfo | ManifestProvider | PureEntryProvider | undefined;
65
- expose: string;
66
- alias?: string;
67
- name: string;
68
- version?: string;
69
- buildVersion?: string;
70
- entry: string;
71
- type: RemoteEntryType;
72
- entryGlobalName: string;
73
- shareScope: string | string[];
74
- } | undefined;
75
-
76
- export declare function initDataFetchMap(): void;
77
-
78
- export declare function isCSROnly(): boolean;
79
-
80
- export declare function isDataLoaderExpose(exposeKey: string): boolean;
81
-
82
- export declare function isServerEnv(): boolean;
83
-
84
- export declare function loadDataFetchModule(instance: ModuleFederation, id: string): Promise<(params: DataFetchParams) => Promise<unknown>>;
85
-
86
- declare type MF_DATA_FETCH_CACHE = {
87
- cacheStore?: LRUCache<string, Map<string, CacheItem<any>>>;
88
- tagKeyMap?: Map<string, Set<string>>;
89
- cacheConfig?: CacheConfig;
90
- };
91
-
92
- declare type MF_DATA_FETCH_MAP = Record<string, MF_DATA_FETCH_MAP_VALUE>;
93
-
94
- declare type MF_DATA_FETCH_MAP_VALUE = [
95
- [
96
- () => Promise<DataFetch<unknown>>,
97
- MF_DATA_FETCH_TYPE,
98
- Promise<DataFetch<unknown>>?
99
- ],
100
- MF_DATA_FETCH_MAP_VALUE_PROMISE_SET?,
101
- MF_DATA_FETCH_STATUS?
102
- ];
103
-
104
- declare type MF_DATA_FETCH_MAP_VALUE_PROMISE_SET = [
105
- Promise<unknown>,
106
- ((data: unknown) => void)?,
107
- ((err: unknown) => void)?
108
- ];
109
-
110
- declare const enum MF_DATA_FETCH_STATUS {
111
- LOADED = 1,
112
- LOADING = 2,
113
- AWAIT = 0,
114
- ERROR = 3
115
- }
116
-
117
- declare const enum MF_DATA_FETCH_TYPE {
118
- FETCH_SERVER = 1,
119
- FETCH_CLIENT = 2
120
- }
121
-
122
- declare type MF_SSR_DOWNGRADE = string[] | true | undefined;
123
-
124
- declare type NoSSRRemoteInfo = {
125
- name: string;
126
- version: string;
127
- ssrPublicPath: string;
128
- ssrRemoteEntry: string;
129
- globalName: string;
130
- };
131
-
132
- export declare function setDataFetchItemLoadedStatus(id: string): void;
133
-
134
- export declare function setSSREnv({ fetchServerQuery, }: {
135
- fetchServerQuery?: Record<string, unknown>;
136
- }): void;
137
-
138
- export declare const wrapDataFetchId: (id?: string) => string;
139
-
140
- export { }
141
-
142
-
143
- declare module '@module-federation/runtime-core' {
144
- interface ModuleFederation {
145
- createLazyComponent<T, E extends keyof T>(options: Omit<CreateLazyComponentOptions<T, E>, 'instance'>): ReturnType<typeof createLazyComponent<T, E>>;
146
- prefetch(options: Omit<PrefetchOptions, 'instance'>): ReturnType<typeof prefetch>;
147
- collectSSRAssets(options: Omit<Parameters<typeof collectSSRAssets>[0], 'instance'>): ReturnType<typeof collectSSRAssets>;
148
- }
149
- }
1
+ export * from './lazy/utils';
@@ -1,24 +1,24 @@
1
- import "./index.esm-CPwSeCvw.mjs";
2
- import { G, H, f, J, I, u, k, n, e, m, B, y, i, q, j, t, h, z, s, w } from "./utils-dUgb9Jkm.mjs";
1
+ import "./logger-DwWkXsWl.mjs";
2
+ import { H, I, h, f, O, v, m, o, e, n, J, z, i, t, k, u, j, A, s, x } from "./utils-BBP3hEeV.mjs";
3
3
  export {
4
- G as callAllDowngrade,
5
- H as callDowngrade,
6
- f as fetchData,
7
- J as flushDataFetch,
8
- I as getDataFetchCache,
9
- u as getDataFetchIdWithErrorMsgs,
10
- k as getDataFetchInfo,
11
- n as getDataFetchItem,
4
+ H as callAllDowngrade,
5
+ I as callDowngrade,
6
+ h as fetchData,
7
+ f as flushDataFetch,
8
+ O as getDataFetchCache,
9
+ v as getDataFetchIdWithErrorMsgs,
10
+ m as getDataFetchInfo,
11
+ o as getDataFetchItem,
12
12
  e as getDataFetchMap,
13
- m as getDataFetchMapKey,
14
- B as getDowngradeTag,
15
- y as getLoadedRemoteInfos,
13
+ n as getDataFetchMapKey,
14
+ J as getDowngradeTag,
15
+ z as getLoadedRemoteInfos,
16
16
  i as initDataFetchMap,
17
- q as isCSROnly,
18
- j as isDataLoaderExpose,
19
- t as isServerEnv,
20
- h as loadDataFetchModule,
21
- z as setDataFetchItemLoadedStatus,
17
+ t as isCSROnly,
18
+ k as isDataLoaderExpose,
19
+ u as isServerEnv,
20
+ j as loadDataFetchModule,
21
+ A as setDataFetchItemLoadedStatus,
22
22
  s as setSSREnv,
23
- w as wrapDataFetchId
23
+ x as wrapDataFetchId
24
24
  };
@@ -0,0 +1,139 @@
1
+ const MANIFEST_EXT = ".json";
2
+ const BROWSER_LOG_KEY = "FEDERATION_DEBUG";
3
+ const SEPARATOR = ":";
4
+ const isBrowserEnvValue = typeof ENV_TARGET !== "undefined" ? ENV_TARGET === "web" : typeof window !== "undefined" && typeof window.document !== "undefined";
5
+ function isBrowserEnv() {
6
+ return isBrowserEnvValue;
7
+ }
8
+ function isBrowserDebug() {
9
+ try {
10
+ if (isBrowserEnv() && window.localStorage) return Boolean(localStorage.getItem(BROWSER_LOG_KEY));
11
+ } catch (error) {
12
+ return false;
13
+ }
14
+ return false;
15
+ }
16
+ function isDebugMode() {
17
+ if (typeof process !== "undefined" && process.env && process.env["FEDERATION_DEBUG"]) return Boolean(process.env["FEDERATION_DEBUG"]);
18
+ if (typeof FEDERATION_DEBUG !== "undefined" && Boolean(FEDERATION_DEBUG)) return true;
19
+ return isBrowserDebug();
20
+ }
21
+ const PREFIX = "[ Module Federation ]";
22
+ const DEFAULT_DELEGATE = console;
23
+ const LOGGER_STACK_SKIP_TOKENS = [
24
+ "logger.ts",
25
+ "logger.js",
26
+ "captureStackTrace",
27
+ "Logger.emit",
28
+ "Logger.log",
29
+ "Logger.info",
30
+ "Logger.warn",
31
+ "Logger.error",
32
+ "Logger.debug"
33
+ ];
34
+ function captureStackTrace() {
35
+ try {
36
+ const stack = (/* @__PURE__ */ new Error()).stack;
37
+ if (!stack) return;
38
+ const [, ...rawLines] = stack.split("\n");
39
+ const filtered = rawLines.filter((line) => !LOGGER_STACK_SKIP_TOKENS.some((token) => line.includes(token)));
40
+ if (!filtered.length) return;
41
+ return `Stack trace:
42
+ ${filtered.slice(0, 5).join("\n")}`;
43
+ } catch {
44
+ return;
45
+ }
46
+ }
47
+ var Logger = class {
48
+ constructor(prefix, delegate = DEFAULT_DELEGATE) {
49
+ this.prefix = prefix;
50
+ this.delegate = delegate ?? DEFAULT_DELEGATE;
51
+ }
52
+ setPrefix(prefix) {
53
+ this.prefix = prefix;
54
+ }
55
+ setDelegate(delegate) {
56
+ this.delegate = delegate ?? DEFAULT_DELEGATE;
57
+ }
58
+ emit(method, args) {
59
+ const delegate = this.delegate;
60
+ const stackTrace = isDebugMode() ? captureStackTrace() : void 0;
61
+ const enrichedArgs = stackTrace ? [...args, stackTrace] : args;
62
+ const order = (() => {
63
+ switch (method) {
64
+ case "log":
65
+ return ["log", "info"];
66
+ case "info":
67
+ return ["info", "log"];
68
+ case "warn":
69
+ return [
70
+ "warn",
71
+ "info",
72
+ "log"
73
+ ];
74
+ case "error":
75
+ return [
76
+ "error",
77
+ "warn",
78
+ "log"
79
+ ];
80
+ default:
81
+ return ["debug", "log"];
82
+ }
83
+ })();
84
+ for (const candidate of order) {
85
+ const handler = delegate[candidate];
86
+ if (typeof handler === "function") {
87
+ handler.call(delegate, this.prefix, ...enrichedArgs);
88
+ return;
89
+ }
90
+ }
91
+ for (const candidate of order) {
92
+ const handler = DEFAULT_DELEGATE[candidate];
93
+ if (typeof handler === "function") {
94
+ handler.call(DEFAULT_DELEGATE, this.prefix, ...enrichedArgs);
95
+ return;
96
+ }
97
+ }
98
+ }
99
+ log(...args) {
100
+ this.emit("log", args);
101
+ }
102
+ warn(...args) {
103
+ this.emit("warn", args);
104
+ }
105
+ error(...args) {
106
+ this.emit("error", args);
107
+ }
108
+ success(...args) {
109
+ this.emit("info", args);
110
+ }
111
+ info(...args) {
112
+ this.emit("info", args);
113
+ }
114
+ ready(...args) {
115
+ this.emit("info", args);
116
+ }
117
+ debug(...args) {
118
+ if (isDebugMode()) this.emit("debug", args);
119
+ }
120
+ };
121
+ function createLogger(prefix) {
122
+ return new Logger(prefix);
123
+ }
124
+ function createInfrastructureLogger(prefix) {
125
+ const infrastructureLogger = new Logger(prefix);
126
+ Object.defineProperty(infrastructureLogger, "__mf_infrastructure_logger__", {
127
+ value: true,
128
+ enumerable: false,
129
+ configurable: false
130
+ });
131
+ return infrastructureLogger;
132
+ }
133
+ createInfrastructureLogger(PREFIX);
134
+ export {
135
+ MANIFEST_EXT as M,
136
+ SEPARATOR as S,
137
+ createLogger as c,
138
+ isBrowserEnvValue as i
139
+ };
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+ const MANIFEST_EXT = ".json";
3
+ const BROWSER_LOG_KEY = "FEDERATION_DEBUG";
4
+ const SEPARATOR = ":";
5
+ const isBrowserEnvValue = typeof ENV_TARGET !== "undefined" ? ENV_TARGET === "web" : typeof window !== "undefined" && typeof window.document !== "undefined";
6
+ function isBrowserEnv() {
7
+ return isBrowserEnvValue;
8
+ }
9
+ function isBrowserDebug() {
10
+ try {
11
+ if (isBrowserEnv() && window.localStorage) return Boolean(localStorage.getItem(BROWSER_LOG_KEY));
12
+ } catch (error) {
13
+ return false;
14
+ }
15
+ return false;
16
+ }
17
+ function isDebugMode() {
18
+ if (typeof process !== "undefined" && process.env && process.env["FEDERATION_DEBUG"]) return Boolean(process.env["FEDERATION_DEBUG"]);
19
+ if (typeof FEDERATION_DEBUG !== "undefined" && Boolean(FEDERATION_DEBUG)) return true;
20
+ return isBrowserDebug();
21
+ }
22
+ const PREFIX = "[ Module Federation ]";
23
+ const DEFAULT_DELEGATE = console;
24
+ const LOGGER_STACK_SKIP_TOKENS = [
25
+ "logger.ts",
26
+ "logger.js",
27
+ "captureStackTrace",
28
+ "Logger.emit",
29
+ "Logger.log",
30
+ "Logger.info",
31
+ "Logger.warn",
32
+ "Logger.error",
33
+ "Logger.debug"
34
+ ];
35
+ function captureStackTrace() {
36
+ try {
37
+ const stack = (/* @__PURE__ */ new Error()).stack;
38
+ if (!stack) return;
39
+ const [, ...rawLines] = stack.split("\n");
40
+ const filtered = rawLines.filter((line) => !LOGGER_STACK_SKIP_TOKENS.some((token) => line.includes(token)));
41
+ if (!filtered.length) return;
42
+ return `Stack trace:
43
+ ${filtered.slice(0, 5).join("\n")}`;
44
+ } catch {
45
+ return;
46
+ }
47
+ }
48
+ var Logger = class {
49
+ constructor(prefix, delegate = DEFAULT_DELEGATE) {
50
+ this.prefix = prefix;
51
+ this.delegate = delegate ?? DEFAULT_DELEGATE;
52
+ }
53
+ setPrefix(prefix) {
54
+ this.prefix = prefix;
55
+ }
56
+ setDelegate(delegate) {
57
+ this.delegate = delegate ?? DEFAULT_DELEGATE;
58
+ }
59
+ emit(method, args) {
60
+ const delegate = this.delegate;
61
+ const stackTrace = isDebugMode() ? captureStackTrace() : void 0;
62
+ const enrichedArgs = stackTrace ? [...args, stackTrace] : args;
63
+ const order = (() => {
64
+ switch (method) {
65
+ case "log":
66
+ return ["log", "info"];
67
+ case "info":
68
+ return ["info", "log"];
69
+ case "warn":
70
+ return [
71
+ "warn",
72
+ "info",
73
+ "log"
74
+ ];
75
+ case "error":
76
+ return [
77
+ "error",
78
+ "warn",
79
+ "log"
80
+ ];
81
+ default:
82
+ return ["debug", "log"];
83
+ }
84
+ })();
85
+ for (const candidate of order) {
86
+ const handler = delegate[candidate];
87
+ if (typeof handler === "function") {
88
+ handler.call(delegate, this.prefix, ...enrichedArgs);
89
+ return;
90
+ }
91
+ }
92
+ for (const candidate of order) {
93
+ const handler = DEFAULT_DELEGATE[candidate];
94
+ if (typeof handler === "function") {
95
+ handler.call(DEFAULT_DELEGATE, this.prefix, ...enrichedArgs);
96
+ return;
97
+ }
98
+ }
99
+ }
100
+ log(...args) {
101
+ this.emit("log", args);
102
+ }
103
+ warn(...args) {
104
+ this.emit("warn", args);
105
+ }
106
+ error(...args) {
107
+ this.emit("error", args);
108
+ }
109
+ success(...args) {
110
+ this.emit("info", args);
111
+ }
112
+ info(...args) {
113
+ this.emit("info", args);
114
+ }
115
+ ready(...args) {
116
+ this.emit("info", args);
117
+ }
118
+ debug(...args) {
119
+ if (isDebugMode()) this.emit("debug", args);
120
+ }
121
+ };
122
+ function createLogger(prefix) {
123
+ return new Logger(prefix);
124
+ }
125
+ function createInfrastructureLogger(prefix) {
126
+ const infrastructureLogger = new Logger(prefix);
127
+ Object.defineProperty(infrastructureLogger, "__mf_infrastructure_logger__", {
128
+ value: true,
129
+ enumerable: false,
130
+ configurable: false
131
+ });
132
+ return infrastructureLogger;
133
+ }
134
+ createInfrastructureLogger(PREFIX);
135
+ exports.MANIFEST_EXT = MANIFEST_EXT;
136
+ exports.SEPARATOR = SEPARATOR;
137
+ exports.createLogger = createLogger;
138
+ exports.isBrowserEnvValue = isBrowserEnvValue;
package/dist/plugin.d.ts CHANGED
@@ -1,22 +1,2 @@
1
- import { ModuleFederation } from '@module-federation/runtime';
2
- import { ModuleFederationRuntimePlugin } from '@module-federation/runtime';
3
-
4
- declare function BridgeReactPlugin(): ModuleFederationRuntimePlugin;
5
- export default BridgeReactPlugin;
6
-
7
- export declare const federationRuntime: FederationRuntimeType;
8
-
9
- export declare type FederationRuntimeType = {
10
- instance: ModuleFederation | null;
11
- };
12
-
13
- export { }
14
-
15
-
16
- declare module '@module-federation/runtime-core' {
17
- interface ModuleFederation {
18
- createLazyComponent<T, E extends keyof T>(options: Omit<CreateLazyComponentOptions<T, E>, 'instance'>): ReturnType<typeof createLazyComponent<T, E>>;
19
- prefetch(options: Omit<PrefetchOptions, 'instance'>): ReturnType<typeof prefetch>;
20
- collectSSRAssets(options: Omit<Parameters<typeof collectSSRAssets>[0], 'instance'>): ReturnType<typeof collectSSRAssets>;
21
- }
22
- }
1
+ export { default } from './provider/plugin';
2
+ export * from './provider/plugin';
@@ -0,0 +1,12 @@
1
+ import type { ModuleFederationRuntimePlugin } from '@module-federation/runtime';
2
+ import { createLazyComponent, prefetch, collectSSRAssets } from '../lazy';
3
+ import type { CreateLazyComponentOptions, PrefetchOptions } from '../lazy';
4
+ declare module '@module-federation/runtime-core' {
5
+ interface ModuleFederation {
6
+ createLazyComponent<T, E extends keyof T>(options: Omit<CreateLazyComponentOptions<T, E>, 'instance'>): ReturnType<typeof createLazyComponent<T, E>>;
7
+ prefetch(options: Omit<PrefetchOptions, 'instance'>): ReturnType<typeof prefetch>;
8
+ collectSSRAssets(options: Omit<Parameters<typeof collectSSRAssets>[0], 'instance'>): ReturnType<typeof collectSSRAssets>;
9
+ }
10
+ }
11
+ export declare function lazyLoadComponentPlugin(): ModuleFederationRuntimePlugin;
12
+ export default lazyLoadComponentPlugin;
@@ -0,0 +1 @@
1
+ export {};