@module-federation/modern-js 0.0.0-next-20250526033636 → 0.0.0-next-20250526062606

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 +201 -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 +191 -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 +166 -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 +18 -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
@@ -7,8 +7,8 @@ import { ModuleFederationPlugin } from "@module-federation/enhanced/webpack";
7
7
  import { ModuleFederationPlugin as RspackModuleFederationPlugin } from "@module-federation/enhanced/rspack";
8
8
  import UniverseEntryChunkTrackerPlugin from "@module-federation/node/universe-entry-chunk-tracker-plugin";
9
9
  import { updateStatsAndManifest } from "./manifest";
10
- import logger from "../logger";
11
- import { isDev } from "./utils";
10
+ import { isDev } from "./constant";
11
+ import logger from "./logger";
12
12
  import { isWebTarget, skipByTarget } from "./utils";
13
13
  function setEnv() {
14
14
  process.env["MF_DISABLE_EMIT_STATS"] = "true";
@@ -85,20 +85,15 @@ var moduleFederationSSRPlugin = function(pluginOptions) {
85
85
  setEnv();
86
86
  api._internalRuntimePlugins(function(param) {
87
87
  var entrypoint = param.entrypoint, plugins = param.plugins;
88
- plugins.push({
89
- name: "injectDataFetchFunction",
90
- path: "@module-federation/modern-js/ssr-inject-data-fetch-function-plugin",
91
- config: {}
92
- });
93
- if (!isDev()) {
88
+ if (!isDev) {
94
89
  return {
95
90
  entrypoint,
96
91
  plugins
97
92
  };
98
93
  }
99
94
  plugins.push({
100
- name: "mfSSRDev",
101
- path: "@module-federation/modern-js/ssr-dev-plugin",
95
+ name: "mfSSR",
96
+ path: "@module-federation/modern-js/ssr-runtime",
102
97
  config: {}
103
98
  });
104
99
  return {
@@ -106,18 +101,6 @@ var moduleFederationSSRPlugin = function(pluginOptions) {
106
101
  plugins
107
102
  };
108
103
  });
109
- if (pluginOptions.ssrConfig.remotes) {
110
- api._internalServerPlugins(function(param) {
111
- var plugins = param.plugins;
112
- plugins.push({
113
- name: "@module-federation/modern-js/data-fetch-server-plugin",
114
- options: {}
115
- });
116
- return {
117
- plugins
118
- };
119
- });
120
- }
121
104
  api.modifyBundlerChain(function(chain) {
122
105
  var target = chain.get("target");
123
106
  if (skipByTarget(target)) {
@@ -138,7 +121,7 @@ var moduleFederationSSRPlugin = function(pluginOptions) {
138
121
  }
139
122
  if (!isWeb) {
140
123
  chain.target("async-node");
141
- if (isDev()) {
124
+ if (isDev) {
142
125
  chain.plugin("UniverseEntryChunkTrackerPlugin").use(UniverseEntryChunkTrackerPlugin);
143
126
  }
144
127
  var userSSRConfig = pluginOptions.userConfig.ssr ? _type_of(pluginOptions.userConfig.ssr) === "object" ? pluginOptions.userConfig.ssr : {} : {};
@@ -147,7 +130,7 @@ var moduleFederationSSRPlugin = function(pluginOptions) {
147
130
  chain.output.publicPath("".concat(publicPath).concat(userSSRConfig.distOutputDir, "/"));
148
131
  }
149
132
  }
150
- if (isDev() && isWeb) {
133
+ if (isDev && isWeb) {
151
134
  chain.externals({
152
135
  "@module-federation/node/utils": "NOT_USED_IN_BROWSER"
153
136
  });
@@ -42,12 +42,8 @@ var skipByTarget = function(target) {
42
42
  }
43
43
  return false;
44
44
  };
45
- function isDev() {
46
- return process.env.NODE_ENV === "development";
47
- }
48
45
  export {
49
46
  getIPV4,
50
- isDev,
51
47
  isWebTarget,
52
48
  skipByTarget
53
49
  };
@@ -1,42 +1,6 @@
1
1
  var LOCALHOST = "localhost";
2
2
  var PLUGIN_IDENTIFIER = "[ Modern.js Module Federation ]";
3
- var DATA_FETCH_QUERY = "x-mf-data-fetch";
4
- var DATA_FETCH_ERROR_PREFIX = "caught the following error during dataFetch: ";
5
- var LOAD_REMOTE_ERROR_PREFIX = "caught the following error during loadRemote: ";
6
- var DOWNGRADE_KEY = "_mfSSRDowngrade";
7
- var DATA_FETCH_MAP_KEY = "__MF_DATA_FETCH_MAP__";
8
- var DATA_FETCH_FUNCTION = "_mfDataFetch";
9
- var FS_HREF = "_mfFSHref";
10
- var ERROR_TYPE = {
11
- DATA_FETCH: 1,
12
- LOAD_REMOTE: 2,
13
- UNKNOWN: 3
14
- };
15
- var WRAP_DATA_FETCH_ID_IDENTIFIER = "wrap_dfip_identifier";
16
- var MF_DATA_FETCH_TYPE;
17
- (function(MF_DATA_FETCH_TYPE2) {
18
- MF_DATA_FETCH_TYPE2[MF_DATA_FETCH_TYPE2["FETCH_SERVER"] = 1] = "FETCH_SERVER";
19
- MF_DATA_FETCH_TYPE2[MF_DATA_FETCH_TYPE2["FETCH_CLIENT"] = 2] = "FETCH_CLIENT";
20
- })(MF_DATA_FETCH_TYPE || (MF_DATA_FETCH_TYPE = {}));
21
- var MF_DATA_FETCH_STATUS;
22
- (function(MF_DATA_FETCH_STATUS2) {
23
- MF_DATA_FETCH_STATUS2[MF_DATA_FETCH_STATUS2["LOADED"] = 1] = "LOADED";
24
- MF_DATA_FETCH_STATUS2[MF_DATA_FETCH_STATUS2["LOADING"] = 2] = "LOADING";
25
- MF_DATA_FETCH_STATUS2[MF_DATA_FETCH_STATUS2["AWAIT"] = 0] = "AWAIT";
26
- MF_DATA_FETCH_STATUS2[MF_DATA_FETCH_STATUS2["ERROR"] = 3] = "ERROR";
27
- })(MF_DATA_FETCH_STATUS || (MF_DATA_FETCH_STATUS = {}));
28
3
  export {
29
- DATA_FETCH_ERROR_PREFIX,
30
- DATA_FETCH_FUNCTION,
31
- DATA_FETCH_MAP_KEY,
32
- DATA_FETCH_QUERY,
33
- DOWNGRADE_KEY,
34
- ERROR_TYPE,
35
- FS_HREF,
36
- LOAD_REMOTE_ERROR_PREFIX,
37
4
  LOCALHOST,
38
- MF_DATA_FETCH_STATUS,
39
- MF_DATA_FETCH_TYPE,
40
- PLUGIN_IDENTIFIER,
41
- WRAP_DATA_FETCH_ID_IDENTIFIER
5
+ PLUGIN_IDENTIFIER
42
6
  };
@@ -0,0 +1,191 @@
1
+ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
+ import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
3
+ import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
4
+ import { _ as _object_without_properties } from "@swc/helpers/_/_object_without_properties";
5
+ import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
6
+ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
7
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
8
+ import React from "react";
9
+ import { getInstance } from "@module-federation/enhanced/runtime";
10
+ import { ErrorBoundary } from "react-error-boundary";
11
+ function getLoadedRemoteInfos(instance, id) {
12
+ var _ref = instance.remoteHandler.idToRemoteMap[id] || {}, name = _ref.name, expose = _ref.expose;
13
+ if (!name) {
14
+ return;
15
+ }
16
+ var module = instance.moduleCache.get(name);
17
+ if (!module) {
18
+ return;
19
+ }
20
+ var remoteSnapshot = instance.snapshotHandler.getGlobalRemoteInfo(module.remoteInfo).remoteSnapshot;
21
+ return _object_spread_props(_object_spread({}, module.remoteInfo), {
22
+ snapshot: remoteSnapshot,
23
+ expose
24
+ });
25
+ }
26
+ function getTargetModuleInfo(id) {
27
+ var instance = getInstance();
28
+ if (!instance) {
29
+ return;
30
+ }
31
+ var loadedRemoteInfo = getLoadedRemoteInfos(instance, id);
32
+ if (!loadedRemoteInfo) {
33
+ return;
34
+ }
35
+ var snapshot = loadedRemoteInfo.snapshot;
36
+ if (!snapshot) {
37
+ return;
38
+ }
39
+ var publicPath = "publicPath" in snapshot ? snapshot.publicPath : "getPublicPath" in snapshot ? new Function(snapshot.getPublicPath)() : "";
40
+ if (!publicPath) {
41
+ return;
42
+ }
43
+ var modules = "modules" in snapshot ? snapshot.modules : [];
44
+ var targetModule = modules.find(function(m) {
45
+ return m.modulePath === loadedRemoteInfo.expose;
46
+ });
47
+ if (!targetModule) {
48
+ return;
49
+ }
50
+ var remoteEntry = "remoteEntry" in snapshot ? snapshot.remoteEntry : "";
51
+ if (!remoteEntry) {
52
+ return;
53
+ }
54
+ return {
55
+ module: targetModule,
56
+ publicPath,
57
+ remoteEntry
58
+ };
59
+ }
60
+ function collectSSRAssets(options) {
61
+ var _ref = typeof options === "string" ? {
62
+ id: options
63
+ } : options, id = _ref.id, _ref_injectLink = _ref.injectLink, injectLink = _ref_injectLink === void 0 ? true : _ref_injectLink, _ref_injectScript = _ref.injectScript, injectScript = _ref_injectScript === void 0 ? true : _ref_injectScript;
64
+ var links = [];
65
+ var scripts = [];
66
+ var instance = getInstance();
67
+ if (!instance || !injectLink && !injectScript) {
68
+ return _to_consumable_array(scripts).concat(_to_consumable_array(links));
69
+ }
70
+ var moduleAndPublicPath = getTargetModuleInfo(id);
71
+ if (!moduleAndPublicPath) {
72
+ return _to_consumable_array(scripts).concat(_to_consumable_array(links));
73
+ }
74
+ var targetModule = moduleAndPublicPath.module, publicPath = moduleAndPublicPath.publicPath, remoteEntry = moduleAndPublicPath.remoteEntry;
75
+ if (injectLink) {
76
+ _to_consumable_array(targetModule.assets.css.sync).concat(_to_consumable_array(targetModule.assets.css.async)).forEach(function(file, index) {
77
+ links.push(/* @__PURE__ */ _jsx("link", {
78
+ href: "".concat(publicPath).concat(file),
79
+ rel: "stylesheet",
80
+ type: "text/css"
81
+ }, "".concat(file.split(".")[0], "_").concat(index)));
82
+ });
83
+ }
84
+ if (injectScript) {
85
+ scripts.push(/* @__PURE__ */ _jsx("script", {
86
+ async: true,
87
+ src: "".concat(publicPath).concat(remoteEntry),
88
+ crossOrigin: "anonymous"
89
+ }, remoteEntry.split(".")[0]));
90
+ _to_consumable_array(targetModule.assets.js.sync).forEach(function(file, index) {
91
+ scripts.push(/* @__PURE__ */ _jsx("script", {
92
+ async: true,
93
+ src: "".concat(publicPath).concat(file),
94
+ crossOrigin: "anonymous"
95
+ }, "".concat(file.split(".")[0], "_").concat(index)));
96
+ });
97
+ }
98
+ return _to_consumable_array(scripts).concat(_to_consumable_array(links));
99
+ }
100
+ function createRemoteSSRComponent(info) {
101
+ var exportName = (info === null || info === void 0 ? void 0 : info.export) || "default";
102
+ var LazyComponent = /* @__PURE__ */ React.lazy(/* @__PURE__ */ _async_to_generator(function() {
103
+ var m, moduleId, assets, Com, err, FallbackFunctionComponent, FallbackNode;
104
+ return _ts_generator(this, function(_state) {
105
+ switch (_state.label) {
106
+ case 0:
107
+ _state.trys.push([
108
+ 0,
109
+ 2,
110
+ ,
111
+ 3
112
+ ]);
113
+ return [
114
+ 4,
115
+ info.loader()
116
+ ];
117
+ case 1:
118
+ m = _state.sent();
119
+ if (!m) {
120
+ throw new Error("load remote failed");
121
+ }
122
+ moduleId = m && m[Symbol.for("mf_module_id")];
123
+ assets = collectSSRAssets({
124
+ id: moduleId
125
+ });
126
+ Com = m[exportName];
127
+ if (exportName in m && typeof Com === "function") {
128
+ return [
129
+ 2,
130
+ {
131
+ default: function(props) {
132
+ return /* @__PURE__ */ _jsxs(_Fragment, {
133
+ children: [
134
+ assets,
135
+ /* @__PURE__ */ _jsx(Com, _object_spread({}, props))
136
+ ]
137
+ });
138
+ }
139
+ }
140
+ ];
141
+ } else {
142
+ throw Error("Make sure that ".concat(moduleId, " has the correct export when export is ").concat(String(exportName)));
143
+ }
144
+ return [
145
+ 3,
146
+ 3
147
+ ];
148
+ case 2:
149
+ err = _state.sent();
150
+ if (!info.fallback) {
151
+ throw err;
152
+ }
153
+ FallbackFunctionComponent = info.fallback;
154
+ FallbackNode = /* @__PURE__ */ _jsx(FallbackFunctionComponent, {
155
+ error: err,
156
+ resetErrorBoundary: function() {
157
+ console.log('SSR mode not support "resetErrorBoundary" !');
158
+ }
159
+ });
160
+ return [
161
+ 2,
162
+ {
163
+ default: function() {
164
+ return FallbackNode;
165
+ }
166
+ }
167
+ ];
168
+ case 3:
169
+ return [
170
+ 2
171
+ ];
172
+ }
173
+ });
174
+ }));
175
+ return function(props) {
176
+ var key = props.key, args = _object_without_properties(props, [
177
+ "key"
178
+ ]);
179
+ return /* @__PURE__ */ _jsx(ErrorBoundary, {
180
+ FallbackComponent: info.fallback,
181
+ children: /* @__PURE__ */ _jsx(React.Suspense, {
182
+ fallback: info.loading,
183
+ children: /* @__PURE__ */ _jsx(LazyComponent, _object_spread({}, args))
184
+ })
185
+ });
186
+ };
187
+ }
188
+ export {
189
+ collectSSRAssets,
190
+ createRemoteSSRComponent
191
+ };
@@ -1,20 +1,12 @@
1
1
  export * from "@module-federation/enhanced/runtime";
2
- import { ERROR_TYPE } from "../constant";
3
2
  var 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";
@@ -3,8 +3,7 @@ import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
3
3
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
4
4
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
5
5
  import { SSRLiveReload } from "./SSRLiveReload";
6
- import { flushDataFetch } from "../utils";
7
- var mfSSRDevPlugin = function() {
6
+ var mfSSRPlugin = function() {
8
7
  return {
9
8
  name: "@module-federation/modern-js",
10
9
  setup: function(api) {
@@ -31,7 +30,6 @@ var mfSSRDevPlugin = function() {
31
30
  ];
32
31
  case 2:
33
32
  shouldUpdate = _state.sent();
34
- console.log("shouldUpdate: ", shouldUpdate);
35
33
  if (!shouldUpdate)
36
34
  return [
37
35
  3,
@@ -44,7 +42,6 @@ var mfSSRDevPlugin = function() {
44
42
  ];
45
43
  case 3:
46
44
  _state.sent();
47
- flushDataFetch();
48
45
  globalThis.shouldUpdate = true;
49
46
  _state.label = 4;
50
47
  case 4:
@@ -69,5 +66,5 @@ var mfSSRDevPlugin = function() {
69
66
  };
70
67
  };
71
68
  export {
72
- mfSSRDevPlugin
69
+ mfSSRPlugin
73
70
  };
@@ -3,10 +3,10 @@ import { getIPV4, isWebTarget, skipByTarget } from "./utils";
3
3
  import { encodeName } from "@module-federation/sdk";
4
4
  import { bundle } from "@modern-js/node-bundle-require";
5
5
  import { LOCALHOST, PLUGIN_IDENTIFIER } from "../constant";
6
- import { autoDeleteSplitChunkCacheGroups, addDataFetchExposes } from "@module-federation/rsbuild-plugin/utils";
7
- import logger from "../logger";
8
- import { isDev } from "./utils";
6
+ import { autoDeleteSplitChunkCacheGroups } from "@module-federation/rsbuild-plugin/utils";
7
+ import logger from "./logger";
9
8
  const defaultPath = path.resolve(process.cwd(), "module-federation.config.ts");
9
+ const isDev = process.env.NODE_ENV === "development";
10
10
  function setEnv(enableSSR) {
11
11
  if (enableSSR) {
12
12
  process.env["MF_DISABLE_EMIT_STATS"] = "true";
@@ -95,7 +95,6 @@ const patchDTSConfig = (mfConfig, isServer) => {
95
95
  };
96
96
  const patchMFConfig = (mfConfig, isServer, remoteIpStrategy) => {
97
97
  replaceRemoteUrl(mfConfig, remoteIpStrategy);
98
- addDataFetchExposes(mfConfig.exposes, isServer);
99
98
  if (mfConfig.remoteType === void 0) {
100
99
  mfConfig.remoteType = "script";
101
100
  }
@@ -107,13 +106,12 @@ const patchMFConfig = (mfConfig, isServer, remoteIpStrategy) => {
107
106
  ];
108
107
  patchDTSConfig(mfConfig, isServer);
109
108
  injectRuntimePlugins(require.resolve("@module-federation/modern-js/shared-strategy"), runtimePlugins);
110
- injectRuntimePlugins(require.resolve("@module-federation/modern-js/auto-fetch-data"), runtimePlugins);
111
- if (isDev()) {
109
+ if (isDev) {
112
110
  injectRuntimePlugins(require.resolve("@module-federation/modern-js/resolve-entry-ipv4"), runtimePlugins);
113
111
  }
114
112
  if (isServer) {
115
113
  injectRuntimePlugins(require.resolve("@module-federation/node/runtimePlugin"), runtimePlugins);
116
- if (isDev()) {
114
+ if (isDev) {
117
115
  injectRuntimePlugins(require.resolve("@module-federation/node/record-dynamic-remote-entry-hash-plugin"), runtimePlugins);
118
116
  }
119
117
  injectRuntimePlugins(require.resolve("@module-federation/modern-js/inject-node-fetch"), runtimePlugins);
@@ -213,7 +211,7 @@ function patchBundlerConfig(options) {
213
211
  splitChunkConfig.chunks = "async";
214
212
  logger.warn(`splitChunks.chunks = async is not allowed with stream SSR mode, it will auto changed to "async"`);
215
213
  }
216
- if (isDev() && chain.output.get("publicPath") === "auto") {
214
+ if (isDev && chain.output.get("publicPath") === "auto") {
217
215
  var _modernjsConfig_dev, _modernjsConfig_server;
218
216
  const port = ((_modernjsConfig_dev = modernjsConfig.dev) === null || _modernjsConfig_dev === void 0 ? void 0 : _modernjsConfig_dev.port) || ((_modernjsConfig_server = modernjsConfig.server) === null || _modernjsConfig_server === void 0 ? void 0 : _modernjsConfig_server.port) || 8080;
219
217
  const publicPath = `http://localhost:${port}/`;
@@ -227,7 +225,7 @@ function patchBundlerConfig(options) {
227
225
  chain.output.chunkFilename(chunkFileName.replace(".js", suffix));
228
226
  }
229
227
  }
230
- if (isDev() && enableSSR && !isServer) {
228
+ if (isDev && enableSSR && !isServer) {
231
229
  chain.resolve.fallback.set("crypto", false).set("stream", false).set("vm", false);
232
230
  }
233
231
  if (((_modernjsConfig_deploy = modernjsConfig.deploy) === null || _modernjsConfig_deploy === void 0 ? void 0 : _modernjsConfig_deploy.microFrontend) && Object.keys(mfConfig.exposes || {}).length) {
@@ -38,7 +38,6 @@ describe("patchMFConfig", async () => {
38
38
  remoteType: "script",
39
39
  runtimePlugins: [
40
40
  require.resolve("@module-federation/modern-js/shared-strategy"),
41
- require.resolve("@module-federation/modern-js/auto-fetch-data"),
42
41
  require.resolve("@module-federation/node/runtimePlugin"),
43
42
  require.resolve("@module-federation/modern-js/inject-node-fetch")
44
43
  ],
@@ -66,8 +65,7 @@ describe("patchMFConfig", async () => {
66
65
  },
67
66
  remoteType: "script",
68
67
  runtimePlugins: [
69
- require.resolve("@module-federation/modern-js/shared-strategy"),
70
- require.resolve("@module-federation/modern-js/auto-fetch-data")
68
+ require.resolve("@module-federation/modern-js/shared-strategy")
71
69
  ],
72
70
  shared: {
73
71
  react: {
@@ -0,0 +1,4 @@
1
+ const isDev = process.env.NODE_ENV === "development";
2
+ export {
3
+ isDev
4
+ };
@@ -1,5 +1,5 @@
1
1
  import { createLogger } from "@module-federation/sdk";
2
- import { PLUGIN_IDENTIFIER } from "./constant";
2
+ import { PLUGIN_IDENTIFIER } from "../constant";
3
3
  const logger = createLogger(PLUGIN_IDENTIFIER);
4
4
  var logger_default = logger;
5
5
  export {
@@ -4,8 +4,8 @@ import { ModuleFederationPlugin } from "@module-federation/enhanced/webpack";
4
4
  import { ModuleFederationPlugin as RspackModuleFederationPlugin } from "@module-federation/enhanced/rspack";
5
5
  import UniverseEntryChunkTrackerPlugin from "@module-federation/node/universe-entry-chunk-tracker-plugin";
6
6
  import { updateStatsAndManifest } from "./manifest";
7
- import logger from "../logger";
8
- import { isDev } from "./utils";
7
+ import { isDev } from "./constant";
8
+ import logger from "./logger";
9
9
  import { isWebTarget, skipByTarget } from "./utils";
10
10
  function setEnv() {
11
11
  process.env["MF_DISABLE_EMIT_STATS"] = "true";
@@ -76,20 +76,15 @@ const moduleFederationSSRPlugin = (pluginOptions) => ({
76
76
  }
77
77
  setEnv();
78
78
  api._internalRuntimePlugins(({ entrypoint, plugins }) => {
79
- plugins.push({
80
- name: "injectDataFetchFunction",
81
- path: "@module-federation/modern-js/ssr-inject-data-fetch-function-plugin",
82
- config: {}
83
- });
84
- if (!isDev()) {
79
+ if (!isDev) {
85
80
  return {
86
81
  entrypoint,
87
82
  plugins
88
83
  };
89
84
  }
90
85
  plugins.push({
91
- name: "mfSSRDev",
92
- path: "@module-federation/modern-js/ssr-dev-plugin",
86
+ name: "mfSSR",
87
+ path: "@module-federation/modern-js/ssr-runtime",
93
88
  config: {}
94
89
  });
95
90
  return {
@@ -97,17 +92,6 @@ const moduleFederationSSRPlugin = (pluginOptions) => ({
97
92
  plugins
98
93
  };
99
94
  });
100
- if (pluginOptions.ssrConfig.remotes) {
101
- api._internalServerPlugins(({ plugins }) => {
102
- plugins.push({
103
- name: "@module-federation/modern-js/data-fetch-server-plugin",
104
- options: {}
105
- });
106
- return {
107
- plugins
108
- };
109
- });
110
- }
111
95
  api.modifyBundlerChain((chain) => {
112
96
  const target = chain.get("target");
113
97
  if (skipByTarget(target)) {
@@ -128,7 +112,7 @@ const moduleFederationSSRPlugin = (pluginOptions) => ({
128
112
  }
129
113
  if (!isWeb) {
130
114
  chain.target("async-node");
131
- if (isDev()) {
115
+ if (isDev) {
132
116
  chain.plugin("UniverseEntryChunkTrackerPlugin").use(UniverseEntryChunkTrackerPlugin);
133
117
  }
134
118
  const userSSRConfig = pluginOptions.userConfig.ssr ? typeof pluginOptions.userConfig.ssr === "object" ? pluginOptions.userConfig.ssr : {} : {};
@@ -137,7 +121,7 @@ const moduleFederationSSRPlugin = (pluginOptions) => ({
137
121
  chain.output.publicPath(`${publicPath}${userSSRConfig.distOutputDir}/`);
138
122
  }
139
123
  }
140
- if (isDev() && isWeb) {
124
+ if (isDev && isWeb) {
141
125
  chain.externals({
142
126
  "@module-federation/node/utils": "NOT_USED_IN_BROWSER"
143
127
  });
@@ -42,12 +42,8 @@ const skipByTarget = (target) => {
42
42
  }
43
43
  return false;
44
44
  };
45
- function isDev() {
46
- return process.env.NODE_ENV === "development";
47
- }
48
45
  export {
49
46
  getIPV4,
50
- isDev,
51
47
  isWebTarget,
52
48
  skipByTarget
53
49
  };
@@ -1,42 +1,6 @@
1
1
  const LOCALHOST = "localhost";
2
2
  const PLUGIN_IDENTIFIER = "[ Modern.js Module Federation ]";
3
- const DATA_FETCH_QUERY = "x-mf-data-fetch";
4
- const DATA_FETCH_ERROR_PREFIX = "caught the following error during dataFetch: ";
5
- const LOAD_REMOTE_ERROR_PREFIX = "caught the following error during loadRemote: ";
6
- const DOWNGRADE_KEY = "_mfSSRDowngrade";
7
- const DATA_FETCH_MAP_KEY = "__MF_DATA_FETCH_MAP__";
8
- const DATA_FETCH_FUNCTION = "_mfDataFetch";
9
- const FS_HREF = "_mfFSHref";
10
- const ERROR_TYPE = {
11
- DATA_FETCH: 1,
12
- LOAD_REMOTE: 2,
13
- UNKNOWN: 3
14
- };
15
- const WRAP_DATA_FETCH_ID_IDENTIFIER = "wrap_dfip_identifier";
16
- var MF_DATA_FETCH_TYPE;
17
- (function(MF_DATA_FETCH_TYPE2) {
18
- MF_DATA_FETCH_TYPE2[MF_DATA_FETCH_TYPE2["FETCH_SERVER"] = 1] = "FETCH_SERVER";
19
- MF_DATA_FETCH_TYPE2[MF_DATA_FETCH_TYPE2["FETCH_CLIENT"] = 2] = "FETCH_CLIENT";
20
- })(MF_DATA_FETCH_TYPE || (MF_DATA_FETCH_TYPE = {}));
21
- var MF_DATA_FETCH_STATUS;
22
- (function(MF_DATA_FETCH_STATUS2) {
23
- MF_DATA_FETCH_STATUS2[MF_DATA_FETCH_STATUS2["LOADED"] = 1] = "LOADED";
24
- MF_DATA_FETCH_STATUS2[MF_DATA_FETCH_STATUS2["LOADING"] = 2] = "LOADING";
25
- MF_DATA_FETCH_STATUS2[MF_DATA_FETCH_STATUS2["AWAIT"] = 0] = "AWAIT";
26
- MF_DATA_FETCH_STATUS2[MF_DATA_FETCH_STATUS2["ERROR"] = 3] = "ERROR";
27
- })(MF_DATA_FETCH_STATUS || (MF_DATA_FETCH_STATUS = {}));
28
3
  export {
29
- DATA_FETCH_ERROR_PREFIX,
30
- DATA_FETCH_FUNCTION,
31
- DATA_FETCH_MAP_KEY,
32
- DATA_FETCH_QUERY,
33
- DOWNGRADE_KEY,
34
- ERROR_TYPE,
35
- FS_HREF,
36
- LOAD_REMOTE_ERROR_PREFIX,
37
4
  LOCALHOST,
38
- MF_DATA_FETCH_STATUS,
39
- MF_DATA_FETCH_TYPE,
40
- PLUGIN_IDENTIFIER,
41
- WRAP_DATA_FETCH_ID_IDENTIFIER
5
+ PLUGIN_IDENTIFIER
42
6
  };