@module-federation/modern-js 0.0.0-next-20250314065230 → 0.0.0-next-20250314105429

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.
@@ -29,10 +29,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
29
29
  var configPlugin_exports = {};
30
30
  __export(configPlugin_exports, {
31
31
  default: () => configPlugin_default,
32
- isWebTarget: () => import_utils.isWebTarget,
33
32
  moduleFederationConfigPlugin: () => moduleFederationConfigPlugin,
34
- setEnv: () => setEnv,
35
- skipByTarget: () => import_utils.skipByTarget
33
+ setEnv: () => setEnv
36
34
  });
37
35
  module.exports = __toCommonJS(configPlugin_exports);
38
36
  var import_path = __toESM(require("path"));
@@ -61,19 +59,14 @@ const moduleFederationConfigPlugin = (userConfig) => ({
61
59
  userConfig.csrConfig = csrConfig;
62
60
  var _userConfig_userConfig_ssr;
63
61
  const enableSSR = (_userConfig_userConfig_ssr = (_userConfig_userConfig = userConfig.userConfig) === null || _userConfig_userConfig === void 0 ? void 0 : _userConfig_userConfig.ssr) !== null && _userConfig_userConfig_ssr !== void 0 ? _userConfig_userConfig_ssr : Boolean(modernjsConfig === null || modernjsConfig === void 0 ? void 0 : (_modernjsConfig_server = modernjsConfig.server) === null || _modernjsConfig_server === void 0 ? void 0 : _modernjsConfig_server.ssr);
64
- api.modifyBundlerChain((chain) => {
65
- const target = chain.get("target");
66
- if ((0, import_utils.skipByTarget)(target)) {
67
- return;
68
- }
69
- const isWeb = (0, import_utils.isWebTarget)(target);
70
- (0, import_utils.addMyTypes2Ignored)(chain, !isWeb ? ssrConfig : csrConfig);
71
- const targetMFConfig = !isWeb ? ssrConfig : csrConfig;
72
- (0, import_utils.patchMFConfig)(targetMFConfig, !isWeb, userConfig.remoteIpStrategy || "ipv4");
62
+ api.modifyBundlerChain((chain, { isServer }) => {
63
+ (0, import_utils.addMyTypes2Ignored)(chain, isServer ? ssrConfig : csrConfig);
64
+ const targetMFConfig = isServer ? ssrConfig : csrConfig;
65
+ (0, import_utils.patchMFConfig)(targetMFConfig, isServer, userConfig.remoteIpStrategy || "ipv4");
73
66
  (0, import_utils.patchBundlerConfig)({
74
67
  // @ts-expect-error chain type is not correct
75
68
  chain,
76
- isServer: !isWeb,
69
+ isServer,
77
70
  modernjsConfig,
78
71
  mfConfig,
79
72
  enableSSR
@@ -122,8 +115,6 @@ const moduleFederationConfigPlugin = (userConfig) => ({
122
115
  var configPlugin_default = moduleFederationConfigPlugin;
123
116
  // Annotate the CommonJS export names for ESM import in node:
124
117
  0 && (module.exports = {
125
- isWebTarget,
126
118
  moduleFederationConfigPlugin,
127
- setEnv,
128
- skipByTarget
119
+ setEnv
129
120
  });
@@ -83,14 +83,10 @@ const moduleFederationSSRPlugin = (pluginOptions) => ({
83
83
  plugins
84
84
  };
85
85
  });
86
- api.modifyBundlerChain((chain) => {
87
- const target = chain.get("target");
88
- if ((0, import_utils2.skipByTarget)(target)) {
89
- return;
90
- }
86
+ api.modifyBundlerChain((chain, { isServer }) => {
91
87
  const bundlerType = api.getAppContext().bundlerType === "rspack" ? "rspack" : "webpack";
92
88
  const MFPlugin = bundlerType === "webpack" ? import_webpack.ModuleFederationPlugin : import_rspack.ModuleFederationPlugin;
93
- const isWeb = (0, import_utils2.isWebTarget)(target);
89
+ const isWeb = (0, import_utils2.isWebTarget)(chain.get("target"));
94
90
  if (!isWeb) {
95
91
  if (!chain.plugins.has(CHAIN_MF_PLUGIN_ID)) {
96
92
  chain.plugin(CHAIN_MF_PLUGIN_ID).use(MFPlugin, [
@@ -107,12 +103,12 @@ const moduleFederationSSRPlugin = (pluginOptions) => ({
107
103
  chain.plugin("UniverseEntryChunkTrackerPlugin").use(import_universe_entry_chunk_tracker_plugin.default);
108
104
  }
109
105
  }
110
- if (import_constant.isDev && isWeb) {
106
+ if (import_constant.isDev && !isServer) {
111
107
  chain.externals({
112
108
  "@module-federation/node/utils": "NOT_USED_IN_BROWSER"
113
109
  });
114
110
  }
115
- if (!isWeb) {
111
+ if (isServer) {
116
112
  ssrOutputPath = chain.output.get("path") || import_path.default.resolve(process.cwd(), `dist/${import_constant2.MODERN_JS_SERVER_DIR}`);
117
113
  } else {
118
114
  csrOutputPath = chain.output.get("path") || import_path.default.resolve(process.cwd(), "dist");
@@ -33,8 +33,7 @@ __export(utils_exports, {
33
33
  getMFConfig: () => getMFConfig,
34
34
  isWebTarget: () => isWebTarget,
35
35
  patchBundlerConfig: () => patchBundlerConfig,
36
- patchMFConfig: () => patchMFConfig,
37
- skipByTarget: () => skipByTarget
36
+ patchMFConfig: () => patchMFConfig
38
37
  });
39
38
  module.exports = __toCommonJS(utils_exports);
40
39
  var import_os = __toESM(require("os"));
@@ -299,15 +298,6 @@ const isWebTarget = (target) => {
299
298
  }
300
299
  return false;
301
300
  };
302
- const skipByTarget = (target) => {
303
- const IGNORE_TARGET = "webworker";
304
- if (Array.isArray(target)) {
305
- return target.includes(IGNORE_TARGET);
306
- } else if (typeof target === "string") {
307
- return target === IGNORE_TARGET;
308
- }
309
- return false;
310
- };
311
301
  // Annotate the CommonJS export names for ESM import in node:
312
302
  0 && (module.exports = {
313
303
  addMyTypes2Ignored,
@@ -315,6 +305,5 @@ const skipByTarget = (target) => {
315
305
  getMFConfig,
316
306
  isWebTarget,
317
307
  patchBundlerConfig,
318
- patchMFConfig,
319
- skipByTarget
308
+ patchMFConfig
320
309
  });
@@ -1,7 +1,7 @@
1
1
  import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
2
  import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
3
  import path from "path";
4
- import { patchBundlerConfig, getIPV4, getMFConfig, patchMFConfig, addMyTypes2Ignored, isWebTarget, skipByTarget } from "./utils";
4
+ import { patchBundlerConfig, getIPV4, getMFConfig, patchMFConfig, addMyTypes2Ignored } from "./utils";
5
5
  function setEnv(enableSSR) {
6
6
  if (enableSSR) {
7
7
  process.env["MF_DISABLE_EMIT_STATS"] = "true";
@@ -35,19 +35,15 @@ var moduleFederationConfigPlugin = function(userConfig) {
35
35
  userConfig.ssrConfig = ssrConfig;
36
36
  userConfig.csrConfig = csrConfig;
37
37
  enableSSR = (_userConfig_userConfig_ssr = (_userConfig_userConfig = userConfig.userConfig) === null || _userConfig_userConfig === void 0 ? void 0 : _userConfig_userConfig.ssr) !== null && _userConfig_userConfig_ssr !== void 0 ? _userConfig_userConfig_ssr : Boolean(modernjsConfig === null || modernjsConfig === void 0 ? void 0 : (_modernjsConfig_server = modernjsConfig.server) === null || _modernjsConfig_server === void 0 ? void 0 : _modernjsConfig_server.ssr);
38
- api.modifyBundlerChain(function(chain) {
39
- var target = chain.get("target");
40
- if (skipByTarget(target)) {
41
- return;
42
- }
43
- var isWeb = isWebTarget(target);
44
- addMyTypes2Ignored(chain, !isWeb ? ssrConfig : csrConfig);
45
- var targetMFConfig = !isWeb ? ssrConfig : csrConfig;
46
- patchMFConfig(targetMFConfig, !isWeb, userConfig.remoteIpStrategy || "ipv4");
38
+ api.modifyBundlerChain(function(chain, param) {
39
+ var isServer = param.isServer;
40
+ addMyTypes2Ignored(chain, isServer ? ssrConfig : csrConfig);
41
+ var targetMFConfig = isServer ? ssrConfig : csrConfig;
42
+ patchMFConfig(targetMFConfig, isServer, userConfig.remoteIpStrategy || "ipv4");
47
43
  patchBundlerConfig({
48
44
  // @ts-expect-error chain type is not correct
49
45
  chain,
50
- isServer: !isWeb,
46
+ isServer,
51
47
  modernjsConfig,
52
48
  mfConfig,
53
49
  enableSSR
@@ -106,8 +102,6 @@ var moduleFederationConfigPlugin = function(userConfig) {
106
102
  var configPlugin_default = moduleFederationConfigPlugin;
107
103
  export {
108
104
  configPlugin_default as default,
109
- isWebTarget,
110
105
  moduleFederationConfigPlugin,
111
- setEnv,
112
- skipByTarget
106
+ setEnv
113
107
  };
@@ -9,7 +9,7 @@ import { updateStatsAndManifest } from "./manifest";
9
9
  import { isDev } from "./constant";
10
10
  import { MODERN_JS_SERVER_DIR } from "../constant";
11
11
  import logger from "./logger";
12
- import { isWebTarget, skipByTarget } from "./utils";
12
+ import { isWebTarget } from "./utils";
13
13
  function setEnv() {
14
14
  process.env["MF_DISABLE_EMIT_STATS"] = "true";
15
15
  process.env["MF_SSR_PRJ"] = "true";
@@ -54,14 +54,11 @@ var moduleFederationSSRPlugin = function(pluginOptions) {
54
54
  plugins
55
55
  };
56
56
  });
57
- api.modifyBundlerChain(function(chain) {
58
- var target = chain.get("target");
59
- if (skipByTarget(target)) {
60
- return;
61
- }
57
+ api.modifyBundlerChain(function(chain, param) {
58
+ var isServer = param.isServer;
62
59
  var bundlerType = api.getAppContext().bundlerType === "rspack" ? "rspack" : "webpack";
63
60
  var MFPlugin = bundlerType === "webpack" ? ModuleFederationPlugin : RspackModuleFederationPlugin;
64
- var isWeb = isWebTarget(target);
61
+ var isWeb = isWebTarget(chain.get("target"));
65
62
  if (!isWeb) {
66
63
  if (!chain.plugins.has(CHAIN_MF_PLUGIN_ID)) {
67
64
  chain.plugin(CHAIN_MF_PLUGIN_ID).use(MFPlugin, [
@@ -78,12 +75,12 @@ var moduleFederationSSRPlugin = function(pluginOptions) {
78
75
  chain.plugin("UniverseEntryChunkTrackerPlugin").use(UniverseEntryChunkTrackerPlugin);
79
76
  }
80
77
  }
81
- if (isDev && isWeb) {
78
+ if (isDev && !isServer) {
82
79
  chain.externals({
83
80
  "@module-federation/node/utils": "NOT_USED_IN_BROWSER"
84
81
  });
85
82
  }
86
- if (!isWeb) {
83
+ if (isServer) {
87
84
  ssrOutputPath = chain.output.get("path") || path.resolve(process.cwd(), "dist/".concat(MODERN_JS_SERVER_DIR));
88
85
  } else {
89
86
  csrOutputPath = chain.output.get("path") || path.resolve(process.cwd(), "dist");
@@ -289,21 +289,11 @@ var isWebTarget = function(target) {
289
289
  }
290
290
  return false;
291
291
  };
292
- var skipByTarget = function(target) {
293
- var IGNORE_TARGET = "webworker";
294
- if (Array.isArray(target)) {
295
- return target.includes(IGNORE_TARGET);
296
- } else if (typeof target === "string") {
297
- return target === IGNORE_TARGET;
298
- }
299
- return false;
300
- };
301
292
  export {
302
293
  addMyTypes2Ignored,
303
294
  getIPV4,
304
295
  getMFConfig,
305
296
  isWebTarget,
306
297
  patchBundlerConfig,
307
- patchMFConfig,
308
- skipByTarget
298
+ patchMFConfig
309
299
  };
@@ -1,5 +1,5 @@
1
1
  import path from "path";
2
- import { patchBundlerConfig, getIPV4, getMFConfig, patchMFConfig, addMyTypes2Ignored, isWebTarget, skipByTarget } from "./utils";
2
+ import { patchBundlerConfig, getIPV4, getMFConfig, patchMFConfig, addMyTypes2Ignored } from "./utils";
3
3
  function setEnv(enableSSR) {
4
4
  if (enableSSR) {
5
5
  process.env["MF_DISABLE_EMIT_STATS"] = "true";
@@ -24,19 +24,14 @@ const moduleFederationConfigPlugin = (userConfig) => ({
24
24
  userConfig.csrConfig = csrConfig;
25
25
  var _userConfig_userConfig_ssr;
26
26
  const enableSSR = (_userConfig_userConfig_ssr = (_userConfig_userConfig = userConfig.userConfig) === null || _userConfig_userConfig === void 0 ? void 0 : _userConfig_userConfig.ssr) !== null && _userConfig_userConfig_ssr !== void 0 ? _userConfig_userConfig_ssr : Boolean(modernjsConfig === null || modernjsConfig === void 0 ? void 0 : (_modernjsConfig_server = modernjsConfig.server) === null || _modernjsConfig_server === void 0 ? void 0 : _modernjsConfig_server.ssr);
27
- api.modifyBundlerChain((chain) => {
28
- const target = chain.get("target");
29
- if (skipByTarget(target)) {
30
- return;
31
- }
32
- const isWeb = isWebTarget(target);
33
- addMyTypes2Ignored(chain, !isWeb ? ssrConfig : csrConfig);
34
- const targetMFConfig = !isWeb ? ssrConfig : csrConfig;
35
- patchMFConfig(targetMFConfig, !isWeb, userConfig.remoteIpStrategy || "ipv4");
27
+ api.modifyBundlerChain((chain, { isServer }) => {
28
+ addMyTypes2Ignored(chain, isServer ? ssrConfig : csrConfig);
29
+ const targetMFConfig = isServer ? ssrConfig : csrConfig;
30
+ patchMFConfig(targetMFConfig, isServer, userConfig.remoteIpStrategy || "ipv4");
36
31
  patchBundlerConfig({
37
32
  // @ts-expect-error chain type is not correct
38
33
  chain,
39
- isServer: !isWeb,
34
+ isServer,
40
35
  modernjsConfig,
41
36
  mfConfig,
42
37
  enableSSR
@@ -85,8 +80,6 @@ const moduleFederationConfigPlugin = (userConfig) => ({
85
80
  var configPlugin_default = moduleFederationConfigPlugin;
86
81
  export {
87
82
  configPlugin_default as default,
88
- isWebTarget,
89
83
  moduleFederationConfigPlugin,
90
- setEnv,
91
- skipByTarget
84
+ setEnv
92
85
  };
@@ -7,7 +7,7 @@ import { updateStatsAndManifest } from "./manifest";
7
7
  import { isDev } from "./constant";
8
8
  import { MODERN_JS_SERVER_DIR } from "../constant";
9
9
  import logger from "./logger";
10
- import { isWebTarget, skipByTarget } from "./utils";
10
+ import { isWebTarget } from "./utils";
11
11
  function setEnv() {
12
12
  process.env["MF_DISABLE_EMIT_STATS"] = "true";
13
13
  process.env["MF_SSR_PRJ"] = "true";
@@ -47,14 +47,10 @@ const moduleFederationSSRPlugin = (pluginOptions) => ({
47
47
  plugins
48
48
  };
49
49
  });
50
- api.modifyBundlerChain((chain) => {
51
- const target = chain.get("target");
52
- if (skipByTarget(target)) {
53
- return;
54
- }
50
+ api.modifyBundlerChain((chain, { isServer }) => {
55
51
  const bundlerType = api.getAppContext().bundlerType === "rspack" ? "rspack" : "webpack";
56
52
  const MFPlugin = bundlerType === "webpack" ? ModuleFederationPlugin : RspackModuleFederationPlugin;
57
- const isWeb = isWebTarget(target);
53
+ const isWeb = isWebTarget(chain.get("target"));
58
54
  if (!isWeb) {
59
55
  if (!chain.plugins.has(CHAIN_MF_PLUGIN_ID)) {
60
56
  chain.plugin(CHAIN_MF_PLUGIN_ID).use(MFPlugin, [
@@ -71,12 +67,12 @@ const moduleFederationSSRPlugin = (pluginOptions) => ({
71
67
  chain.plugin("UniverseEntryChunkTrackerPlugin").use(UniverseEntryChunkTrackerPlugin);
72
68
  }
73
69
  }
74
- if (isDev && isWeb) {
70
+ if (isDev && !isServer) {
75
71
  chain.externals({
76
72
  "@module-federation/node/utils": "NOT_USED_IN_BROWSER"
77
73
  });
78
74
  }
79
- if (!isWeb) {
75
+ if (isServer) {
80
76
  ssrOutputPath = chain.output.get("path") || path.resolve(process.cwd(), `dist/${MODERN_JS_SERVER_DIR}`);
81
77
  } else {
82
78
  csrOutputPath = chain.output.get("path") || path.resolve(process.cwd(), "dist");
@@ -260,21 +260,11 @@ const isWebTarget = (target) => {
260
260
  }
261
261
  return false;
262
262
  };
263
- const skipByTarget = (target) => {
264
- const IGNORE_TARGET = "webworker";
265
- if (Array.isArray(target)) {
266
- return target.includes(IGNORE_TARGET);
267
- } else if (typeof target === "string") {
268
- return target === IGNORE_TARGET;
269
- }
270
- return false;
271
- };
272
263
  export {
273
264
  addMyTypes2Ignored,
274
265
  getIPV4,
275
266
  getMFConfig,
276
267
  isWebTarget,
277
268
  patchBundlerConfig,
278
- patchMFConfig,
279
- skipByTarget
269
+ patchMFConfig
280
270
  };
@@ -1,7 +1,5 @@
1
1
  import type { CliPluginFuture, AppTools } from '@modern-js/app-tools';
2
2
  import type { InternalModernPluginOptions } from '../types';
3
- import { isWebTarget, skipByTarget } from './utils';
4
3
  export declare function setEnv(enableSSR: boolean): void;
5
4
  export declare const moduleFederationConfigPlugin: (userConfig: InternalModernPluginOptions) => CliPluginFuture<AppTools>;
6
5
  export default moduleFederationConfigPlugin;
7
- export { isWebTarget, skipByTarget };
@@ -15,4 +15,3 @@ export declare function patchBundlerConfig(options: {
15
15
  }): void;
16
16
  export declare const getIPV4: () => string;
17
17
  export declare const isWebTarget: (target: string[] | string) => boolean;
18
- export declare const skipByTarget: (target: string[] | string) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/modern-js",
3
- "version": "0.0.0-next-20250314065230",
3
+ "version": "0.0.0-next-20250314105429",
4
4
  "files": [
5
5
  "dist/",
6
6
  "types.d.ts",
@@ -89,10 +89,10 @@
89
89
  "@swc/helpers": "0.5.13",
90
90
  "node-fetch": "~3.3.0",
91
91
  "react-error-boundary": "4.1.2",
92
- "@module-federation/rsbuild-plugin": "0.0.0-next-20250314065230",
93
- "@module-federation/enhanced": "0.0.0-next-20250314065230",
94
- "@module-federation/node": "0.0.0-next-20250314065230",
95
- "@module-federation/sdk": "0.0.0-next-20250314065230"
92
+ "@module-federation/rsbuild-plugin": "0.0.0-next-20250314105429",
93
+ "@module-federation/enhanced": "0.0.0-next-20250314105429",
94
+ "@module-federation/node": "0.0.0-next-20250314105429",
95
+ "@module-federation/sdk": "0.0.0-next-20250314105429"
96
96
  },
97
97
  "devDependencies": {
98
98
  "@modern-js/app-tools": "2.65.1",
@@ -100,7 +100,7 @@
100
100
  "@modern-js/module-tools": "2.65.1",
101
101
  "@modern-js/runtime": "2.65.1",
102
102
  "@modern-js/tsconfig": "2.65.1",
103
- "@module-federation/manifest": "0.0.0-next-20250314065230"
103
+ "@module-federation/manifest": "0.0.0-next-20250314105429"
104
104
  },
105
105
  "peerDependencies": {
106
106
  "react": ">=17",