@module-federation/modern-js 0.0.0-next-20240625025206 → 0.0.0-next-20240625070454

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.
package/README.md CHANGED
@@ -4,7 +4,7 @@ This plugin provides Module Federation supporting functions for Modern.js
4
4
 
5
5
  ## Supports
6
6
 
7
- - modern.js ^2.52.0
7
+ - modern.js ^2.54.2
8
8
  - Server-Side Rendering
9
9
 
10
10
  We highly recommend referencing this application which takes advantage of the best capabilities:
@@ -94,7 +94,7 @@ const moduleFederationPlugin = (userConfig = {}) => ({
94
94
  tools: {
95
95
  rspack(config) {
96
96
  if (enableSSR) {
97
- throw new Error("@module-federation/modern-js not support ssr for rspack bundler yet!");
97
+ throw new Error(`${import_constant.PLUGIN_IDENTIFIER} not support ssr for rspack bundler yet!`);
98
98
  }
99
99
  modifyBundlerConfig(config, false);
100
100
  },
@@ -90,11 +90,10 @@ const replaceRemoteUrl = async (mfConfig) => {
90
90
  handleRemoteObject(mfConfig.remotes);
91
91
  }
92
92
  };
93
- const patchMFConfig = (mfConfig, isServer) => {
94
- const isDev = process.env.NODE_ENV === "development";
95
- const runtimePlugins = [
96
- ...mfConfig.runtimePlugins || []
97
- ];
93
+ const patchDTSConfig = (mfConfig, isServer) => {
94
+ if (isServer) {
95
+ return;
96
+ }
98
97
  const ModernJSRuntime = "@modern-js/runtime/mf";
99
98
  if (mfConfig.dts !== false) {
100
99
  var _mfConfig_dts, _mfConfig_dts1;
@@ -122,6 +121,13 @@ const patchMFConfig = (mfConfig, isServer) => {
122
121
  }
123
122
  }
124
123
  }
124
+ };
125
+ const patchMFConfig = (mfConfig, isServer) => {
126
+ const isDev = process.env.NODE_ENV === "development";
127
+ const runtimePlugins = [
128
+ ...mfConfig.runtimePlugins || []
129
+ ];
130
+ patchDTSConfig(mfConfig, isServer);
125
131
  injectRuntimePlugins(import_path.default.resolve(__dirname, "./mfRuntimePlugins/shared-strategy.js"), runtimePlugins);
126
132
  if (isDev) {
127
133
  injectRuntimePlugins(import_path.default.resolve(__dirname, "./mfRuntimePlugins/resolve-entry-ipv4.js"), runtimePlugins);
@@ -178,7 +184,7 @@ function patchWebpackConfig(options) {
178
184
  }
179
185
  if (!isServer && enableSSR && typeof ((_bundlerConfig_optimization1 = bundlerConfig.optimization) === null || _bundlerConfig_optimization1 === void 0 ? void 0 : _bundlerConfig_optimization1.splitChunks) === "object" && bundlerConfig.optimization.splitChunks.cacheGroups) {
180
186
  bundlerConfig.optimization.splitChunks.chunks = "async";
181
- console.warn('[Modern.js Module Federation] splitChunks.chunks = async is not allowed with stream SSR mode, it will auto changed to "async"');
187
+ console.warn(`${import_constant.PLUGIN_IDENTIFIER} splitChunks.chunks = async is not allowed with stream SSR mode, it will auto changed to "async"`);
182
188
  }
183
189
  if (((_bundlerConfig_output = bundlerConfig.output) === null || _bundlerConfig_output === void 0 ? void 0 : _bundlerConfig_output.publicPath) === "auto") {
184
190
  var _modernjsConfig_dev, _modernjsConfig_server1;
@@ -19,13 +19,16 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  var constant_exports = {};
20
20
  __export(constant_exports, {
21
21
  LOCALHOST: () => LOCALHOST,
22
- MODERN_JS_SERVER_DIR: () => MODERN_JS_SERVER_DIR
22
+ MODERN_JS_SERVER_DIR: () => MODERN_JS_SERVER_DIR,
23
+ PLUGIN_IDENTIFIER: () => PLUGIN_IDENTIFIER
23
24
  });
24
25
  module.exports = __toCommonJS(constant_exports);
25
26
  const MODERN_JS_SERVER_DIR = "bundles";
26
27
  const LOCALHOST = "localhost";
28
+ const PLUGIN_IDENTIFIER = "[ Modern.js Module Federation ]";
27
29
  // Annotate the CommonJS export names for ESM import in node:
28
30
  0 && (module.exports = {
29
31
  LOCALHOST,
30
- MODERN_JS_SERVER_DIR
32
+ MODERN_JS_SERVER_DIR,
33
+ PLUGIN_IDENTIFIER
31
34
  });
@@ -7,7 +7,7 @@ import { ModuleFederationPlugin as RspackModuleFederationPlugin } from "@module-
7
7
  import { StreamingTargetPlugin, EntryChunkTrackerPlugin } from "@module-federation/node";
8
8
  import { getMFConfig, getTargetEnvConfig, patchWebpackConfig, getIPV4 } from "./utils";
9
9
  import { updateStatsAndManifest } from "./manifest";
10
- import { MODERN_JS_SERVER_DIR } from "../constant";
10
+ import { MODERN_JS_SERVER_DIR, PLUGIN_IDENTIFIER } from "../constant";
11
11
  var SSR_PLUGIN_IDENTIFIER = "mfPluginSSR";
12
12
  var isDev = process.env.NODE_ENV === "development";
13
13
  var moduleFederationPlugin = function() {
@@ -75,7 +75,7 @@ var moduleFederationPlugin = function() {
75
75
  tools: {
76
76
  rspack: function rspack(config) {
77
77
  if (enableSSR) {
78
- throw new Error("@module-federation/modern-js not support ssr for rspack bundler yet!");
78
+ throw new Error("".concat(PLUGIN_IDENTIFIER, " not support ssr for rspack bundler yet!"));
79
79
  }
80
80
  modifyBundlerConfig(config, false);
81
81
  },
@@ -7,7 +7,7 @@ import { encodeName } from "@module-federation/sdk";
7
7
  import path from "path";
8
8
  import os from "os";
9
9
  import { bundle } from "@modern-js/node-bundle-require";
10
- import { LOCALHOST } from "../constant";
10
+ import { LOCALHOST, PLUGIN_IDENTIFIER } from "../constant";
11
11
  var defaultPath = path.resolve(process.cwd(), "module-federation.config.ts");
12
12
  var getMFConfig = function() {
13
13
  var _ref = _async_to_generator(function(userConfig) {
@@ -103,9 +103,10 @@ var replaceRemoteUrl = function() {
103
103
  return _ref.apply(this, arguments);
104
104
  };
105
105
  }();
106
- var patchMFConfig = function(mfConfig, isServer) {
107
- var isDev = process.env.NODE_ENV === "development";
108
- var runtimePlugins = _to_consumable_array(mfConfig.runtimePlugins || []);
106
+ var patchDTSConfig = function(mfConfig, isServer) {
107
+ if (isServer) {
108
+ return;
109
+ }
109
110
  var ModernJSRuntime = "@modern-js/runtime/mf";
110
111
  if (mfConfig.dts !== false) {
111
112
  var _mfConfig_dts, _mfConfig_dts1;
@@ -133,6 +134,11 @@ var patchMFConfig = function(mfConfig, isServer) {
133
134
  }
134
135
  }
135
136
  }
137
+ };
138
+ var patchMFConfig = function(mfConfig, isServer) {
139
+ var isDev = process.env.NODE_ENV === "development";
140
+ var runtimePlugins = _to_consumable_array(mfConfig.runtimePlugins || []);
141
+ patchDTSConfig(mfConfig, isServer);
136
142
  injectRuntimePlugins(path.resolve(__dirname, "./mfRuntimePlugins/shared-strategy.js"), runtimePlugins);
137
143
  if (isDev) {
138
144
  injectRuntimePlugins(path.resolve(__dirname, "./mfRuntimePlugins/resolve-entry-ipv4.js"), runtimePlugins);
@@ -184,7 +190,7 @@ function patchWebpackConfig(options) {
184
190
  }
185
191
  if (!isServer && enableSSR && typeof ((_bundlerConfig_optimization1 = bundlerConfig.optimization) === null || _bundlerConfig_optimization1 === void 0 ? void 0 : _bundlerConfig_optimization1.splitChunks) === "object" && bundlerConfig.optimization.splitChunks.cacheGroups) {
186
192
  bundlerConfig.optimization.splitChunks.chunks = "async";
187
- console.warn('[Modern.js Module Federation] splitChunks.chunks = async is not allowed with stream SSR mode, it will auto changed to "async"');
193
+ console.warn("".concat(PLUGIN_IDENTIFIER, ' splitChunks.chunks = async is not allowed with stream SSR mode, it will auto changed to "async"'));
188
194
  }
189
195
  if (((_bundlerConfig_output = bundlerConfig.output) === null || _bundlerConfig_output === void 0 ? void 0 : _bundlerConfig_output.publicPath) === "auto") {
190
196
  var _modernjsConfig_dev, _modernjsConfig_server1;
@@ -1,6 +1,8 @@
1
1
  var MODERN_JS_SERVER_DIR = "bundles";
2
2
  var LOCALHOST = "localhost";
3
+ var PLUGIN_IDENTIFIER = "[ Modern.js Module Federation ]";
3
4
  export {
4
5
  LOCALHOST,
5
- MODERN_JS_SERVER_DIR
6
+ MODERN_JS_SERVER_DIR,
7
+ PLUGIN_IDENTIFIER
6
8
  };
@@ -5,7 +5,7 @@ import { ModuleFederationPlugin as RspackModuleFederationPlugin } from "@module-
5
5
  import { StreamingTargetPlugin, EntryChunkTrackerPlugin } from "@module-federation/node";
6
6
  import { getMFConfig, getTargetEnvConfig, patchWebpackConfig, getIPV4 } from "./utils";
7
7
  import { updateStatsAndManifest } from "./manifest";
8
- import { MODERN_JS_SERVER_DIR } from "../constant";
8
+ import { MODERN_JS_SERVER_DIR, PLUGIN_IDENTIFIER } from "../constant";
9
9
  const SSR_PLUGIN_IDENTIFIER = "mfPluginSSR";
10
10
  const isDev = process.env.NODE_ENV === "development";
11
11
  const moduleFederationPlugin = (userConfig = {}) => ({
@@ -58,7 +58,7 @@ const moduleFederationPlugin = (userConfig = {}) => ({
58
58
  tools: {
59
59
  rspack(config) {
60
60
  if (enableSSR) {
61
- throw new Error("@module-federation/modern-js not support ssr for rspack bundler yet!");
61
+ throw new Error(`${PLUGIN_IDENTIFIER} not support ssr for rspack bundler yet!`);
62
62
  }
63
63
  modifyBundlerConfig(config, false);
64
64
  },
@@ -2,7 +2,7 @@ import { encodeName } from "@module-federation/sdk";
2
2
  import path from "path";
3
3
  import os from "os";
4
4
  import { bundle } from "@modern-js/node-bundle-require";
5
- import { LOCALHOST } from "../constant";
5
+ import { LOCALHOST, PLUGIN_IDENTIFIER } from "../constant";
6
6
  const defaultPath = path.resolve(process.cwd(), "module-federation.config.ts");
7
7
  const getMFConfig = async (userConfig) => {
8
8
  const { config, configPath } = userConfig;
@@ -53,11 +53,10 @@ const replaceRemoteUrl = async (mfConfig) => {
53
53
  handleRemoteObject(mfConfig.remotes);
54
54
  }
55
55
  };
56
- const patchMFConfig = (mfConfig, isServer) => {
57
- const isDev = process.env.NODE_ENV === "development";
58
- const runtimePlugins = [
59
- ...mfConfig.runtimePlugins || []
60
- ];
56
+ const patchDTSConfig = (mfConfig, isServer) => {
57
+ if (isServer) {
58
+ return;
59
+ }
61
60
  const ModernJSRuntime = "@modern-js/runtime/mf";
62
61
  if (mfConfig.dts !== false) {
63
62
  var _mfConfig_dts, _mfConfig_dts1;
@@ -85,6 +84,13 @@ const patchMFConfig = (mfConfig, isServer) => {
85
84
  }
86
85
  }
87
86
  }
87
+ };
88
+ const patchMFConfig = (mfConfig, isServer) => {
89
+ const isDev = process.env.NODE_ENV === "development";
90
+ const runtimePlugins = [
91
+ ...mfConfig.runtimePlugins || []
92
+ ];
93
+ patchDTSConfig(mfConfig, isServer);
88
94
  injectRuntimePlugins(path.resolve(__dirname, "./mfRuntimePlugins/shared-strategy.js"), runtimePlugins);
89
95
  if (isDev) {
90
96
  injectRuntimePlugins(path.resolve(__dirname, "./mfRuntimePlugins/resolve-entry-ipv4.js"), runtimePlugins);
@@ -141,7 +147,7 @@ function patchWebpackConfig(options) {
141
147
  }
142
148
  if (!isServer && enableSSR && typeof ((_bundlerConfig_optimization1 = bundlerConfig.optimization) === null || _bundlerConfig_optimization1 === void 0 ? void 0 : _bundlerConfig_optimization1.splitChunks) === "object" && bundlerConfig.optimization.splitChunks.cacheGroups) {
143
149
  bundlerConfig.optimization.splitChunks.chunks = "async";
144
- console.warn('[Modern.js Module Federation] splitChunks.chunks = async is not allowed with stream SSR mode, it will auto changed to "async"');
150
+ console.warn(`${PLUGIN_IDENTIFIER} splitChunks.chunks = async is not allowed with stream SSR mode, it will auto changed to "async"`);
145
151
  }
146
152
  if (((_bundlerConfig_output = bundlerConfig.output) === null || _bundlerConfig_output === void 0 ? void 0 : _bundlerConfig_output.publicPath) === "auto") {
147
153
  var _modernjsConfig_dev, _modernjsConfig_server1;
@@ -1,6 +1,8 @@
1
1
  const MODERN_JS_SERVER_DIR = "bundles";
2
2
  const LOCALHOST = "localhost";
3
+ const PLUGIN_IDENTIFIER = "[ Modern.js Module Federation ]";
3
4
  export {
4
5
  LOCALHOST,
5
- MODERN_JS_SERVER_DIR
6
+ MODERN_JS_SERVER_DIR,
7
+ PLUGIN_IDENTIFIER
6
8
  };
@@ -1,2 +1,3 @@
1
1
  export declare const MODERN_JS_SERVER_DIR = "bundles";
2
2
  export declare const LOCALHOST = "localhost";
3
+ export declare const PLUGIN_IDENTIFIER = "[ Modern.js Module Federation ]";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/modern-js",
3
- "version": "0.0.0-next-20240625025206",
3
+ "version": "0.0.0-next-20240625070454",
4
4
  "files": [
5
5
  "dist/",
6
6
  "types.d.ts",
@@ -43,21 +43,21 @@
43
43
  "license": "MIT",
44
44
  "dependencies": {
45
45
  "@swc/helpers": "0.5.3",
46
- "@modern-js/utils": "^2.49.2",
47
- "@modern-js/node-bundle-require": "^2.49.2",
46
+ "@modern-js/utils": "^2.54.2",
47
+ "@modern-js/node-bundle-require": "^2.54.2",
48
48
  "node-fetch": "~3.3.0",
49
49
  "react-error-boundary": "4.0.13",
50
- "@module-federation/sdk": "0.0.0-next-20240625025206",
51
- "@module-federation/enhanced": "0.0.0-next-20240625025206",
52
- "@module-federation/node": "0.0.0-next-20240625025206"
50
+ "@module-federation/sdk": "0.0.0-next-20240625070454",
51
+ "@module-federation/enhanced": "0.0.0-next-20240625070454",
52
+ "@module-federation/node": "0.0.0-next-20240625070454"
53
53
  },
54
54
  "devDependencies": {
55
- "@modern-js/app-tools": "^2.49.2",
56
- "@modern-js/core": "^2.49.2",
57
- "@modern-js/runtime": "^2.49.2",
58
- "@modern-js/module-tools": "^2.35.0",
59
- "@modern-js/tsconfig": "^2.35.0",
60
- "@module-federation/manifest": "0.0.0-next-20240625025206"
55
+ "@modern-js/app-tools": "^2.54.2",
56
+ "@modern-js/core": "^2.54.2",
57
+ "@modern-js/runtime": "^2.54.2",
58
+ "@modern-js/module-tools": "^2.54.2",
59
+ "@modern-js/tsconfig": "^2.54.2",
60
+ "@module-federation/manifest": "0.0.0-next-20240625070454"
61
61
  },
62
62
  "peerDependencies": {
63
63
  "react": ">=17",