@module-federation/modern-js 0.0.0-next-20250313034018 → 0.0.0-next-20250313075107

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.
@@ -59,14 +59,15 @@ const moduleFederationConfigPlugin = (userConfig) => ({
59
59
  userConfig.csrConfig = csrConfig;
60
60
  var _userConfig_userConfig_ssr;
61
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);
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");
62
+ api.modifyBundlerChain((chain) => {
63
+ const isWeb = (0, import_utils.isWebTarget)(chain.get("target"));
64
+ (0, import_utils.addMyTypes2Ignored)(chain, isWeb ? ssrConfig : csrConfig);
65
+ const targetMFConfig = isWeb ? ssrConfig : csrConfig;
66
+ (0, import_utils.patchMFConfig)(targetMFConfig, isWeb, userConfig.remoteIpStrategy || "ipv4");
66
67
  (0, import_utils.patchBundlerConfig)({
67
68
  // @ts-expect-error chain type is not correct
68
69
  chain,
69
- isServer,
70
+ isServer: isWeb,
70
71
  modernjsConfig,
71
72
  mfConfig,
72
73
  enableSSR
@@ -291,10 +291,11 @@ const getIPV4 = () => {
291
291
  };
292
292
  const isWebTarget = (target) => {
293
293
  const WEB_TARGET = "web";
294
+ const WEB_WORKER_TARGET = "webworker";
294
295
  if (Array.isArray(target)) {
295
- return target.includes(WEB_TARGET);
296
+ return target.includes(WEB_TARGET) || target.includes(WEB_WORKER_TARGET);
296
297
  } else if (typeof target === "string") {
297
- return target === WEB_TARGET;
298
+ return target === WEB_TARGET || target === WEB_WORKER_TARGET;
298
299
  }
299
300
  return false;
300
301
  };
@@ -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 } from "./utils";
4
+ import { patchBundlerConfig, getIPV4, getMFConfig, patchMFConfig, addMyTypes2Ignored, isWebTarget } from "./utils";
5
5
  function setEnv(enableSSR) {
6
6
  if (enableSSR) {
7
7
  process.env["MF_DISABLE_EMIT_STATS"] = "true";
@@ -35,15 +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, 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");
38
+ api.modifyBundlerChain(function(chain) {
39
+ var isWeb = isWebTarget(chain.get("target"));
40
+ addMyTypes2Ignored(chain, isWeb ? ssrConfig : csrConfig);
41
+ var targetMFConfig = isWeb ? ssrConfig : csrConfig;
42
+ patchMFConfig(targetMFConfig, isWeb, userConfig.remoteIpStrategy || "ipv4");
43
43
  patchBundlerConfig({
44
44
  // @ts-expect-error chain type is not correct
45
45
  chain,
46
- isServer,
46
+ isServer: isWeb,
47
47
  modernjsConfig,
48
48
  mfConfig,
49
49
  enableSSR
@@ -282,10 +282,11 @@ var getIPV4 = function() {
282
282
  };
283
283
  var isWebTarget = function(target) {
284
284
  var WEB_TARGET = "web";
285
+ var WEB_WORKER_TARGET = "webworker";
285
286
  if (Array.isArray(target)) {
286
- return target.includes(WEB_TARGET);
287
+ return target.includes(WEB_TARGET) || target.includes(WEB_WORKER_TARGET);
287
288
  } else if (typeof target === "string") {
288
- return target === WEB_TARGET;
289
+ return target === WEB_TARGET || target === WEB_WORKER_TARGET;
289
290
  }
290
291
  return false;
291
292
  };
@@ -1,5 +1,5 @@
1
1
  import path from "path";
2
- import { patchBundlerConfig, getIPV4, getMFConfig, patchMFConfig, addMyTypes2Ignored } from "./utils";
2
+ import { patchBundlerConfig, getIPV4, getMFConfig, patchMFConfig, addMyTypes2Ignored, isWebTarget } from "./utils";
3
3
  function setEnv(enableSSR) {
4
4
  if (enableSSR) {
5
5
  process.env["MF_DISABLE_EMIT_STATS"] = "true";
@@ -24,14 +24,15 @@ 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, { isServer }) => {
28
- addMyTypes2Ignored(chain, isServer ? ssrConfig : csrConfig);
29
- const targetMFConfig = isServer ? ssrConfig : csrConfig;
30
- patchMFConfig(targetMFConfig, isServer, userConfig.remoteIpStrategy || "ipv4");
27
+ api.modifyBundlerChain((chain) => {
28
+ const isWeb = isWebTarget(chain.get("target"));
29
+ addMyTypes2Ignored(chain, isWeb ? ssrConfig : csrConfig);
30
+ const targetMFConfig = isWeb ? ssrConfig : csrConfig;
31
+ patchMFConfig(targetMFConfig, isWeb, userConfig.remoteIpStrategy || "ipv4");
31
32
  patchBundlerConfig({
32
33
  // @ts-expect-error chain type is not correct
33
34
  chain,
34
- isServer,
35
+ isServer: isWeb,
35
36
  modernjsConfig,
36
37
  mfConfig,
37
38
  enableSSR
@@ -253,10 +253,11 @@ const getIPV4 = () => {
253
253
  };
254
254
  const isWebTarget = (target) => {
255
255
  const WEB_TARGET = "web";
256
+ const WEB_WORKER_TARGET = "webworker";
256
257
  if (Array.isArray(target)) {
257
- return target.includes(WEB_TARGET);
258
+ return target.includes(WEB_TARGET) || target.includes(WEB_WORKER_TARGET);
258
259
  } else if (typeof target === "string") {
259
- return target === WEB_TARGET;
260
+ return target === WEB_TARGET || target === WEB_WORKER_TARGET;
260
261
  }
261
262
  return false;
262
263
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/modern-js",
3
- "version": "0.0.0-next-20250313034018",
3
+ "version": "0.0.0-next-20250313075107",
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-20250313034018",
93
- "@module-federation/enhanced": "0.0.0-next-20250313034018",
94
- "@module-federation/node": "0.0.0-next-20250313034018",
95
- "@module-federation/sdk": "0.0.0-next-20250313034018"
92
+ "@module-federation/rsbuild-plugin": "0.0.0-next-20250313075107",
93
+ "@module-federation/enhanced": "0.0.0-next-20250313075107",
94
+ "@module-federation/node": "0.0.0-next-20250313075107",
95
+ "@module-federation/sdk": "0.0.0-next-20250313075107"
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-20250313034018"
103
+ "@module-federation/manifest": "0.0.0-next-20250313075107"
104
104
  },
105
105
  "peerDependencies": {
106
106
  "react": ">=17",