@module-federation/modern-js 2.6.0 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/cjs/cli/configPlugin.js +28 -10
  2. package/dist/cjs/cli/index.js +11 -7
  3. package/dist/cjs/cli/mfRuntimePlugins/inject-node-fetch.js +14 -21
  4. package/dist/cjs/cli/mfRuntimePlugins/shared-strategy.js +12 -8
  5. package/dist/cjs/cli/server/data-fetch-server-plugin.js +9 -5
  6. package/dist/cjs/cli/ssrPlugin.js +11 -7
  7. package/dist/cjs/cli/utils.js +9 -5
  8. package/dist/cjs/constant.js +13 -9
  9. package/dist/cjs/logger.js +9 -5
  10. package/dist/cjs/react/data-fetch.js +9 -5
  11. package/dist/cjs/react/index.js +9 -5
  12. package/dist/cjs/react/plugin.js +12 -8
  13. package/dist/cjs/react/v18.js +9 -5
  14. package/dist/cjs/react/v19.js +9 -5
  15. package/dist/cjs/runtime/index.js +9 -5
  16. package/dist/cjs/server/fileCache.js +13 -9
  17. package/dist/cjs/server/index.js +9 -5
  18. package/dist/cjs/server/staticMiddleware.js +11 -7
  19. package/dist/cjs/ssr-runtime/SSRLiveReload.js +9 -5
  20. package/dist/cjs/ssr-runtime/devPlugin.js +9 -5
  21. package/dist/cjs/ssr-runtime/injectDataFetchFunctionPlugin.js +9 -5
  22. package/dist/esm/cli/configPlugin.mjs +19 -15
  23. package/dist/esm/cli/index.mjs +2 -1
  24. package/dist/esm/cli/mfRuntimePlugins/inject-node-fetch.mjs +2 -3
  25. package/dist/esm/cli/mfRuntimePlugins/shared-strategy.mjs +1 -1
  26. package/dist/esm/cli/server/data-fetch-server-plugin.mjs +1 -1
  27. package/dist/esm/cli/ssrPlugin.mjs +2 -1
  28. package/dist/esm/cli/utils.mjs +1 -1
  29. package/dist/esm/interfaces/bundler.mjs +1 -0
  30. package/dist/esm/logger.mjs +1 -1
  31. package/dist/esm/react/plugin.mjs +1 -2
  32. package/dist/esm/rslib-runtime.mjs +18 -0
  33. package/dist/esm/server/fileCache.mjs +5 -4
  34. package/dist/esm/server/index.mjs +2 -1
  35. package/dist/esm/types/index.mjs +1 -0
  36. package/dist/esm-node/cli/configPlugin.mjs +18 -15
  37. package/dist/esm-node/cli/index.mjs +2 -1
  38. package/dist/esm-node/cli/mfRuntimePlugins/inject-node-fetch.mjs +2 -3
  39. package/dist/esm-node/cli/mfRuntimePlugins/shared-strategy.mjs +1 -1
  40. package/dist/esm-node/cli/server/data-fetch-server-plugin.mjs +1 -1
  41. package/dist/esm-node/cli/ssrPlugin.mjs +2 -1
  42. package/dist/esm-node/interfaces/bundler.mjs +1 -0
  43. package/dist/esm-node/logger.mjs +1 -1
  44. package/dist/esm-node/react/plugin.mjs +1 -2
  45. package/dist/esm-node/rslib-runtime.mjs +18 -0
  46. package/dist/esm-node/server/fileCache.mjs +4 -4
  47. package/dist/esm-node/server/index.mjs +2 -1
  48. package/dist/esm-node/types/index.mjs +1 -0
  49. package/dist/types/cli/configPlugin.d.ts +1 -0
  50. package/dist/types/server/fileCache.d.ts +1 -0
  51. package/dist/types/types/index.d.ts +6 -0
  52. package/package.json +17 -18
  53. package/dist/types/cli/configPlugin.spec.d.ts +0 -1
  54. package/dist/types/cli/ssrPlugin.spec.d.ts +0 -1
  55. package/dist/types/server/fileCache.spec.d.ts +0 -1
  56. package/dist/types/server/staticMiddleware.spec.d.ts +0 -1
@@ -24,11 +24,15 @@ function __webpack_require__(moduleId) {
24
24
  };
25
25
  })();
26
26
  (()=>{
27
- __webpack_require__.d = (exports1, definition)=>{
28
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
29
- enumerable: true,
30
- get: definition[key]
31
- });
27
+ __webpack_require__.d = (exports1, getters, values)=>{
28
+ var define = (defs, kind)=>{
29
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
30
+ enumerable: true,
31
+ [kind]: defs[key]
32
+ });
33
+ };
34
+ define(getters, "get");
35
+ define(values, "value");
32
36
  };
33
37
  })();
34
38
  (()=>{
@@ -48,15 +52,16 @@ var __webpack_exports__ = {};
48
52
  (()=>{
49
53
  __webpack_require__.r(__webpack_exports__);
50
54
  __webpack_require__.d(__webpack_exports__, {
51
- patchMFConfig: ()=>patchMFConfig,
55
+ addMyTypes2Ignored: ()=>addMyTypes2Ignored,
52
56
  default: ()=>configPlugin,
53
57
  getMFConfig: ()=>getMFConfig,
54
58
  isWebTarget: ()=>external_utils_js_namespaceObject.isWebTarget,
55
59
  moduleFederationConfigPlugin: ()=>moduleFederationConfigPlugin,
56
- addMyTypes2Ignored: ()=>addMyTypes2Ignored,
57
- skipByTarget: ()=>external_utils_js_namespaceObject.skipByTarget,
60
+ patchBundlerConfig: ()=>patchBundlerConfig,
61
+ patchMFConfig: ()=>patchMFConfig,
62
+ setDefaultOptimizationTarget: ()=>setDefaultOptimizationTarget,
58
63
  setEnv: ()=>setEnv,
59
- patchBundlerConfig: ()=>patchBundlerConfig
64
+ skipByTarget: ()=>external_utils_js_namespaceObject.skipByTarget
60
65
  });
61
66
  const external_fs_namespaceObject = require("fs");
62
67
  var external_fs_default = /*#__PURE__*/ __webpack_require__.n(external_fs_namespaceObject);
@@ -163,6 +168,13 @@ var __webpack_exports__ = {};
163
168
  mfConfig.dev = false;
164
169
  return mfConfig;
165
170
  };
171
+ const setDefaultOptimizationTarget = (mfConfig, enableSSR, isServer, autoOptimization = true)=>{
172
+ var _mfConfig, _mfConfig_experiments, _mfConfig_experiments_optimization;
173
+ if (!autoOptimization) return;
174
+ (_mfConfig = mfConfig).experiments || (_mfConfig.experiments = {});
175
+ (_mfConfig_experiments = mfConfig.experiments).optimization || (_mfConfig_experiments.optimization = {});
176
+ null != (_mfConfig_experiments_optimization = mfConfig.experiments.optimization).target || (_mfConfig_experiments_optimization.target = enableSSR && isServer ? 'node' : 'web');
177
+ };
166
178
  function patchIgnoreWarning(chain) {
167
179
  const ignoreWarnings = chain.get('ignoreWarnings') || [];
168
180
  const ignoredMsgs = [
@@ -231,7 +243,10 @@ var __webpack_exports__ = {};
231
243
  }
232
244
  }
233
245
  if ((0, external_utils_js_namespaceObject.isDev)() && enableSSR && !isServer) chain.resolve.fallback.set('crypto', false).set('stream', false).set('vm', false);
234
- if ((null == (_modernjsConfig_deploy = modernjsConfig.deploy) ? void 0 : _modernjsConfig_deploy.microFrontend) && Object.keys(mfConfig.exposes || {}).length) chain.optimization.usedExports(false);
246
+ if ((null == (_modernjsConfig_deploy = modernjsConfig.deploy) ? void 0 : _modernjsConfig_deploy.microFrontend) && Object.keys(mfConfig.exposes || {}).length) {
247
+ external_logger_js_default().info('optimization.usedExports is set to "global" to avoid tree shaking issues in micro frontend mode.');
248
+ chain.optimization.usedExports('global');
249
+ }
235
250
  }
236
251
  const moduleFederationConfigPlugin = (userConfig)=>({
237
252
  name: '@modern-js/plugin-module-federation-config',
@@ -259,6 +274,7 @@ var __webpack_exports__ = {};
259
274
  const isWeb = (0, external_utils_js_namespaceObject.isWebTarget)(target);
260
275
  addMyTypes2Ignored(chain, isWeb ? csrConfig : ssrConfig);
261
276
  const targetMFConfig = isWeb ? csrConfig : ssrConfig;
277
+ setDefaultOptimizationTarget(targetMFConfig, enableSSR, !isWeb, userConfig.originPluginOptions.autoOptimization);
262
278
  patchMFConfig(targetMFConfig, !isWeb);
263
279
  if ('rspack' === bundlerType && (null == (_modernjsConfig_source = modernjsConfig.source) ? void 0 : _modernjsConfig_source.enableAsyncEntry) !== true && (null == (_targetMFConfig_experiments = targetMFConfig.experiments) ? void 0 : _targetMFConfig_experiments.asyncStartup) !== false) {
264
280
  var _targetMFConfig;
@@ -328,6 +344,7 @@ exports.isWebTarget = __webpack_exports__.isWebTarget;
328
344
  exports.moduleFederationConfigPlugin = __webpack_exports__.moduleFederationConfigPlugin;
329
345
  exports.patchBundlerConfig = __webpack_exports__.patchBundlerConfig;
330
346
  exports.patchMFConfig = __webpack_exports__.patchMFConfig;
347
+ exports.setDefaultOptimizationTarget = __webpack_exports__.setDefaultOptimizationTarget;
331
348
  exports.setEnv = __webpack_exports__.setEnv;
332
349
  exports.skipByTarget = __webpack_exports__.skipByTarget;
333
350
  for(var __rspack_i in __webpack_exports__)if (-1 === [
@@ -338,6 +355,7 @@ for(var __rspack_i in __webpack_exports__)if (-1 === [
338
355
  "moduleFederationConfigPlugin",
339
356
  "patchBundlerConfig",
340
357
  "patchMFConfig",
358
+ "setDefaultOptimizationTarget",
341
359
  "setEnv",
342
360
  "skipByTarget"
343
361
  ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
@@ -1,11 +1,15 @@
1
1
  "use strict";
2
2
  var __webpack_require__ = {};
3
3
  (()=>{
4
- __webpack_require__.d = (exports1, definition)=>{
5
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
- enumerable: true,
7
- get: definition[key]
8
- });
4
+ __webpack_require__.d = (exports1, getters, values)=>{
5
+ var define = (defs, kind)=>{
6
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
+ enumerable: true,
8
+ [kind]: defs[key]
9
+ });
10
+ };
11
+ define(getters, "get");
12
+ define(values, "value");
9
13
  };
10
14
  })();
11
15
  (()=>{
@@ -24,9 +28,9 @@ var __webpack_require__ = {};
24
28
  var __webpack_exports__ = {};
25
29
  __webpack_require__.r(__webpack_exports__);
26
30
  __webpack_require__.d(__webpack_exports__, {
27
- moduleFederationPlugin: ()=>moduleFederationPlugin,
28
31
  createModuleFederationConfig: ()=>enhanced_namespaceObject.createModuleFederationConfig,
29
- default: ()=>cli
32
+ default: ()=>cli,
33
+ moduleFederationPlugin: ()=>moduleFederationPlugin
30
34
  });
31
35
  const enhanced_namespaceObject = require("@module-federation/enhanced");
32
36
  const rspack_namespaceObject = require("@module-federation/enhanced/rspack");
@@ -1,20 +1,15 @@
1
1
  "use strict";
2
2
  var __webpack_require__ = {};
3
3
  (()=>{
4
- __webpack_require__.n = (module)=>{
5
- var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
- __webpack_require__.d(getter, {
7
- a: getter
8
- });
9
- return getter;
10
- };
11
- })();
12
- (()=>{
13
- __webpack_require__.d = (exports1, definition)=>{
14
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
- enumerable: true,
16
- get: definition[key]
17
- });
4
+ __webpack_require__.d = (exports1, getters, values)=>{
5
+ var define = (defs, kind)=>{
6
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
+ enumerable: true,
8
+ [kind]: defs[key]
9
+ });
10
+ };
11
+ define(getters, "get");
12
+ define(values, "value");
18
13
  };
19
14
  })();
20
15
  (()=>{
@@ -32,19 +27,17 @@ var __webpack_require__ = {};
32
27
  })();
33
28
  var __webpack_exports__ = {};
34
29
  __webpack_require__.r(__webpack_exports__);
35
- __webpack_require__.d(__webpack_exports__, {
36
- default: ()=>inject_node_fetch
37
- });
38
- const external_node_fetch_namespaceObject = require("node-fetch");
39
- var external_node_fetch_default = /*#__PURE__*/ __webpack_require__.n(external_node_fetch_namespaceObject);
40
30
  const injectNodeFetchPlugin = ()=>({
41
31
  name: 'inject-node-fetch-plugin',
42
32
  beforeInit (args) {
43
- if (!globalThis.fetch) globalThis.fetch = external_node_fetch_default();
33
+ if (!globalThis.fetch) throw new Error('@module-federation/modern-js requires Node.js 18 or later.');
44
34
  return args;
45
35
  }
46
36
  });
47
- const inject_node_fetch = injectNodeFetchPlugin;
37
+ const __rspack_default_export = injectNodeFetchPlugin;
38
+ __webpack_require__.d(__webpack_exports__, {}, {
39
+ default: __rspack_default_export
40
+ });
48
41
  exports["default"] = __webpack_exports__["default"];
49
42
  for(var __rspack_i in __webpack_exports__)if (-1 === [
50
43
  "default"
@@ -1,11 +1,15 @@
1
1
  "use strict";
2
2
  var __webpack_require__ = {};
3
3
  (()=>{
4
- __webpack_require__.d = (exports1, definition)=>{
5
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
- enumerable: true,
7
- get: definition[key]
8
- });
4
+ __webpack_require__.d = (exports1, getters, values)=>{
5
+ var define = (defs, kind)=>{
6
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
+ enumerable: true,
8
+ [kind]: defs[key]
9
+ });
10
+ };
11
+ define(getters, "get");
12
+ define(values, "value");
9
13
  };
10
14
  })();
11
15
  (()=>{
@@ -23,9 +27,6 @@ var __webpack_require__ = {};
23
27
  })();
24
28
  var __webpack_exports__ = {};
25
29
  __webpack_require__.r(__webpack_exports__);
26
- __webpack_require__.d(__webpack_exports__, {
27
- default: ()=>__rspack_default_export
28
- });
29
30
  const sharedStrategy = ()=>({
30
31
  name: 'shared-strategy-plugin',
31
32
  beforeInit (args) {
@@ -44,6 +45,9 @@ const sharedStrategy = ()=>({
44
45
  }
45
46
  });
46
47
  const __rspack_default_export = sharedStrategy;
48
+ __webpack_require__.d(__webpack_exports__, {}, {
49
+ default: __rspack_default_export
50
+ });
47
51
  exports["default"] = __webpack_exports__["default"];
48
52
  for(var __rspack_i in __webpack_exports__)if (-1 === [
49
53
  "default"
@@ -10,11 +10,15 @@ var __webpack_require__ = {};
10
10
  };
11
11
  })();
12
12
  (()=>{
13
- __webpack_require__.d = (exports1, definition)=>{
14
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
- enumerable: true,
16
- get: definition[key]
17
- });
13
+ __webpack_require__.d = (exports1, getters, values)=>{
14
+ var define = (defs, kind)=>{
15
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
16
+ enumerable: true,
17
+ [kind]: defs[key]
18
+ });
19
+ };
20
+ define(getters, "get");
21
+ define(values, "value");
18
22
  };
19
23
  })();
20
24
  (()=>{
@@ -10,11 +10,15 @@ var __webpack_require__ = {};
10
10
  };
11
11
  })();
12
12
  (()=>{
13
- __webpack_require__.d = (exports1, definition)=>{
14
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
- enumerable: true,
16
- get: definition[key]
17
- });
13
+ __webpack_require__.d = (exports1, getters, values)=>{
14
+ var define = (defs, kind)=>{
15
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
16
+ enumerable: true,
17
+ [kind]: defs[key]
18
+ });
19
+ };
20
+ define(getters, "get");
21
+ define(values, "value");
18
22
  };
19
23
  })();
20
24
  (()=>{
@@ -33,10 +37,10 @@ var __webpack_require__ = {};
33
37
  var __webpack_exports__ = {};
34
38
  __webpack_require__.r(__webpack_exports__);
35
39
  __webpack_require__.d(__webpack_exports__, {
40
+ CHAIN_MF_PLUGIN_ID: ()=>CHAIN_MF_PLUGIN_ID,
36
41
  default: ()=>ssrPlugin,
37
42
  moduleFederationSSRPlugin: ()=>moduleFederationSSRPlugin,
38
- setEnv: ()=>setEnv,
39
- CHAIN_MF_PLUGIN_ID: ()=>CHAIN_MF_PLUGIN_ID
43
+ setEnv: ()=>setEnv
40
44
  });
41
45
  const external_path_namespaceObject = require("path");
42
46
  var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
@@ -10,11 +10,15 @@ var __webpack_require__ = {};
10
10
  };
11
11
  })();
12
12
  (()=>{
13
- __webpack_require__.d = (exports1, definition)=>{
14
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
- enumerable: true,
16
- get: definition[key]
17
- });
13
+ __webpack_require__.d = (exports1, getters, values)=>{
14
+ var define = (defs, kind)=>{
15
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
16
+ enumerable: true,
17
+ [kind]: defs[key]
18
+ });
19
+ };
20
+ define(getters, "get");
21
+ define(values, "value");
18
22
  };
19
23
  })();
20
24
  (()=>{
@@ -1,11 +1,15 @@
1
1
  "use strict";
2
2
  var __webpack_require__ = {};
3
3
  (()=>{
4
- __webpack_require__.d = (exports1, definition)=>{
5
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
- enumerable: true,
7
- get: definition[key]
8
- });
4
+ __webpack_require__.d = (exports1, getters, values)=>{
5
+ var define = (defs, kind)=>{
6
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
+ enumerable: true,
8
+ [kind]: defs[key]
9
+ });
10
+ };
11
+ define(getters, "get");
12
+ define(values, "value");
9
13
  };
10
14
  })();
11
15
  (()=>{
@@ -23,12 +27,12 @@ var __webpack_require__ = {};
23
27
  })();
24
28
  var __webpack_exports__ = {};
25
29
  __webpack_require__.r(__webpack_exports__);
26
- __webpack_require__.d(__webpack_exports__, {
27
- LOCALHOST: ()=>LOCALHOST,
28
- PLUGIN_IDENTIFIER: ()=>PLUGIN_IDENTIFIER
29
- });
30
30
  const LOCALHOST = 'localhost';
31
31
  const PLUGIN_IDENTIFIER = '[ Modern.js Module Federation ]';
32
+ __webpack_require__.d(__webpack_exports__, {}, {
33
+ LOCALHOST: LOCALHOST,
34
+ PLUGIN_IDENTIFIER: PLUGIN_IDENTIFIER
35
+ });
32
36
  exports.LOCALHOST = __webpack_exports__.LOCALHOST;
33
37
  exports.PLUGIN_IDENTIFIER = __webpack_exports__.PLUGIN_IDENTIFIER;
34
38
  for(var __rspack_i in __webpack_exports__)if (-1 === [
@@ -1,11 +1,15 @@
1
1
  "use strict";
2
2
  var __webpack_require__ = {};
3
3
  (()=>{
4
- __webpack_require__.d = (exports1, definition)=>{
5
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
- enumerable: true,
7
- get: definition[key]
8
- });
4
+ __webpack_require__.d = (exports1, getters, values)=>{
5
+ var define = (defs, kind)=>{
6
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
+ enumerable: true,
8
+ [kind]: defs[key]
9
+ });
10
+ };
11
+ define(getters, "get");
12
+ define(values, "value");
9
13
  };
10
14
  })();
11
15
  (()=>{
@@ -24,11 +24,15 @@ function __webpack_require__(moduleId) {
24
24
  };
25
25
  })();
26
26
  (()=>{
27
- __webpack_require__.d = (exports1, definition)=>{
28
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
29
- enumerable: true,
30
- get: definition[key]
31
- });
27
+ __webpack_require__.d = (exports1, getters, values)=>{
28
+ var define = (defs, kind)=>{
29
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
30
+ enumerable: true,
31
+ [kind]: defs[key]
32
+ });
33
+ };
34
+ define(getters, "get");
35
+ define(values, "value");
32
36
  };
33
37
  })();
34
38
  (()=>{
@@ -24,11 +24,15 @@ function __webpack_require__(moduleId) {
24
24
  };
25
25
  })();
26
26
  (()=>{
27
- __webpack_require__.d = (exports1, definition)=>{
28
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
29
- enumerable: true,
30
- get: definition[key]
31
- });
27
+ __webpack_require__.d = (exports1, getters, values)=>{
28
+ var define = (defs, kind)=>{
29
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
30
+ enumerable: true,
31
+ [kind]: defs[key]
32
+ });
33
+ };
34
+ define(getters, "get");
35
+ define(values, "value");
32
36
  };
33
37
  })();
34
38
  (()=>{
@@ -24,11 +24,15 @@ function __webpack_require__(moduleId) {
24
24
  };
25
25
  })();
26
26
  (()=>{
27
- __webpack_require__.d = (exports1, definition)=>{
28
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
29
- enumerable: true,
30
- get: definition[key]
31
- });
27
+ __webpack_require__.d = (exports1, getters, values)=>{
28
+ var define = (defs, kind)=>{
29
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
30
+ enumerable: true,
31
+ [kind]: defs[key]
32
+ });
33
+ };
34
+ define(getters, "get");
35
+ define(values, "value");
32
36
  };
33
37
  })();
34
38
  (()=>{
@@ -47,14 +51,14 @@ function __webpack_require__(moduleId) {
47
51
  var __webpack_exports__ = {};
48
52
  (()=>{
49
53
  __webpack_require__.r(__webpack_exports__);
50
- __webpack_require__.d(__webpack_exports__, {
51
- default: ()=>_module_federation_bridge_react_plugin__rspack_import_0_default.a
52
- });
53
54
  var _module_federation_bridge_react_plugin__rspack_import_0 = __webpack_require__("@module-federation/bridge-react/plugin");
54
55
  var _module_federation_bridge_react_plugin__rspack_import_0_default = /*#__PURE__*/ __webpack_require__.n(_module_federation_bridge_react_plugin__rspack_import_0);
55
56
  var __rspack_reexport = {};
56
57
  for(const __rspack_import_key in _module_federation_bridge_react_plugin__rspack_import_0)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_module_federation_bridge_react_plugin__rspack_import_0[__rspack_import_key];
57
58
  __webpack_require__.d(__webpack_exports__, __rspack_reexport);
59
+ __webpack_require__.d(__webpack_exports__, {
60
+ default: ()=>_module_federation_bridge_react_plugin__rspack_import_0_default.a
61
+ });
58
62
  })();
59
63
  exports["default"] = __webpack_exports__["default"];
60
64
  for(var __rspack_i in __webpack_exports__)if (-1 === [
@@ -24,11 +24,15 @@ function __webpack_require__(moduleId) {
24
24
  };
25
25
  })();
26
26
  (()=>{
27
- __webpack_require__.d = (exports1, definition)=>{
28
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
29
- enumerable: true,
30
- get: definition[key]
31
- });
27
+ __webpack_require__.d = (exports1, getters, values)=>{
28
+ var define = (defs, kind)=>{
29
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
30
+ enumerable: true,
31
+ [kind]: defs[key]
32
+ });
33
+ };
34
+ define(getters, "get");
35
+ define(values, "value");
32
36
  };
33
37
  })();
34
38
  (()=>{
@@ -24,11 +24,15 @@ function __webpack_require__(moduleId) {
24
24
  };
25
25
  })();
26
26
  (()=>{
27
- __webpack_require__.d = (exports1, definition)=>{
28
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
29
- enumerable: true,
30
- get: definition[key]
31
- });
27
+ __webpack_require__.d = (exports1, getters, values)=>{
28
+ var define = (defs, kind)=>{
29
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
30
+ enumerable: true,
31
+ [kind]: defs[key]
32
+ });
33
+ };
34
+ define(getters, "get");
35
+ define(values, "value");
32
36
  };
33
37
  })();
34
38
  (()=>{
@@ -24,11 +24,15 @@ function __webpack_require__(moduleId) {
24
24
  };
25
25
  })();
26
26
  (()=>{
27
- __webpack_require__.d = (exports1, definition)=>{
28
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
29
- enumerable: true,
30
- get: definition[key]
31
- });
27
+ __webpack_require__.d = (exports1, getters, values)=>{
28
+ var define = (defs, kind)=>{
29
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
30
+ enumerable: true,
31
+ [kind]: defs[key]
32
+ });
33
+ };
34
+ define(getters, "get");
35
+ define(values, "value");
32
36
  };
33
37
  })();
34
38
  (()=>{
@@ -1,11 +1,15 @@
1
1
  "use strict";
2
2
  var __webpack_require__ = {};
3
3
  (()=>{
4
- __webpack_require__.d = (exports1, definition)=>{
5
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
- enumerable: true,
7
- get: definition[key]
8
- });
4
+ __webpack_require__.d = (exports1, getters, values)=>{
5
+ var define = (defs, kind)=>{
6
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
+ enumerable: true,
8
+ [kind]: defs[key]
9
+ });
10
+ };
11
+ define(getters, "get");
12
+ define(values, "value");
9
13
  };
10
14
  })();
11
15
  (()=>{
@@ -28,7 +32,7 @@ __webpack_require__.d(__webpack_exports__, {
28
32
  fileCache: ()=>fileCache
29
33
  });
30
34
  const promises_namespaceObject = require("fs/promises");
31
- const external_lru_cache_namespaceObject = require("lru-cache");
35
+ const size_limited_cache_namespaceObject = require("@module-federation/bridge-react/size-limited-cache");
32
36
  const pathExists = async (filepath)=>{
33
37
  try {
34
38
  await (0, promises_namespaceObject.access)(filepath);
@@ -64,9 +68,9 @@ class FileCache {
64
68
  return null;
65
69
  }
66
70
  }
67
- constructor(){
68
- this.cache = new external_lru_cache_namespaceObject.LRUCache({
69
- maxSize: 209715200
71
+ constructor(maxSize = 209715200){
72
+ this.cache = new size_limited_cache_namespaceObject.SizeLimitedCache({
73
+ maxSize
70
74
  });
71
75
  }
72
76
  }
@@ -1,11 +1,15 @@
1
1
  "use strict";
2
2
  var __webpack_require__ = {};
3
3
  (()=>{
4
- __webpack_require__.d = (exports1, definition)=>{
5
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
- enumerable: true,
7
- get: definition[key]
8
- });
4
+ __webpack_require__.d = (exports1, getters, values)=>{
5
+ var define = (defs, kind)=>{
6
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
+ enumerable: true,
8
+ [kind]: defs[key]
9
+ });
10
+ };
11
+ define(getters, "get");
12
+ define(values, "value");
9
13
  };
10
14
  })();
11
15
  (()=>{
@@ -10,11 +10,15 @@ var __webpack_require__ = {};
10
10
  };
11
11
  })();
12
12
  (()=>{
13
- __webpack_require__.d = (exports1, definition)=>{
14
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
- enumerable: true,
16
- get: definition[key]
17
- });
13
+ __webpack_require__.d = (exports1, getters, values)=>{
14
+ var define = (defs, kind)=>{
15
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
16
+ enumerable: true,
17
+ [kind]: defs[key]
18
+ });
19
+ };
20
+ define(getters, "get");
21
+ define(values, "value");
18
22
  };
19
23
  })();
20
24
  (()=>{
@@ -33,8 +37,8 @@ var __webpack_require__ = {};
33
37
  var __webpack_exports__ = {};
34
38
  __webpack_require__.r(__webpack_exports__);
35
39
  __webpack_require__.d(__webpack_exports__, {
36
- createStaticMiddleware: ()=>createStaticMiddleware,
37
- createCorsMiddleware: ()=>createCorsMiddleware
40
+ createCorsMiddleware: ()=>createCorsMiddleware,
41
+ createStaticMiddleware: ()=>createStaticMiddleware
38
42
  });
39
43
  const promises_namespaceObject = require("fs/promises");
40
44
  const external_path_namespaceObject = require("path");
@@ -1,11 +1,15 @@
1
1
  "use strict";
2
2
  var __webpack_require__ = {};
3
3
  (()=>{
4
- __webpack_require__.d = (exports1, definition)=>{
5
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
- enumerable: true,
7
- get: definition[key]
8
- });
4
+ __webpack_require__.d = (exports1, getters, values)=>{
5
+ var define = (defs, kind)=>{
6
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
+ enumerable: true,
8
+ [kind]: defs[key]
9
+ });
10
+ };
11
+ define(getters, "get");
12
+ define(values, "value");
9
13
  };
10
14
  })();
11
15
  (()=>{
@@ -1,11 +1,15 @@
1
1
  "use strict";
2
2
  var __webpack_require__ = {};
3
3
  (()=>{
4
- __webpack_require__.d = (exports1, definition)=>{
5
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
- enumerable: true,
7
- get: definition[key]
8
- });
4
+ __webpack_require__.d = (exports1, getters, values)=>{
5
+ var define = (defs, kind)=>{
6
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
+ enumerable: true,
8
+ [kind]: defs[key]
9
+ });
10
+ };
11
+ define(getters, "get");
12
+ define(values, "value");
9
13
  };
10
14
  })();
11
15
  (()=>{
@@ -1,11 +1,15 @@
1
1
  "use strict";
2
2
  var __webpack_require__ = {};
3
3
  (()=>{
4
- __webpack_require__.d = (exports1, definition)=>{
5
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
- enumerable: true,
7
- get: definition[key]
8
- });
4
+ __webpack_require__.d = (exports1, getters, values)=>{
5
+ var define = (defs, kind)=>{
6
+ for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
7
+ enumerable: true,
8
+ [kind]: defs[key]
9
+ });
10
+ };
11
+ define(getters, "get");
12
+ define(values, "value");
9
13
  };
10
14
  })();
11
15
  (()=>{
@@ -1,4 +1,3 @@
1
- import * as __rspack_external_jiti from "jiti";
2
1
  import { _ } from "@swc/helpers/_/_async_to_generator";
3
2
  import { _ as _object_spread__ } from "@swc/helpers/_/_object_spread";
4
3
  import { _ as _object_spread_props__ } from "@swc/helpers/_/_object_spread_props";
@@ -12,21 +11,13 @@ import { encodeName } from "@module-federation/sdk";
12
11
  import { PLUGIN_IDENTIFIER } from "../constant.mjs";
13
12
  import { addDataFetchExposes, autoDeleteSplitChunkCacheGroups } from "@module-federation/rsbuild-plugin/utils";
14
13
  import logger from "../logger.mjs";
15
- var __webpack_modules__ = {
14
+ import { __webpack_require__ } from "../rslib-runtime.mjs";
15
+ import * as __rspack_external_jiti from "jiti";
16
+ __webpack_require__.add({
16
17
  jiti: function(module) {
17
18
  module.exports = __rspack_external_jiti;
18
19
  }
19
- };
20
- var __webpack_module_cache__ = {};
21
- function __webpack_require__(moduleId) {
22
- var cachedModule = __webpack_module_cache__[moduleId];
23
- if (void 0 !== cachedModule) return cachedModule.exports;
24
- var module = __webpack_module_cache__[moduleId] = {
25
- exports: {}
26
- };
27
- __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
28
- return module.exports;
29
- }
20
+ });
30
21
  var defaultPath = path.resolve(process.cwd(), 'module-federation.config.ts');
31
22
  var configPlugin_resolvePackageFile = function(packageName, esmRelativePath, cjsRelativePath) {
32
23
  var packageEntry = require.resolve(packageName);
@@ -147,6 +138,14 @@ var configPlugin_patchMFConfig = function(mfConfig, isServer) {
147
138
  mfConfig.dev = false;
148
139
  return mfConfig;
149
140
  };
141
+ var configPlugin_setDefaultOptimizationTarget = function(mfConfig, enableSSR, isServer) {
142
+ var autoOptimization = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : true;
143
+ var _mfConfig, _mfConfig_experiments, _mfConfig_experiments_optimization;
144
+ if (!autoOptimization) return;
145
+ (_mfConfig = mfConfig).experiments || (_mfConfig.experiments = {});
146
+ (_mfConfig_experiments = mfConfig.experiments).optimization || (_mfConfig_experiments.optimization = {});
147
+ null != (_mfConfig_experiments_optimization = mfConfig.experiments.optimization).target || (_mfConfig_experiments_optimization.target = enableSSR && isServer ? 'node' : 'web');
148
+ };
150
149
  function patchIgnoreWarning(chain) {
151
150
  var ignoreWarnings = chain.get('ignoreWarnings') || [];
152
151
  var ignoredMsgs = [
@@ -213,7 +212,10 @@ function patchBundlerConfig(options) {
213
212
  }
214
213
  }
215
214
  if (isDev() && enableSSR && !isServer) chain.resolve.fallback.set('crypto', false).set('stream', false).set('vm', false);
216
- if ((null == (_modernjsConfig_deploy = modernjsConfig.deploy) ? void 0 : _modernjsConfig_deploy.microFrontend) && Object.keys(mfConfig.exposes || {}).length) chain.optimization.usedExports(false);
215
+ if ((null == (_modernjsConfig_deploy = modernjsConfig.deploy) ? void 0 : _modernjsConfig_deploy.microFrontend) && Object.keys(mfConfig.exposes || {}).length) {
216
+ logger.info('optimization.usedExports is set to "global" to avoid tree shaking issues in micro frontend mode.');
217
+ chain.optimization.usedExports('global');
218
+ }
217
219
  }
218
220
  var configPlugin_moduleFederationConfigPlugin = function(userConfig) {
219
221
  return {
@@ -250,6 +252,7 @@ var configPlugin_moduleFederationConfigPlugin = function(userConfig) {
250
252
  var isWeb = isWebTarget(target);
251
253
  addMyTypes2Ignored(chain, isWeb ? csrConfig : ssrConfig);
252
254
  var targetMFConfig = isWeb ? csrConfig : ssrConfig;
255
+ configPlugin_setDefaultOptimizationTarget(targetMFConfig, enableSSR, !isWeb, userConfig.originPluginOptions.autoOptimization);
253
256
  configPlugin_patchMFConfig(targetMFConfig, !isWeb);
254
257
  if ('rspack' === bundlerType && (null == (_modernjsConfig_source = modernjsConfig.source) ? void 0 : _modernjsConfig_source.enableAsyncEntry) !== true && (null == (_targetMFConfig_experiments = targetMFConfig.experiments) ? void 0 : _targetMFConfig_experiments.asyncStartup) !== false) {
255
258
  var _targetMFConfig;
@@ -318,4 +321,5 @@ var configPlugin_moduleFederationConfigPlugin = function(userConfig) {
318
321
  };
319
322
  };
320
323
  var configPlugin = configPlugin_moduleFederationConfigPlugin;
321
- export { addMyTypes2Ignored, configPlugin as default, configPlugin_getMFConfig as getMFConfig, isWebTarget, configPlugin_moduleFederationConfigPlugin as moduleFederationConfigPlugin, patchBundlerConfig, configPlugin_patchMFConfig as patchMFConfig, setEnv, skipByTarget };
324
+ export default configPlugin;
325
+ export { addMyTypes2Ignored, configPlugin_getMFConfig as getMFConfig, configPlugin_moduleFederationConfigPlugin as moduleFederationConfigPlugin, configPlugin_patchMFConfig as patchMFConfig, configPlugin_setDefaultOptimizationTarget as setDefaultOptimizationTarget, isWebTarget, patchBundlerConfig, setEnv, skipByTarget };
@@ -88,4 +88,5 @@ var cli_moduleFederationPlugin = function() {
88
88
  };
89
89
  };
90
90
  var cli = cli_moduleFederationPlugin;
91
- export { createModuleFederationConfig, cli as default, cli_moduleFederationPlugin as moduleFederationPlugin };
91
+ export default cli;
92
+ export { cli_moduleFederationPlugin as moduleFederationPlugin, createModuleFederationConfig };
@@ -1,12 +1,11 @@
1
- import node_fetch from "node-fetch";
2
1
  var inject_node_fetch_injectNodeFetchPlugin = function() {
3
2
  return {
4
3
  name: 'inject-node-fetch-plugin',
5
4
  beforeInit: function(args) {
6
- if (!globalThis.fetch) globalThis.fetch = node_fetch;
5
+ if (!globalThis.fetch) throw new Error('@module-federation/modern-js requires Node.js 18 or later.');
7
6
  return args;
8
7
  }
9
8
  };
10
9
  };
11
10
  var inject_node_fetch = inject_node_fetch_injectNodeFetchPlugin;
12
- export { inject_node_fetch as default };
11
+ export default inject_node_fetch;
@@ -18,4 +18,4 @@ var shared_strategy_sharedStrategy = function() {
18
18
  };
19
19
  };
20
20
  var shared_strategy = shared_strategy_sharedStrategy;
21
- export { shared_strategy as default };
21
+ export default shared_strategy;
@@ -14,4 +14,4 @@ var data_fetch_server_plugin_dataFetchServePlugin = function() {
14
14
  };
15
15
  };
16
16
  var data_fetch_server_plugin = data_fetch_server_plugin_dataFetchServePlugin;
17
- export { data_fetch_server_plugin as default };
17
+ export default data_fetch_server_plugin;
@@ -294,4 +294,5 @@ var ssrPlugin_moduleFederationSSRPlugin = function(pluginOptions) {
294
294
  };
295
295
  };
296
296
  var ssrPlugin = ssrPlugin_moduleFederationSSRPlugin;
297
- export { CHAIN_MF_PLUGIN_ID, ssrPlugin as default, ssrPlugin_moduleFederationSSRPlugin as moduleFederationSSRPlugin, setEnv };
297
+ export default ssrPlugin;
298
+ export { CHAIN_MF_PLUGIN_ID, setEnv, ssrPlugin_moduleFederationSSRPlugin as moduleFederationSSRPlugin };
@@ -37,4 +37,4 @@ var utils_skipByTarget = function(target) {
37
37
  function isDev() {
38
38
  return 'development' === process.env.NODE_ENV;
39
39
  }
40
- export { utils_getIPV4 as getIPV4, isDev, utils_isWebTarget as isWebTarget, utils_skipByTarget as skipByTarget };
40
+ export { isDev, utils_getIPV4 as getIPV4, utils_isWebTarget as isWebTarget, utils_skipByTarget as skipByTarget };
@@ -0,0 +1 @@
1
+ export { };
@@ -2,4 +2,4 @@ import { createLogger } from "@module-federation/sdk";
2
2
  import { PLUGIN_IDENTIFIER } from "./constant.mjs";
3
3
  var logger = createLogger(PLUGIN_IDENTIFIER);
4
4
  var src_logger = logger;
5
- export { src_logger as default };
5
+ export default src_logger;
@@ -1,3 +1,2 @@
1
- import bridge_react_plugin from "@module-federation/bridge-react/plugin";
2
1
  export * from "@module-federation/bridge-react/plugin";
3
- export { bridge_react_plugin as default };
2
+ export { default } from "@module-federation/bridge-react/plugin";
@@ -0,0 +1,18 @@
1
+ var __webpack_modules__ = {};
2
+ var __webpack_module_cache__ = {};
3
+ function __webpack_require__(moduleId) {
4
+ var cachedModule = __webpack_module_cache__[moduleId];
5
+ if (void 0 !== cachedModule) return cachedModule.exports;
6
+ var module = __webpack_module_cache__[moduleId] = {
7
+ exports: {}
8
+ };
9
+ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
10
+ return module.exports;
11
+ }
12
+ __webpack_require__.m = __webpack_modules__;
13
+ !function() {
14
+ __webpack_require__.add = function(modules) {
15
+ Object.assign(__webpack_require__.m, modules);
16
+ };
17
+ }();
18
+ export { __webpack_require__ };
@@ -2,7 +2,7 @@ import { _ } from "@swc/helpers/_/_async_to_generator";
2
2
  import { _ as _class_call_check__ } from "@swc/helpers/_/_class_call_check";
3
3
  import { _ as _ts_generator__ } from "@swc/helpers/_/_ts_generator";
4
4
  import { access, lstat, readFile } from "fs/promises";
5
- import { LRUCache } from "lru-cache";
5
+ import { SizeLimitedCache } from "@module-federation/bridge-react/size-limited-cache";
6
6
  var fileCache_pathExists = function(filepath) {
7
7
  return _(function() {
8
8
  return _ts_generator__(this, function(_state) {
@@ -41,9 +41,10 @@ var fileCache_pathExists = function(filepath) {
41
41
  var fileCache_FileCache = /*#__PURE__*/ function() {
42
42
  "use strict";
43
43
  function FileCache() {
44
+ var maxSize = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 209715200;
44
45
  _class_call_check__(this, FileCache);
45
- this.cache = new LRUCache({
46
- maxSize: 209715200
46
+ this.cache = new SizeLimitedCache({
47
+ maxSize: maxSize
47
48
  });
48
49
  }
49
50
  var _proto = FileCache.prototype;
@@ -122,4 +123,4 @@ var fileCache_FileCache = /*#__PURE__*/ function() {
122
123
  return FileCache;
123
124
  }();
124
125
  var fileCache = new fileCache_FileCache();
125
- export { fileCache_FileCache as FileCache, fileCache };
126
+ export { fileCache, fileCache_FileCache as FileCache };
@@ -33,4 +33,5 @@ var server_staticServePlugin = function() {
33
33
  };
34
34
  };
35
35
  var server = server_staticServePlugin;
36
- export { server as default, server_staticServePlugin as staticServePlugin };
36
+ export default server;
37
+ export { server_staticServePlugin as staticServePlugin };
@@ -0,0 +1 @@
1
+ export { };
@@ -1,4 +1,3 @@
1
- import * as __rspack_external_jiti from "jiti";
2
1
  import fs from "fs";
3
2
  import path from "path";
4
3
  import { isDev, isWebTarget, skipByTarget } from "./utils.mjs";
@@ -6,21 +5,13 @@ import { encodeName } from "@module-federation/sdk";
6
5
  import { PLUGIN_IDENTIFIER } from "../constant.mjs";
7
6
  import { addDataFetchExposes, autoDeleteSplitChunkCacheGroups } from "@module-federation/rsbuild-plugin/utils";
8
7
  import logger from "../logger.mjs";
9
- var __webpack_modules__ = {
8
+ import { __webpack_require__ } from "../rslib-runtime.mjs";
9
+ import * as __rspack_external_jiti from "jiti";
10
+ __webpack_require__.add({
10
11
  jiti (module) {
11
12
  module.exports = __rspack_external_jiti;
12
13
  }
13
- };
14
- var __webpack_module_cache__ = {};
15
- function __webpack_require__(moduleId) {
16
- var cachedModule = __webpack_module_cache__[moduleId];
17
- if (void 0 !== cachedModule) return cachedModule.exports;
18
- var module = __webpack_module_cache__[moduleId] = {
19
- exports: {}
20
- };
21
- __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
22
- return module.exports;
23
- }
14
+ });
24
15
  const defaultPath = path.resolve(process.cwd(), 'module-federation.config.ts');
25
16
  const resolvePackageFile = (packageName, esmRelativePath, cjsRelativePath)=>{
26
17
  const packageEntry = require.resolve(packageName);
@@ -116,6 +107,13 @@ const patchMFConfig = (mfConfig, isServer)=>{
116
107
  mfConfig.dev = false;
117
108
  return mfConfig;
118
109
  };
110
+ const setDefaultOptimizationTarget = (mfConfig, enableSSR, isServer, autoOptimization = true)=>{
111
+ var _mfConfig, _mfConfig_experiments, _mfConfig_experiments_optimization;
112
+ if (!autoOptimization) return;
113
+ (_mfConfig = mfConfig).experiments || (_mfConfig.experiments = {});
114
+ (_mfConfig_experiments = mfConfig.experiments).optimization || (_mfConfig_experiments.optimization = {});
115
+ null != (_mfConfig_experiments_optimization = mfConfig.experiments.optimization).target || (_mfConfig_experiments_optimization.target = enableSSR && isServer ? 'node' : 'web');
116
+ };
119
117
  function patchIgnoreWarning(chain) {
120
118
  const ignoreWarnings = chain.get('ignoreWarnings') || [];
121
119
  const ignoredMsgs = [
@@ -184,7 +182,10 @@ function patchBundlerConfig(options) {
184
182
  }
185
183
  }
186
184
  if (isDev() && enableSSR && !isServer) chain.resolve.fallback.set('crypto', false).set('stream', false).set('vm', false);
187
- if ((null == (_modernjsConfig_deploy = modernjsConfig.deploy) ? void 0 : _modernjsConfig_deploy.microFrontend) && Object.keys(mfConfig.exposes || {}).length) chain.optimization.usedExports(false);
185
+ if ((null == (_modernjsConfig_deploy = modernjsConfig.deploy) ? void 0 : _modernjsConfig_deploy.microFrontend) && Object.keys(mfConfig.exposes || {}).length) {
186
+ logger.info('optimization.usedExports is set to "global" to avoid tree shaking issues in micro frontend mode.');
187
+ chain.optimization.usedExports('global');
188
+ }
188
189
  }
189
190
  const moduleFederationConfigPlugin = (userConfig)=>({
190
191
  name: '@modern-js/plugin-module-federation-config',
@@ -212,6 +213,7 @@ const moduleFederationConfigPlugin = (userConfig)=>({
212
213
  const isWeb = isWebTarget(target);
213
214
  addMyTypes2Ignored(chain, isWeb ? csrConfig : ssrConfig);
214
215
  const targetMFConfig = isWeb ? csrConfig : ssrConfig;
216
+ setDefaultOptimizationTarget(targetMFConfig, enableSSR, !isWeb, userConfig.originPluginOptions.autoOptimization);
215
217
  patchMFConfig(targetMFConfig, !isWeb);
216
218
  if ('rspack' === bundlerType && (null == (_modernjsConfig_source = modernjsConfig.source) ? void 0 : _modernjsConfig_source.enableAsyncEntry) !== true && (null == (_targetMFConfig_experiments = targetMFConfig.experiments) ? void 0 : _targetMFConfig_experiments.asyncStartup) !== false) {
217
219
  var _targetMFConfig;
@@ -273,4 +275,5 @@ const moduleFederationConfigPlugin = (userConfig)=>({
273
275
  }
274
276
  });
275
277
  const configPlugin = moduleFederationConfigPlugin;
276
- export { addMyTypes2Ignored, configPlugin as default, getMFConfig, isWebTarget, moduleFederationConfigPlugin, patchBundlerConfig, patchMFConfig, setEnv, skipByTarget };
278
+ export default configPlugin;
279
+ export { addMyTypes2Ignored, getMFConfig, isWebTarget, moduleFederationConfigPlugin, patchBundlerConfig, patchMFConfig, setDefaultOptimizationTarget, setEnv, skipByTarget };
@@ -72,4 +72,5 @@ const moduleFederationPlugin = (userConfig = {})=>{
72
72
  };
73
73
  };
74
74
  const cli = moduleFederationPlugin;
75
- export { createModuleFederationConfig, cli as default, moduleFederationPlugin };
75
+ export default cli;
76
+ export { createModuleFederationConfig, moduleFederationPlugin };
@@ -1,10 +1,9 @@
1
- import node_fetch from "node-fetch";
2
1
  const injectNodeFetchPlugin = ()=>({
3
2
  name: 'inject-node-fetch-plugin',
4
3
  beforeInit (args) {
5
- if (!globalThis.fetch) globalThis.fetch = node_fetch;
4
+ if (!globalThis.fetch) throw new Error('@module-federation/modern-js requires Node.js 18 or later.');
6
5
  return args;
7
6
  }
8
7
  });
9
8
  const inject_node_fetch = injectNodeFetchPlugin;
10
- export { inject_node_fetch as default };
9
+ export default inject_node_fetch;
@@ -16,4 +16,4 @@ const sharedStrategy = ()=>({
16
16
  }
17
17
  });
18
18
  const shared_strategy = sharedStrategy;
19
- export { shared_strategy as default };
19
+ export default shared_strategy;
@@ -12,4 +12,4 @@ const dataFetchServePlugin = ()=>({
12
12
  }
13
13
  });
14
14
  const data_fetch_server_plugin = dataFetchServePlugin;
15
- export { data_fetch_server_plugin as default };
15
+ export default data_fetch_server_plugin;
@@ -255,4 +255,5 @@ const moduleFederationSSRPlugin = (pluginOptions)=>({
255
255
  }
256
256
  });
257
257
  const ssrPlugin = moduleFederationSSRPlugin;
258
- export { CHAIN_MF_PLUGIN_ID, ssrPlugin as default, moduleFederationSSRPlugin, setEnv };
258
+ export default ssrPlugin;
259
+ export { CHAIN_MF_PLUGIN_ID, moduleFederationSSRPlugin, setEnv };
@@ -0,0 +1 @@
1
+ export { };
@@ -2,4 +2,4 @@ import { createLogger } from "@module-federation/sdk";
2
2
  import { PLUGIN_IDENTIFIER } from "./constant.mjs";
3
3
  const logger = createLogger(PLUGIN_IDENTIFIER);
4
4
  const src_logger = logger;
5
- export { src_logger as default };
5
+ export default src_logger;
@@ -1,3 +1,2 @@
1
- import bridge_react_plugin from "@module-federation/bridge-react/plugin";
2
1
  export * from "@module-federation/bridge-react/plugin";
3
- export { bridge_react_plugin as default };
2
+ export { default } from "@module-federation/bridge-react/plugin";
@@ -0,0 +1,18 @@
1
+ var __webpack_modules__ = {};
2
+ var __webpack_module_cache__ = {};
3
+ function __webpack_require__(moduleId) {
4
+ var cachedModule = __webpack_module_cache__[moduleId];
5
+ if (void 0 !== cachedModule) return cachedModule.exports;
6
+ var module = __webpack_module_cache__[moduleId] = {
7
+ exports: {}
8
+ };
9
+ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
10
+ return module.exports;
11
+ }
12
+ __webpack_require__.m = __webpack_modules__;
13
+ (()=>{
14
+ __webpack_require__.add = function(modules) {
15
+ Object.assign(__webpack_require__.m, modules);
16
+ };
17
+ })();
18
+ export { __webpack_require__ };
@@ -1,5 +1,5 @@
1
1
  import { access, lstat, readFile } from "fs/promises";
2
- import { LRUCache } from "lru-cache";
2
+ import { SizeLimitedCache } from "@module-federation/bridge-react/size-limited-cache";
3
3
  const pathExists = async (filepath)=>{
4
4
  try {
5
5
  await access(filepath);
@@ -35,9 +35,9 @@ class FileCache {
35
35
  return null;
36
36
  }
37
37
  }
38
- constructor(){
39
- this.cache = new LRUCache({
40
- maxSize: 209715200
38
+ constructor(maxSize = 209715200){
39
+ this.cache = new SizeLimitedCache({
40
+ maxSize
41
41
  });
42
42
  }
43
43
  }
@@ -31,4 +31,5 @@ const staticServePlugin = ()=>({
31
31
  }
32
32
  });
33
33
  const server = staticServePlugin;
34
- export { server as default, staticServePlugin };
34
+ export default server;
35
+ export { staticServePlugin };
@@ -0,0 +1 @@
1
+ export { };
@@ -8,6 +8,7 @@ export type ConfigType<T> = T extends 'webpack' ? webpack.Configuration : T exte
8
8
  export declare function setEnv(enableSSR: boolean): void;
9
9
  export declare const getMFConfig: (userConfig: PluginOptions) => Promise<moduleFederationPlugin.ModuleFederationPluginOptions>;
10
10
  export declare const patchMFConfig: (mfConfig: moduleFederationPlugin.ModuleFederationPluginOptions, isServer: boolean) => moduleFederationPlugin.ModuleFederationPluginOptions;
11
+ export declare const setDefaultOptimizationTarget: (mfConfig: moduleFederationPlugin.ModuleFederationPluginOptions, enableSSR: boolean, isServer: boolean, autoOptimization?: boolean) => void;
11
12
  export declare function addMyTypes2Ignored(chain: BundlerChainConfig, mfConfig: moduleFederationPlugin.ModuleFederationPluginOptions): void;
12
13
  export declare function patchBundlerConfig(options: {
13
14
  chain: BundlerChainConfig;
@@ -4,6 +4,7 @@ export interface FileResult {
4
4
  }
5
5
  export declare class FileCache {
6
6
  private cache;
7
+ constructor(maxSize?: number);
7
8
  /**
8
9
  * Check if file exists and return file info
9
10
  * @param filepath Path to the file
@@ -3,6 +3,12 @@ import type { StatsAssetResource } from '@module-federation/rsbuild-plugin/utils
3
3
  export interface PluginOptions {
4
4
  config?: moduleFederationPlugin.ModuleFederationPluginOptions;
5
5
  configPath?: string;
6
+ /**
7
+ * Automatically set the federation optimization target from the Modern.js
8
+ * SSR and bundler target configuration.
9
+ * @default true
10
+ */
11
+ autoOptimization?: boolean;
6
12
  ssr?: {
7
13
  distOutputDir?: string;
8
14
  } | boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/modern-js",
3
- "version": "2.6.0",
3
+ "version": "2.8.0",
4
4
  "files": [
5
5
  "dist/",
6
6
  "types.d.ts",
@@ -131,39 +131,38 @@
131
131
  "types": "./dist/types/cli/index.d.ts",
132
132
  "author": "hanric <hanric.zhang@gmail.com>",
133
133
  "license": "MIT",
134
+ "engines": {
135
+ "node": ">=18.0.0"
136
+ },
134
137
  "dependencies": {
135
- "@modern-js/utils": "2.70.5",
136
- "lru-cache": "10.4.3",
137
138
  "@swc/helpers": "0.5.17",
138
- "node-fetch": "3.3.0",
139
139
  "jiti": "2.4.2",
140
- "react-error-boundary": "4.1.2",
141
- "@module-federation/rsbuild-plugin": "2.6.0",
142
- "@module-federation/bridge-react": "2.6.0",
143
- "@module-federation/node": "2.7.45",
144
- "@module-federation/sdk": "2.6.0",
145
- "@module-federation/cli": "2.6.0",
146
- "@module-federation/runtime": "2.6.0",
147
- "@module-federation/enhanced": "2.6.0"
140
+ "@module-federation/rsbuild-plugin": "2.8.0",
141
+ "@module-federation/runtime": "2.8.0",
142
+ "@module-federation/bridge-react": "2.8.0",
143
+ "@module-federation/node": "2.7.47",
144
+ "@module-federation/sdk": "2.8.0",
145
+ "@module-federation/cli": "2.8.0",
146
+ "@module-federation/enhanced": "2.8.0"
148
147
  },
149
148
  "devDependencies": {
150
149
  "@rsbuild/plugin-react": "1.4.5",
151
- "@rslib/core": "0.18.5",
150
+ "@rstest/core": "^0.10.6",
151
+ "@rslib/core": "0.23.2",
152
152
  "@rsbuild/core": "1.3.21",
153
153
  "@modern-js/app-tools": "2.70.5",
154
154
  "@modern-js/server-runtime": "2.70.5",
155
155
  "@modern-js/module-tools": "2.70.5",
156
156
  "@modern-js/runtime": "2.70.5",
157
- "@modern-js/tsconfig": "2.70.5",
158
157
  "@types/react": "^18.3.11",
159
158
  "@types/react-dom": "^18.3.0",
160
- "vitest": "1.6.0",
161
- "@module-federation/manifest": "2.6.0"
159
+ "typescript": "7.0.2",
160
+ "@module-federation/manifest": "2.8.0"
162
161
  },
163
162
  "peerDependencies": {
164
163
  "react": ">=17",
165
164
  "react-dom": ">=17",
166
- "typescript": "^4.9.0 || ^5.0.0",
165
+ "typescript": "^4.9.0 || ^5.0.0 || ^6.0.0 || ^7.0.0",
167
166
  "vue-tsc": "^1.0.24",
168
167
  "react-router-dom": "^4 || ^5 || ^6 || ^7",
169
168
  "react-router": "^7"
@@ -185,7 +184,7 @@
185
184
  "scripts": {
186
185
  "build": "rslib build",
187
186
  "lint": "ESLINT_USE_FLAT_CONFIG=false pnpm exec eslint --ignore-pattern node_modules \"**/*.ts\"",
188
- "test": "pnpm exec vitest run --passWithNoTests --config vite.config.mts",
187
+ "test": "pnpm exec rstest --passWithNoTests",
189
188
  "pre-release": "pnpm run test && pnpm run build"
190
189
  }
191
190
  }
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};