@module-federation/modern-js 0.0.0-next-20250526025159 → 0.0.0-next-20250526035905

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 (82) hide show
  1. package/dist/cjs/cli/configPlugin.js +6 -8
  2. package/dist/cjs/cli/configPlugin.spec.js +1 -3
  3. package/dist/cjs/{runtime/wrapNoSSR.js → cli/constant.js} +6 -13
  4. package/dist/cjs/{logger.js → cli/logger.js} +1 -1
  5. package/dist/cjs/cli/ssrPlugin.js +11 -27
  6. package/dist/cjs/cli/utils.js +0 -5
  7. package/dist/cjs/constant.js +2 -49
  8. package/dist/cjs/runtime/createRemoteSSRComponent.js +210 -0
  9. package/dist/cjs/runtime/index.js +2 -11
  10. package/dist/cjs/{interfaces/global.js → ssr-runtime/index.js} +8 -2
  11. package/dist/cjs/ssr-runtime/{devPlugin.js → plugin.js} +6 -9
  12. package/dist/esm/cli/configPlugin.js +7 -9
  13. package/dist/esm/cli/configPlugin.spec.js +1 -3
  14. package/dist/esm/cli/constant.js +4 -0
  15. package/dist/esm/{logger.js → cli/logger.js} +1 -1
  16. package/dist/esm/cli/ssrPlugin.js +7 -24
  17. package/dist/esm/cli/utils.js +0 -4
  18. package/dist/esm/constant.js +1 -37
  19. package/dist/esm/runtime/createRemoteSSRComponent.js +263 -0
  20. package/dist/esm/runtime/index.js +2 -10
  21. package/dist/esm/ssr-runtime/index.js +1 -0
  22. package/dist/esm/ssr-runtime/{devPlugin.js → plugin.js} +2 -5
  23. package/dist/esm-node/cli/configPlugin.js +7 -9
  24. package/dist/esm-node/cli/configPlugin.spec.js +1 -3
  25. package/dist/esm-node/cli/constant.js +4 -0
  26. package/dist/esm-node/{logger.js → cli/logger.js} +1 -1
  27. package/dist/esm-node/cli/ssrPlugin.js +7 -23
  28. package/dist/esm-node/cli/utils.js +0 -4
  29. package/dist/esm-node/constant.js +1 -37
  30. package/dist/esm-node/runtime/createRemoteSSRComponent.js +175 -0
  31. package/dist/esm-node/runtime/index.js +2 -10
  32. package/dist/esm-node/ssr-runtime/index.js +1 -0
  33. package/dist/esm-node/ssr-runtime/{devPlugin.js → plugin.js} +2 -5
  34. package/dist/types/cli/constant.d.ts +1 -0
  35. package/dist/types/cli/index.d.ts +0 -1
  36. package/dist/types/cli/utils.d.ts +0 -1
  37. package/dist/types/constant.d.ts +0 -23
  38. package/dist/types/runtime/createRemoteSSRComponent.d.ts +19 -0
  39. package/dist/types/runtime/index.d.ts +2 -6
  40. package/dist/types/ssr-runtime/index.d.ts +1 -0
  41. package/dist/types/ssr-runtime/plugin.d.ts +2 -0
  42. package/package.json +17 -41
  43. package/dist/cjs/cli/mfRuntimePlugins/auto-fetch-data.js +0 -98
  44. package/dist/cjs/cli/server/data-fetch-server-plugin.js +0 -192
  45. package/dist/cjs/runtime/AwaitDataFetch.js +0 -144
  46. package/dist/cjs/runtime/createRemoteComponent.js +0 -327
  47. package/dist/cjs/ssr-runtime/downgrade.js +0 -108
  48. package/dist/cjs/ssr-runtime/injectDataFetchFunctionPlugin.js +0 -128
  49. package/dist/cjs/utils/dataFetch.js +0 -211
  50. package/dist/cjs/utils/index.js +0 -54
  51. package/dist/esm/cli/mfRuntimePlugins/auto-fetch-data.js +0 -74
  52. package/dist/esm/cli/server/data-fetch-server-plugin.js +0 -240
  53. package/dist/esm/interfaces/global.js +0 -0
  54. package/dist/esm/runtime/AwaitDataFetch.js +0 -131
  55. package/dist/esm/runtime/createRemoteComponent.js +0 -417
  56. package/dist/esm/runtime/wrapNoSSR.js +0 -12
  57. package/dist/esm/ssr-runtime/downgrade.js +0 -143
  58. package/dist/esm/ssr-runtime/injectDataFetchFunctionPlugin.js +0 -168
  59. package/dist/esm/utils/dataFetch.js +0 -237
  60. package/dist/esm/utils/index.js +0 -28
  61. package/dist/esm-node/cli/mfRuntimePlugins/auto-fetch-data.js +0 -68
  62. package/dist/esm-node/cli/server/data-fetch-server-plugin.js +0 -162
  63. package/dist/esm-node/interfaces/global.js +0 -0
  64. package/dist/esm-node/runtime/AwaitDataFetch.js +0 -109
  65. package/dist/esm-node/runtime/createRemoteComponent.js +0 -291
  66. package/dist/esm-node/runtime/wrapNoSSR.js +0 -11
  67. package/dist/esm-node/ssr-runtime/downgrade.js +0 -82
  68. package/dist/esm-node/ssr-runtime/injectDataFetchFunctionPlugin.js +0 -94
  69. package/dist/esm-node/utils/dataFetch.js +0 -166
  70. package/dist/esm-node/utils/index.js +0 -27
  71. package/dist/types/cli/mfRuntimePlugins/auto-fetch-data.d.ts +0 -3
  72. package/dist/types/cli/server/data-fetch-server-plugin.d.ts +0 -3
  73. package/dist/types/interfaces/global.d.ts +0 -27
  74. package/dist/types/runtime/AwaitDataFetch.d.ts +0 -19
  75. package/dist/types/runtime/createRemoteComponent.d.ts +0 -26
  76. package/dist/types/runtime/wrapNoSSR.d.ts +0 -9
  77. package/dist/types/ssr-runtime/devPlugin.d.ts +0 -2
  78. package/dist/types/ssr-runtime/downgrade.d.ts +0 -4
  79. package/dist/types/ssr-runtime/injectDataFetchFunctionPlugin.d.ts +0 -2
  80. package/dist/types/utils/dataFetch.d.ts +0 -26
  81. package/dist/types/utils/index.d.ts +0 -15
  82. /package/dist/types/{logger.d.ts → cli/logger.d.ts} +0 -0
@@ -0,0 +1,175 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import React from "react";
3
+ import { getInstance } from "@module-federation/enhanced/runtime";
4
+ import { ErrorBoundary } from "react-error-boundary";
5
+ function getLoadedRemoteInfos(instance, id) {
6
+ const { name, expose } = instance.remoteHandler.idToRemoteMap[id] || {};
7
+ if (!name) {
8
+ return;
9
+ }
10
+ const module = instance.moduleCache.get(name);
11
+ if (!module) {
12
+ return;
13
+ }
14
+ const { remoteSnapshot } = instance.snapshotHandler.getGlobalRemoteInfo(module.remoteInfo);
15
+ return {
16
+ ...module.remoteInfo,
17
+ snapshot: remoteSnapshot,
18
+ expose
19
+ };
20
+ }
21
+ function getTargetModuleInfo(id) {
22
+ const instance = getInstance();
23
+ if (!instance) {
24
+ return;
25
+ }
26
+ const loadedRemoteInfo = getLoadedRemoteInfos(instance, id);
27
+ if (!loadedRemoteInfo) {
28
+ return;
29
+ }
30
+ const snapshot = loadedRemoteInfo.snapshot;
31
+ if (!snapshot) {
32
+ return;
33
+ }
34
+ const publicPath = "publicPath" in snapshot ? snapshot.publicPath : "getPublicPath" in snapshot ? new Function(snapshot.getPublicPath)() : "";
35
+ if (!publicPath) {
36
+ return;
37
+ }
38
+ const modules = "modules" in snapshot ? snapshot.modules : [];
39
+ const targetModule = modules.find((m) => m.modulePath === loadedRemoteInfo.expose);
40
+ if (!targetModule) {
41
+ return;
42
+ }
43
+ const remoteEntry = "remoteEntry" in snapshot ? snapshot.remoteEntry : "";
44
+ if (!remoteEntry) {
45
+ return;
46
+ }
47
+ return {
48
+ module: targetModule,
49
+ publicPath,
50
+ remoteEntry
51
+ };
52
+ }
53
+ async function collectSSRAssets(options) {
54
+ const { id, injectLink = true, injectScript = true, inlineCSS = false } = typeof options === "string" ? {
55
+ id: options
56
+ } : options;
57
+ const links = [];
58
+ const scripts = [];
59
+ const instance = getInstance();
60
+ if (!instance || !injectLink && !injectScript) {
61
+ return [
62
+ ...scripts,
63
+ ...links
64
+ ];
65
+ }
66
+ const moduleAndPublicPath = getTargetModuleInfo(id);
67
+ if (!moduleAndPublicPath) {
68
+ return [
69
+ ...scripts,
70
+ ...links
71
+ ];
72
+ }
73
+ const { module: targetModule, publicPath, remoteEntry } = moduleAndPublicPath;
74
+ if (injectLink) {
75
+ await Promise.all([
76
+ ...targetModule.assets.css.sync,
77
+ ...targetModule.assets.css.async
78
+ ].map(async (file, index) => {
79
+ const href = `${publicPath}${file}`;
80
+ const key = `${file.split(".")[0]}_${index}`;
81
+ if (inlineCSS) {
82
+ const content = await fetch(href).then((res) => res.text());
83
+ links.push(/* @__PURE__ */ _jsx("style", {
84
+ children: content
85
+ }, key));
86
+ return;
87
+ }
88
+ links.push(/* @__PURE__ */ _jsx("link", {
89
+ href: `${publicPath}${file}`,
90
+ rel: "stylesheet",
91
+ type: "text/css"
92
+ }, key));
93
+ }));
94
+ }
95
+ if (injectScript) {
96
+ scripts.push(/* @__PURE__ */ _jsx("script", {
97
+ async: true,
98
+ src: `${publicPath}${remoteEntry}`,
99
+ crossOrigin: "anonymous"
100
+ }, remoteEntry.split(".")[0]));
101
+ [
102
+ ...targetModule.assets.js.sync
103
+ ].forEach((file, index) => {
104
+ scripts.push(/* @__PURE__ */ _jsx("script", {
105
+ async: true,
106
+ src: `${publicPath}${file}`,
107
+ crossOrigin: "anonymous"
108
+ }, `${file.split(".")[0]}_${index}`));
109
+ });
110
+ }
111
+ return [
112
+ ...scripts,
113
+ ...links
114
+ ];
115
+ }
116
+ function createRemoteSSRComponent(info) {
117
+ const exportName = (info === null || info === void 0 ? void 0 : info.export) || "default";
118
+ const LazyComponent = /* @__PURE__ */ React.lazy(async () => {
119
+ try {
120
+ const m = await info.loader();
121
+ if (!m) {
122
+ throw new Error("load remote failed");
123
+ }
124
+ const moduleId = m && m[Symbol.for("mf_module_id")];
125
+ const assets = await collectSSRAssets({
126
+ id: moduleId
127
+ });
128
+ const Com = m[exportName];
129
+ if (exportName in m && typeof Com === "function") {
130
+ return {
131
+ default: (props) => /* @__PURE__ */ _jsxs(_Fragment, {
132
+ children: [
133
+ assets,
134
+ /* @__PURE__ */ _jsx(Com, {
135
+ ...props
136
+ })
137
+ ]
138
+ })
139
+ };
140
+ } else {
141
+ throw Error(`Make sure that ${moduleId} has the correct export when export is ${String(exportName)}`);
142
+ }
143
+ } catch (err) {
144
+ if (!info.fallback) {
145
+ throw err;
146
+ }
147
+ const FallbackFunctionComponent = info.fallback;
148
+ const FallbackNode = /* @__PURE__ */ _jsx(FallbackFunctionComponent, {
149
+ error: err,
150
+ resetErrorBoundary: () => {
151
+ console.log('SSR mode not support "resetErrorBoundary" !');
152
+ }
153
+ });
154
+ return {
155
+ default: () => FallbackNode
156
+ };
157
+ }
158
+ });
159
+ return (props) => {
160
+ const { key, ...args } = props;
161
+ return /* @__PURE__ */ _jsx(ErrorBoundary, {
162
+ FallbackComponent: info.fallback,
163
+ children: /* @__PURE__ */ _jsx(React.Suspense, {
164
+ fallback: info.loading,
165
+ children: /* @__PURE__ */ _jsx(LazyComponent, {
166
+ ...args
167
+ })
168
+ })
169
+ });
170
+ };
171
+ }
172
+ export {
173
+ collectSSRAssets,
174
+ createRemoteSSRComponent
175
+ };
@@ -1,20 +1,12 @@
1
1
  export * from "@module-federation/enhanced/runtime";
2
- import { ERROR_TYPE } from "../constant";
3
2
  const kit = {
4
3
  get createRemoteSSRComponent() {
5
- return require("./createRemoteComponent").createRemoteSSRComponent;
6
- },
7
- get createRemoteComponent() {
8
- return require("./createRemoteComponent").createRemoteComponent;
4
+ return require("./createRemoteSSRComponent").createRemoteSSRComponent;
9
5
  },
10
6
  get collectSSRAssets() {
11
- return require("./createRemoteComponent").collectSSRAssets;
12
- },
13
- get wrapNoSSR() {
14
- return require("./wrapNoSSR").wrapNoSSR;
7
+ return require("./createRemoteSSRComponent").collectSSRAssets;
15
8
  }
16
9
  };
17
10
  export {
18
- ERROR_TYPE,
19
11
  kit
20
12
  };
@@ -0,0 +1 @@
1
+ export * from "./plugin";
@@ -1,7 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { SSRLiveReload } from "./SSRLiveReload";
3
- import { flushDataFetch } from "../utils";
4
- const mfSSRDevPlugin = () => ({
3
+ const mfSSRPlugin = () => ({
5
4
  name: "@module-federation/modern-js",
6
5
  setup: (api) => {
7
6
  api.onBeforeRender(async () => {
@@ -11,11 +10,9 @@ const mfSSRDevPlugin = () => ({
11
10
  globalThis.shouldUpdate = false;
12
11
  const nodeUtils = await import("@module-federation/node/utils");
13
12
  const shouldUpdate = await nodeUtils.revalidate();
14
- console.log("shouldUpdate: ", shouldUpdate);
15
13
  if (shouldUpdate) {
16
14
  console.log("should RELOAD", shouldUpdate);
17
15
  await nodeUtils.flushChunks();
18
- flushDataFetch();
19
16
  globalThis.shouldUpdate = true;
20
17
  }
21
18
  });
@@ -33,5 +30,5 @@ const mfSSRDevPlugin = () => ({
33
30
  }
34
31
  });
35
32
  export {
36
- mfSSRDevPlugin
33
+ mfSSRPlugin
37
34
  };
@@ -0,0 +1 @@
1
+ export declare const isDev: boolean;
@@ -3,4 +3,3 @@ import type { PluginOptions } from '../types';
3
3
  export declare const moduleFederationPlugin: (userConfig?: PluginOptions) => CliPluginFuture<AppTools>;
4
4
  export default moduleFederationPlugin;
5
5
  export { createModuleFederationConfig } from '@module-federation/enhanced';
6
- export type { FederationRuntimePlugin } from '@module-federation/enhanced/runtime';
@@ -3,4 +3,3 @@ export type ConfigType<T> = T extends 'webpack' ? webpack.Configuration : T exte
3
3
  export declare const getIPV4: () => string;
4
4
  export declare const isWebTarget: (target: string[] | string) => boolean;
5
5
  export declare const skipByTarget: (target: string[] | string) => boolean;
6
- export declare function isDev(): boolean;
@@ -1,25 +1,2 @@
1
1
  export declare const LOCALHOST = "localhost";
2
2
  export declare const PLUGIN_IDENTIFIER = "[ Modern.js Module Federation ]";
3
- export declare const DATA_FETCH_QUERY = "x-mf-data-fetch";
4
- export declare const DATA_FETCH_ERROR_PREFIX = "caught the following error during dataFetch: ";
5
- export declare const LOAD_REMOTE_ERROR_PREFIX = "caught the following error during loadRemote: ";
6
- export declare const DOWNGRADE_KEY = "_mfSSRDowngrade";
7
- export declare const DATA_FETCH_MAP_KEY = "__MF_DATA_FETCH_MAP__";
8
- export declare const DATA_FETCH_FUNCTION = "_mfDataFetch";
9
- export declare const FS_HREF = "_mfFSHref";
10
- export declare const ERROR_TYPE: {
11
- DATA_FETCH: number;
12
- LOAD_REMOTE: number;
13
- UNKNOWN: number;
14
- };
15
- export declare const WRAP_DATA_FETCH_ID_IDENTIFIER = "wrap_dfip_identifier";
16
- export declare const enum MF_DATA_FETCH_TYPE {
17
- FETCH_SERVER = 1,
18
- FETCH_CLIENT = 2
19
- }
20
- export declare const enum MF_DATA_FETCH_STATUS {
21
- LOADED = 1,
22
- LOADING = 2,
23
- AWAIT = 0,
24
- ERROR = 3
25
- }
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ import { ErrorBoundaryPropsWithComponent } from 'react-error-boundary';
3
+ type IProps = {
4
+ id: string;
5
+ injectScript?: boolean;
6
+ injectLink?: boolean;
7
+ inlineCSS?: boolean;
8
+ };
9
+ type ReactKey = {
10
+ key?: React.Key | null;
11
+ };
12
+ export declare function collectSSRAssets(options: IProps): Promise<React.ReactNode[]>;
13
+ export declare function createRemoteSSRComponent<T, E extends keyof T>(info: {
14
+ loader: () => Promise<T>;
15
+ loading: React.ReactNode;
16
+ fallback: ErrorBoundaryPropsWithComponent['FallbackComponent'];
17
+ export?: E;
18
+ }): (props: T[E] extends (...args: any) => any ? Parameters<T[E]>[0] extends undefined ? ReactKey : Parameters<T[E]>[0] & ReactKey : ReactKey) => React.JSX.Element;
19
+ export {};
@@ -1,9 +1,5 @@
1
1
  export * from '@module-federation/enhanced/runtime';
2
- export type { DataFetchParams } from '../interfaces/global';
3
- export { ERROR_TYPE } from '../constant';
4
2
  export declare const kit: {
5
- readonly createRemoteSSRComponent: typeof import("./createRemoteComponent").createRemoteSSRComponent;
6
- readonly createRemoteComponent: typeof import("./createRemoteComponent").createRemoteComponent;
7
- readonly collectSSRAssets: typeof import("./createRemoteComponent").collectSSRAssets;
8
- readonly wrapNoSSR: typeof import("./wrapNoSSR").wrapNoSSR;
3
+ readonly createRemoteSSRComponent: any;
4
+ readonly collectSSRAssets: any;
9
5
  };
@@ -0,0 +1 @@
1
+ export * from './plugin';
@@ -0,0 +1,2 @@
1
+ import type { RuntimePluginFuture } from '@modern-js/runtime';
2
+ export declare const mfSSRPlugin: () => RuntimePluginFuture;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/modern-js",
3
- "version": "0.0.0-next-20250526025159",
3
+ "version": "0.0.0-next-20250526035905",
4
4
  "files": [
5
5
  "dist/",
6
6
  "types.d.ts",
@@ -24,13 +24,9 @@
24
24
  "types": "./dist/types/runtime/index.d.ts",
25
25
  "default": "./dist/esm/runtime/index.js"
26
26
  },
27
- "./ssr-dev-plugin": {
28
- "types": "./dist/types/ssr-runtime/devPlugin.d.ts",
29
- "default": "./dist/esm/ssr-runtime/devPlugin.js"
30
- },
31
- "./ssr-inject-data-fetch-function-plugin": {
32
- "types": "./dist/types/ssr-runtime/injectDataFetchFunctionPlugin.d.ts",
33
- "default": "./dist/esm/ssr-runtime/injectDataFetchFunctionPlugin.js"
27
+ "./ssr-runtime": {
28
+ "types": "./dist/types/ssr-runtime/index.d.ts",
29
+ "default": "./dist/esm/ssr-runtime/index.js"
34
30
  },
35
31
  "./config-plugin": {
36
32
  "types": "./dist/types/cli/configPlugin.d.ts",
@@ -52,19 +48,10 @@
52
48
  "import": "./dist/esm/cli/mfRuntimePlugins/resolve-entry-ipv4.js",
53
49
  "require": "./dist/esm/cli/mfRuntimePlugins/resolve-entry-ipv4.js"
54
50
  },
55
- "./auto-fetch-data": {
56
- "types": "./dist/types/cli/mfRuntimePlugins/auto-fetch-data.d.ts",
57
- "import": "./dist/esm/cli/mfRuntimePlugins/auto-fetch-data.js",
58
- "require": "./dist/esm/cli/mfRuntimePlugins/auto-fetch-data.js"
59
- },
60
51
  "./inject-node-fetch": {
61
52
  "types": "./dist/types/cli/mfRuntimePlugins/inject-node-fetch.d.ts",
62
53
  "import": "./dist/esm/cli/mfRuntimePlugins/inject-node-fetch.js",
63
54
  "require": "./dist/esm/cli/mfRuntimePlugins/inject-node-fetch.js"
64
- },
65
- "./data-fetch-server-plugin": {
66
- "types": "./dist/types/cli/server/data-fetch-server-plugin.d.ts",
67
- "default": "./dist/cjs/cli/server/data-fetch-server-plugin.js"
68
55
  }
69
56
  },
70
57
  "typesVersions": {
@@ -87,17 +74,8 @@
87
74
  "resolve-entry-ipv4": [
88
75
  "./dist/types/cli/mfRuntimePlugins/resolve-entry-ipv4.d.ts"
89
76
  ],
90
- "auto-fetch-data": [
91
- "./dist/types/cli/mfRuntimePlugins/auto-fetch-data.d.ts"
92
- ],
93
77
  "inject-node-fetch": [
94
78
  "./dist/types/cli/mfRuntimePlugins/inject-node-fetch.d.ts"
95
- ],
96
- "data-fetch-server-plugin": [
97
- "./dist/types/cli/server/data-fetch-server-plugin.d.ts"
98
- ],
99
- "ssr-inject-data-fetch-function-plugin": [
100
- "./dist/types/cli/server/data-fetch-server-plugin.d.ts"
101
79
  ]
102
80
  }
103
81
  },
@@ -106,27 +84,25 @@
106
84
  "author": "hanric <hanric.zhang@gmail.com>",
107
85
  "license": "MIT",
108
86
  "dependencies": {
109
- "@modern-js/node-bundle-require": "2.67.5",
110
- "@modern-js/utils": "2.67.5",
87
+ "@modern-js/node-bundle-require": "2.65.1",
88
+ "@modern-js/utils": "2.65.1",
111
89
  "@swc/helpers": "0.5.13",
112
90
  "node-fetch": "~3.3.0",
113
91
  "react-error-boundary": "4.1.2",
114
- "@module-federation/rsbuild-plugin": "0.0.0-next-20250526025159",
115
- "@module-federation/enhanced": "0.0.0-next-20250526025159",
116
- "@module-federation/runtime": "0.0.0-next-20250526025159",
117
- "@module-federation/node": "0.0.0-next-20250526025159",
118
- "@module-federation/sdk": "0.0.0-next-20250526025159",
119
- "@module-federation/cli": "0.0.0-next-20250526025159"
92
+ "@module-federation/rsbuild-plugin": "0.0.0-next-20250526035905",
93
+ "@module-federation/enhanced": "0.0.0-next-20250526035905",
94
+ "@module-federation/node": "0.0.0-next-20250526035905",
95
+ "@module-federation/sdk": "0.0.0-next-20250526035905",
96
+ "@module-federation/cli": "0.0.0-next-20250526035905"
120
97
  },
121
98
  "devDependencies": {
122
99
  "@rsbuild/core": "1.2.8",
123
- "@modern-js/app-tools": "2.67.5",
124
- "@modern-js/core": "2.67.5",
125
- "@modern-js/module-tools": "2.67.5",
126
- "@modern-js/runtime": "2.67.5",
127
- "@modern-js/tsconfig": "2.67.5",
128
- "@modern-js/server-runtime": "2.67.5",
129
- "@module-federation/manifest": "0.0.0-next-20250526025159"
100
+ "@modern-js/app-tools": "2.65.1",
101
+ "@modern-js/core": "2.65.1",
102
+ "@modern-js/module-tools": "2.65.1",
103
+ "@modern-js/runtime": "2.65.1",
104
+ "@modern-js/tsconfig": "2.65.1",
105
+ "@module-federation/manifest": "0.0.0-next-20250526035905"
130
106
  },
131
107
  "peerDependencies": {
132
108
  "react": ">=17",
@@ -1,98 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var auto_fetch_data_exports = {};
30
- __export(auto_fetch_data_exports, {
31
- default: () => auto_fetch_data_default
32
- });
33
- module.exports = __toCommonJS(auto_fetch_data_exports);
34
- var import_utils = require("../../utils");
35
- var import_logger = __toESM(require("../../logger"));
36
- var import_dataFetch = require("../../utils/dataFetch");
37
- var import_constant = require("../../constant");
38
- var import_constant2 = require("@module-federation/rsbuild-plugin/constant");
39
- const autoFetchData = () => ({
40
- name: "auto-fetch-data-plugin",
41
- beforeInit(args) {
42
- (0, import_utils.initDataFetchMap)();
43
- return args;
44
- },
45
- afterLoadSnapshot(args) {
46
- const { id, moduleInfo, remoteSnapshot, host } = args;
47
- if (typeof id === "string" && (0, import_dataFetch.isDataLoaderExpose)(id)) {
48
- return args;
49
- }
50
- if (!remoteSnapshot || !id || !("modules" in remoteSnapshot)) {
51
- return args;
52
- }
53
- const { name, alias } = moduleInfo;
54
- const dataFetchInfo = (0, import_utils.getDataFetchInfo)({
55
- name,
56
- alias,
57
- id,
58
- remoteSnapshot
59
- });
60
- if (!dataFetchInfo) {
61
- return args;
62
- }
63
- const { dataFetchId, dataFetchName } = dataFetchInfo;
64
- const dataFetchMapKey = (0, import_dataFetch.getDataFetchMapKey)(dataFetchInfo, {
65
- name: host.name,
66
- version: host.options.version
67
- });
68
- import_logger.default.debug("======= auto fetch plugin dataFetchMapKey: ", dataFetchMapKey);
69
- if (!dataFetchMapKey) {
70
- return args;
71
- }
72
- const dataFetchItem = (0, import_utils.getDataFetchItem)(dataFetchMapKey);
73
- if (dataFetchItem) {
74
- return args;
75
- }
76
- const dataFetchMap = (0, import_utils.getDataFetchMap)();
77
- const downgradeType = remoteSnapshot.modules.find((module2) => module2.moduleName === `${dataFetchName}${import_constant2.DATA_FETCH_CLIENT_SUFFIX}`) ? import_constant.MF_DATA_FETCH_TYPE.FETCH_CLIENT : import_constant.MF_DATA_FETCH_TYPE.FETCH_SERVER;
78
- let finalDataFetchId = dataFetchId;
79
- if (typeof window !== "undefined") {
80
- finalDataFetchId = downgradeType === import_constant.MF_DATA_FETCH_TYPE.FETCH_CLIENT ? `${dataFetchId}${import_constant2.DATA_FETCH_CLIENT_SUFFIX}` : dataFetchId;
81
- }
82
- const getDataFetchGetter = () => (0, import_dataFetch.loadDataFetchModule)(host, finalDataFetchId);
83
- const dataFetchFnItem = [
84
- getDataFetchGetter,
85
- downgradeType
86
- ];
87
- if (typeof window === "undefined" || (0, import_utils.isCSROnly)()) {
88
- dataFetchFnItem.push(getDataFetchGetter());
89
- }
90
- dataFetchMap[dataFetchMapKey] = [
91
- dataFetchFnItem,
92
- void 0,
93
- import_constant.MF_DATA_FETCH_STATUS.AWAIT
94
- ];
95
- return args;
96
- }
97
- });
98
- var auto_fetch_data_default = autoFetchData;