@module-federation/modern-js 0.0.0-next-20240605083609 → 0.0.0-next-20240620090145

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 (35) hide show
  1. package/dist/cjs/cli/index.js +10 -7
  2. package/dist/cjs/cli/mfRuntimePlugins/resolve-entry-ipv4.js +60 -0
  3. package/dist/cjs/cli/mfRuntimePlugins/shared-strategy.js +5 -4
  4. package/dist/cjs/cli/utils.js +101 -24
  5. package/dist/cjs/constant.js +3 -0
  6. package/dist/cjs/runtime/LiveReload.js +43 -0
  7. package/dist/cjs/runtime/MFReactComponent.js +6 -2
  8. package/dist/cjs/runtime/index.js +3 -0
  9. package/dist/cjs/ssr-runtime/plugin.js +3 -17
  10. package/dist/esm/cli/index.js +123 -107
  11. package/dist/esm/cli/mfRuntimePlugins/resolve-entry-ipv4.js +54 -0
  12. package/dist/esm/cli/mfRuntimePlugins/shared-strategy.js +5 -4
  13. package/dist/esm/cli/utils.js +174 -22
  14. package/dist/esm/constant.js +2 -0
  15. package/dist/esm/runtime/LiveReload.js +26 -0
  16. package/dist/esm/runtime/MFReactComponent.js +6 -2
  17. package/dist/esm/runtime/index.js +2 -0
  18. package/dist/esm/ssr-runtime/plugin.js +12 -37
  19. package/dist/esm-node/cli/index.js +11 -8
  20. package/dist/esm-node/cli/mfRuntimePlugins/resolve-entry-ipv4.js +40 -0
  21. package/dist/esm-node/cli/mfRuntimePlugins/shared-strategy.js +5 -4
  22. package/dist/esm-node/cli/utils.js +100 -24
  23. package/dist/esm-node/constant.js +2 -0
  24. package/dist/esm-node/runtime/LiveReload.js +19 -0
  25. package/dist/esm-node/runtime/MFReactComponent.js +6 -2
  26. package/dist/esm-node/runtime/index.js +2 -0
  27. package/dist/esm-node/ssr-runtime/plugin.js +3 -17
  28. package/dist/types/cli/mfRuntimePlugins/resolve-entry-ipv4.d.ts +3 -0
  29. package/dist/types/cli/utils.d.ts +5 -24
  30. package/dist/types/constant.d.ts +1 -0
  31. package/dist/types/runtime/LiveReload.d.ts +2 -0
  32. package/dist/types/runtime/MFReactComponent.d.ts +4 -3
  33. package/dist/types/runtime/index.d.ts +1 -0
  34. package/dist/types/ssr-runtime/plugin.d.ts +1 -3
  35. package/package.json +5 -6
@@ -55,7 +55,7 @@ const moduleFederationPlugin = (userConfig = {}) => ({
55
55
  let browserPlugin;
56
56
  let nodePlugin;
57
57
  return {
58
- config: () => {
58
+ config: async () => {
59
59
  var _modernjsConfig_dev;
60
60
  const bundlerType = useAppContext().bundlerType === "rspack" ? "rspack" : "webpack";
61
61
  const WebpackPluginConstructor = userConfig.webpackPluginImplementation || import_enhanced.ModuleFederationPlugin;
@@ -89,6 +89,7 @@ const moduleFederationPlugin = (userConfig = {}) => ({
89
89
  mfConfig: envConfig
90
90
  });
91
91
  };
92
+ const ipv4 = await (0, import_utils2.lookupIpv4)();
92
93
  return {
93
94
  tools: {
94
95
  rspack(config) {
@@ -133,7 +134,9 @@ const moduleFederationPlugin = (userConfig = {}) => ({
133
134
  next();
134
135
  }
135
136
  } catch (err) {
136
- console.error(err);
137
+ if (process.env.FEDERATION_DEBUG) {
138
+ console.error(err);
139
+ }
137
140
  next();
138
141
  }
139
142
  }
@@ -142,8 +145,7 @@ const moduleFederationPlugin = (userConfig = {}) => ({
142
145
  bundlerChain(chain, { isServer }) {
143
146
  if (isDev && !isServer) {
144
147
  chain.externals({
145
- "@module-federation/node/utils": "NOT_USED_IN_BROWSER",
146
- "@module-federation/dts-plugin/server": "NOT_USED_IN_BROWSER"
148
+ "@module-federation/node/utils": "NOT_USED_IN_BROWSER"
147
149
  });
148
150
  }
149
151
  }
@@ -151,6 +153,9 @@ const moduleFederationPlugin = (userConfig = {}) => ({
151
153
  source: {
152
154
  alias: {
153
155
  "@modern-js/runtime/mf": require.resolve("@module-federation/modern-js/runtime")
156
+ },
157
+ define: {
158
+ FEDERATION_IPV4: JSON.stringify(ipv4)
154
159
  }
155
160
  },
156
161
  dev: {
@@ -187,9 +192,7 @@ const moduleFederationPlugin = (userConfig = {}) => ({
187
192
  }
188
193
  plugins.unshift({
189
194
  name: SSR_PLUGIN_IDENTIFIER,
190
- options: JSON.stringify({
191
- name: mfConfig.name
192
- })
195
+ options: JSON.stringify({})
193
196
  });
194
197
  return {
195
198
  entrypoint,
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var resolve_entry_ipv4_exports = {};
20
+ __export(resolve_entry_ipv4_exports, {
21
+ default: () => resolve_entry_ipv4_default
22
+ });
23
+ module.exports = __toCommonJS(resolve_entry_ipv4_exports);
24
+ var import_constant = require("../../constant");
25
+ const ipv4 = typeof FEDERATION_IPV4 !== "undefined" ? FEDERATION_IPV4 : "127.0.0.1";
26
+ function replaceLocalhost(url) {
27
+ return url.replace(import_constant.LOCALHOST, ipv4);
28
+ }
29
+ const resolveEntryIpv4Plugin = () => ({
30
+ name: "resolve-entry-ipv4",
31
+ beforeRegisterRemote(args) {
32
+ const { remote } = args;
33
+ if ("entry" in remote && remote.entry.includes(import_constant.LOCALHOST)) {
34
+ remote.entry = replaceLocalhost(remote.entry);
35
+ }
36
+ return args;
37
+ },
38
+ // async fetch(manifestUrl) {
39
+ // const ipv4ManifestUrl = manifestUrl.replace(LOCALHOST, ipv4);
40
+ // return globalThis.fetch(ipv4ManifestUrl);
41
+ // },
42
+ async afterResolve(args) {
43
+ const { remoteInfo } = args;
44
+ if (remoteInfo.entry.includes(import_constant.LOCALHOST)) {
45
+ remoteInfo.entry = replaceLocalhost(remoteInfo.entry);
46
+ }
47
+ return args;
48
+ },
49
+ loadRemoteSnapshot(args) {
50
+ const { remoteSnapshot } = args;
51
+ if ("publicPath" in remoteSnapshot && remoteSnapshot.publicPath.includes(import_constant.LOCALHOST)) {
52
+ remoteSnapshot.publicPath = replaceLocalhost(remoteSnapshot.publicPath);
53
+ }
54
+ if ("getPublicPath" in remoteSnapshot && remoteSnapshot.getPublicPath.includes(import_constant.LOCALHOST)) {
55
+ remoteSnapshot.getPublicPath = replaceLocalhost(remoteSnapshot.getPublicPath);
56
+ }
57
+ return args;
58
+ }
59
+ });
60
+ var resolve_entry_ipv4_default = resolveEntryIpv4Plugin;
@@ -24,10 +24,11 @@ module.exports = __toCommonJS(shared_strategy_exports);
24
24
  const sharedStrategy = () => ({
25
25
  name: "shared-strategy-plugin",
26
26
  beforeInit(args) {
27
- const { shareInfo } = args;
28
- if (shareInfo) {
29
- Object.keys(shareInfo || {}).forEach((sharedKey) => {
30
- const sharedConfigs = shareInfo[sharedKey];
27
+ const { userOptions } = args;
28
+ const shared = userOptions.shared;
29
+ if (shared) {
30
+ Object.keys(shared).forEach((sharedKey) => {
31
+ const sharedConfigs = shared[sharedKey];
31
32
  const arraySharedConfigs = Array.isArray(sharedConfigs) ? sharedConfigs : [
32
33
  sharedConfigs
33
34
  ];
@@ -30,6 +30,7 @@ var utils_exports = {};
30
30
  __export(utils_exports, {
31
31
  getMFConfig: () => getMFConfig,
32
32
  getTargetEnvConfig: () => getTargetEnvConfig,
33
+ lookupIpv4: () => lookupIpv4,
33
34
  patchMFConfig: () => patchMFConfig,
34
35
  patchWebpackConfig: () => patchWebpackConfig
35
36
  });
@@ -37,6 +38,8 @@ module.exports = __toCommonJS(utils_exports);
37
38
  var import_sdk = require("@module-federation/sdk");
38
39
  var import_path = __toESM(require("path"));
39
40
  var import_node_bundle_require = require("@modern-js/node-bundle-require");
41
+ var import_dns = __toESM(require("dns"));
42
+ var import_constant = require("../constant");
40
43
  const defaultPath = import_path.default.resolve(process.cwd(), "module-federation.config.ts");
41
44
  const getMFConfig = async (userConfig) => {
42
45
  const { config, configPath } = userConfig;
@@ -46,28 +49,58 @@ const getMFConfig = async (userConfig) => {
46
49
  const mfConfigPath = configPath ? configPath : defaultPath;
47
50
  const preBundlePath = await (0, import_node_bundle_require.bundle)(mfConfigPath);
48
51
  const mfConfig = (await Promise.resolve().then(() => __toESM(require(preBundlePath)))).default;
52
+ await replaceRemoteUrl(mfConfig);
49
53
  return mfConfig;
50
54
  };
55
+ const injectRuntimePlugins = (runtimePlugin, runtimePlugins) => {
56
+ if (!runtimePlugins.includes(runtimePlugin)) {
57
+ runtimePlugins.push(runtimePlugin);
58
+ }
59
+ };
60
+ const replaceRemoteUrl = async (mfConfig) => {
61
+ if (!mfConfig.remotes) {
62
+ return;
63
+ }
64
+ const ipv4 = await lookupIpv4();
65
+ const handleRemoteObject = (remoteObject) => {
66
+ Object.keys(remoteObject).forEach((remoteKey) => {
67
+ const remote = remoteObject[remoteKey];
68
+ if (Array.isArray(remote)) {
69
+ return;
70
+ }
71
+ if (typeof remote === "string" && remote.includes(import_constant.LOCALHOST)) {
72
+ remoteObject[remoteKey] = remote.replace(import_constant.LOCALHOST, ipv4);
73
+ }
74
+ if (typeof remote === "object" && !Array.isArray(remote.external) && remote.external.includes(import_constant.LOCALHOST)) {
75
+ remote.external = remote.external.replace(import_constant.LOCALHOST, ipv4);
76
+ }
77
+ });
78
+ };
79
+ if (Array.isArray(mfConfig.remotes)) {
80
+ mfConfig.remotes.forEach((remoteObject) => {
81
+ if (typeof remoteObject === "string") {
82
+ return;
83
+ }
84
+ handleRemoteObject(remoteObject);
85
+ });
86
+ } else if (typeof mfConfig.remotes !== "string") {
87
+ handleRemoteObject(mfConfig.remotes);
88
+ }
89
+ };
51
90
  const patchMFConfig = (mfConfig, isServer) => {
91
+ const isDev = process.env.NODE_ENV === "development";
52
92
  const runtimePlugins = [
53
93
  ...mfConfig.runtimePlugins || []
54
94
  ];
55
- const sharedStrategyRuntimePluginPath = import_path.default.resolve(__dirname, "./mfRuntimePlugins/shared-strategy.js");
56
- if (!runtimePlugins.includes(sharedStrategyRuntimePluginPath)) {
57
- runtimePlugins.push(sharedStrategyRuntimePluginPath);
95
+ injectRuntimePlugins(import_path.default.resolve(__dirname, "./mfRuntimePlugins/shared-strategy.js"), runtimePlugins);
96
+ if (isDev) {
97
+ injectRuntimePlugins(import_path.default.resolve(__dirname, "./mfRuntimePlugins/resolve-entry-ipv4.js"), runtimePlugins);
58
98
  }
59
99
  if (isServer) {
60
- const isDev = process.env.NODE_ENV === "development";
61
100
  if (isDev) {
62
- const nodeHmrPluginPath = require.resolve("@module-federation/node/record-dynamic-remote-entry-hash-plugin");
63
- if (!runtimePlugins.includes(nodeHmrPluginPath)) {
64
- runtimePlugins.push(nodeHmrPluginPath);
65
- }
66
- }
67
- const injectNodeFetchRuntimePluginPath = import_path.default.resolve(__dirname, "./mfRuntimePlugins/inject-node-fetch.js");
68
- if (!runtimePlugins.includes(injectNodeFetchRuntimePluginPath)) {
69
- runtimePlugins.push(injectNodeFetchRuntimePluginPath);
101
+ injectRuntimePlugins(require.resolve("@module-federation/node/record-dynamic-remote-entry-hash-plugin"), runtimePlugins);
70
102
  }
103
+ injectRuntimePlugins(import_path.default.resolve(__dirname, "./mfRuntimePlugins/inject-node-fetch.js"), runtimePlugins);
71
104
  }
72
105
  if (typeof mfConfig.async === "undefined") {
73
106
  mfConfig.async = true;
@@ -75,18 +108,7 @@ const patchMFConfig = (mfConfig, isServer) => {
75
108
  if (!isServer) {
76
109
  return {
77
110
  ...mfConfig,
78
- runtimePlugins,
79
- dts: mfConfig.dts === false ? false : {
80
- generateTypes: false,
81
- consumeTypes: false,
82
- ...typeof mfConfig.dts === "object" ? mfConfig.dts : {}
83
- },
84
- dev: mfConfig.dev === false ? false : {
85
- disableHotTypesReload: true,
86
- disableLiveReload: false,
87
- injectWebClient: true,
88
- ...typeof mfConfig.dev === "object" ? mfConfig.dev : {}
89
- }
111
+ runtimePlugins
90
112
  };
91
113
  }
92
114
  return {
@@ -124,6 +146,9 @@ function patchWebpackConfig(options) {
124
146
  const { bundlerConfig, modernjsConfig, isServer, mfConfig } = options;
125
147
  const enableSSR = Boolean((_modernjsConfig_server = modernjsConfig.server) === null || _modernjsConfig_server === void 0 ? void 0 : _modernjsConfig_server.ssr);
126
148
  (_bundlerConfig_optimization = bundlerConfig.optimization) === null || _bundlerConfig_optimization === void 0 ? true : delete _bundlerConfig_optimization.runtimeChunk;
149
+ if (!isServer) {
150
+ autoDeleteSplitChunkCacheGroups(mfConfig, bundlerConfig);
151
+ }
127
152
  if (!isServer && enableSSR && typeof ((_bundlerConfig_optimization1 = bundlerConfig.optimization) === null || _bundlerConfig_optimization1 === void 0 ? void 0 : _bundlerConfig_optimization1.splitChunks) === "object" && bundlerConfig.optimization.splitChunks.cacheGroups) {
128
153
  bundlerConfig.optimization.splitChunks.chunks = "async";
129
154
  console.warn('[Modern.js Module Federation] splitChunks.chunks = async is not allowed with stream SSR mode, it will auto changed to "async"');
@@ -153,10 +178,62 @@ function patchWebpackConfig(options) {
153
178
  };
154
179
  }
155
180
  }
181
+ const lookupIpv4 = async () => {
182
+ try {
183
+ const res = await import_dns.default.promises.lookup(import_constant.LOCALHOST, {
184
+ family: 4
185
+ });
186
+ return res.address;
187
+ } catch (err) {
188
+ return "127.0.0.1";
189
+ }
190
+ };
191
+ const SPLIT_CHUNK_MAP = {
192
+ REACT: "lib-react",
193
+ ROUTER: "lib-router",
194
+ LODASH: "lib-lodash",
195
+ ANTD: "lib-antd",
196
+ ARCO: "lib-arco",
197
+ SEMI: "lib-semi",
198
+ AXIOS: "lib-axios"
199
+ };
200
+ const SHARED_SPLIT_CHUNK_MAP = {
201
+ react: SPLIT_CHUNK_MAP.REACT,
202
+ "react-dom": SPLIT_CHUNK_MAP.REACT,
203
+ "react-router": SPLIT_CHUNK_MAP.ROUTER,
204
+ "react-router-dom": SPLIT_CHUNK_MAP.ROUTER,
205
+ "@remix-run/router": SPLIT_CHUNK_MAP.ROUTER,
206
+ lodash: SPLIT_CHUNK_MAP.LODASH,
207
+ "lodash-es": SPLIT_CHUNK_MAP.LODASH,
208
+ antd: SPLIT_CHUNK_MAP.ANTD,
209
+ "@arco-design/web-react": SPLIT_CHUNK_MAP.ARCO,
210
+ "@douyinfe/semi-ui": SPLIT_CHUNK_MAP.SEMI,
211
+ axios: SPLIT_CHUNK_MAP.AXIOS
212
+ };
213
+ function autoDeleteSplitChunkCacheGroups(mfConfig, bundlerConfig) {
214
+ var _bundlerConfig_optimization;
215
+ if (!mfConfig.shared) {
216
+ return;
217
+ }
218
+ if (!((_bundlerConfig_optimization = bundlerConfig.optimization) === null || _bundlerConfig_optimization === void 0 ? void 0 : _bundlerConfig_optimization.splitChunks) || !bundlerConfig.optimization.splitChunks.cacheGroups) {
219
+ return;
220
+ }
221
+ const arrayShared = Array.isArray(mfConfig.shared) ? mfConfig.shared : Object.keys(mfConfig.shared);
222
+ for (const shared of arrayShared) {
223
+ const splitChunkKey = SHARED_SPLIT_CHUNK_MAP[shared];
224
+ if (!splitChunkKey) {
225
+ continue;
226
+ }
227
+ if (bundlerConfig.optimization.splitChunks.cacheGroups[splitChunkKey]) {
228
+ delete bundlerConfig.optimization.splitChunks.cacheGroups[splitChunkKey];
229
+ }
230
+ }
231
+ }
156
232
  // Annotate the CommonJS export names for ESM import in node:
157
233
  0 && (module.exports = {
158
234
  getMFConfig,
159
235
  getTargetEnvConfig,
236
+ lookupIpv4,
160
237
  patchMFConfig,
161
238
  patchWebpackConfig
162
239
  });
@@ -18,11 +18,14 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var constant_exports = {};
20
20
  __export(constant_exports, {
21
+ LOCALHOST: () => LOCALHOST,
21
22
  MODERN_JS_SERVER_DIR: () => MODERN_JS_SERVER_DIR
22
23
  });
23
24
  module.exports = __toCommonJS(constant_exports);
24
25
  const MODERN_JS_SERVER_DIR = "bundles";
26
+ const LOCALHOST = "localhost";
25
27
  // Annotate the CommonJS export names for ESM import in node:
26
28
  0 && (module.exports = {
29
+ LOCALHOST,
27
30
  MODERN_JS_SERVER_DIR
28
31
  });
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var LiveReload_exports = {};
20
+ __export(LiveReload_exports, {
21
+ LiveReload: () => LiveReload
22
+ });
23
+ module.exports = __toCommonJS(LiveReload_exports);
24
+ var import_jsx_runtime = require("react/jsx-runtime");
25
+ function LiveReload() {
26
+ if (process.env.NODE_ENV !== "development") {
27
+ return null;
28
+ }
29
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("script", {
30
+ suppressHydrationWarning: true,
31
+ dangerouslySetInnerHTML: {
32
+ __html: String.raw`
33
+ if(${globalThis.shouldUpdate}){
34
+ location.reload();
35
+ }
36
+ `
37
+ }
38
+ });
39
+ }
40
+ // Annotate the CommonJS export names for ESM import in node:
41
+ 0 && (module.exports = {
42
+ LiveReload
43
+ });
@@ -84,7 +84,9 @@ function getTargetModuleInfo(id) {
84
84
  };
85
85
  }
86
86
  function collectAssets(options) {
87
- const { id, injectLink = true, injectScript = true } = options;
87
+ const { id, injectLink = true, injectScript = true } = typeof options === "string" ? {
88
+ id: options
89
+ } : options;
88
90
  const links = [];
89
91
  const scripts = [];
90
92
  const instance = (0, import_runtime.getInstance)();
@@ -136,7 +138,9 @@ function collectAssets(options) {
136
138
  ];
137
139
  }
138
140
  function MFReactComponent(props) {
139
- const { loading = "loading...", id, fallback } = props;
141
+ const { loading = "loading...", id, fallback = void 0 } = typeof props === "string" ? {
142
+ id: props
143
+ } : props;
140
144
  const Component = /* @__PURE__ */ import_react.default.lazy(() => (0, import_runtime.loadRemote)(id).then((mod) => {
141
145
  const assets = collectAssets(props);
142
146
  if (!mod) {
@@ -19,14 +19,17 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
19
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
20
  var runtime_exports = {};
21
21
  __export(runtime_exports, {
22
+ LiveReload: () => import_LiveReload.LiveReload,
22
23
  MFReactComponent: () => import_MFReactComponent.MFReactComponent,
23
24
  collectAssets: () => import_MFReactComponent.collectAssets
24
25
  });
25
26
  module.exports = __toCommonJS(runtime_exports);
26
27
  __reExport(runtime_exports, require("@module-federation/enhanced/runtime"), module.exports);
27
28
  var import_MFReactComponent = require("./MFReactComponent");
29
+ var import_LiveReload = require("./LiveReload");
28
30
  // Annotate the CommonJS export names for ESM import in node:
29
31
  0 && (module.exports = {
32
+ LiveReload,
30
33
  MFReactComponent,
31
34
  collectAssets,
32
35
  ...require("@module-federation/enhanced/runtime")
@@ -31,10 +31,9 @@ __export(plugin_exports, {
31
31
  mfPluginSSR: () => mfPluginSSR
32
32
  });
33
33
  module.exports = __toCommonJS(plugin_exports);
34
- const mfPluginSSR = ({ name }) => ({
34
+ const mfPluginSSR = () => ({
35
35
  name: "@module-federation/modern-js",
36
36
  setup: () => {
37
- let mfDevServer;
38
37
  return {
39
38
  async init({ context }, next) {
40
39
  if (typeof window !== "undefined") {
@@ -42,26 +41,13 @@ const mfPluginSSR = ({ name }) => ({
42
41
  context
43
42
  });
44
43
  }
45
- const devServer = await Promise.resolve().then(() => __toESM(require("@module-federation/dts-plugin/server")));
46
- if (name) {
47
- mfDevServer = new devServer.ModuleFederationDevServer({
48
- name: `${name}-server`,
49
- remotes: [],
50
- updateCallback: async () => {
51
- },
52
- remoteTypeTarPath: ""
53
- });
54
- }
44
+ globalThis.shouldUpdate = false;
55
45
  const nodeUtils = await Promise.resolve().then(() => __toESM(require("@module-federation/node/utils")));
56
46
  const shouldUpdate = await nodeUtils.revalidate();
57
47
  if (shouldUpdate) {
58
48
  console.log("should RELOAD", shouldUpdate);
59
49
  await nodeUtils.flushChunks();
60
- mfDevServer && mfDevServer.update({
61
- updateKind: devServer.UpdateKind.RELOAD_PAGE,
62
- updateMode: devServer.UpdateMode.POSITIVE,
63
- clientName: name
64
- });
50
+ globalThis.shouldUpdate = true;
65
51
  }
66
52
  return next({
67
53
  context