@module-federation/modern-js 0.0.0-next-20241212123451 → 0.0.0-next-20241213035216
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/dist/cjs/cli/index.js +2 -1
- package/dist/cjs/cli/ssrPlugin.js +13 -13
- package/dist/esm/cli/index.js +2 -1
- package/dist/esm/cli/ssrPlugin.js +13 -13
- package/dist/esm-node/cli/index.js +2 -1
- package/dist/esm-node/cli/ssrPlugin.js +13 -13
- package/dist/types/cli/ssrPlugin.d.ts +1 -1
- package/dist/types/types/index.d.ts +2 -0
- package/package.json +10 -5
package/dist/cjs/cli/index.js
CHANGED
|
@@ -36,7 +36,8 @@ const moduleFederationPlugin = (userConfig = {}) => {
|
|
|
36
36
|
nodePlugin: void 0,
|
|
37
37
|
distOutputDir: "",
|
|
38
38
|
originPluginOptions: userConfig,
|
|
39
|
-
remoteIpStrategy: userConfig === null || userConfig === void 0 ? void 0 : userConfig.remoteIpStrategy
|
|
39
|
+
remoteIpStrategy: userConfig === null || userConfig === void 0 ? void 0 : userConfig.remoteIpStrategy,
|
|
40
|
+
userConfig
|
|
40
41
|
};
|
|
41
42
|
return {
|
|
42
43
|
name: "@modern-js/plugin-module-federation",
|
|
@@ -45,17 +45,17 @@ function setEnv() {
|
|
|
45
45
|
process.env["MF_DISABLE_EMIT_STATS"] = "true";
|
|
46
46
|
process.env["MF_SSR_PRJ"] = "true";
|
|
47
47
|
}
|
|
48
|
-
const moduleFederationSSRPlugin = (
|
|
48
|
+
const moduleFederationSSRPlugin = (pluginOptions) => ({
|
|
49
49
|
name: "@modern-js/plugin-module-federation-ssr",
|
|
50
50
|
pre: [
|
|
51
51
|
"@modern-js/plugin-module-federation-config",
|
|
52
52
|
"@modern-js/plugin-module-federation"
|
|
53
53
|
],
|
|
54
54
|
setup: async ({ useConfigContext, useAppContext }) => {
|
|
55
|
-
var _modernjsConfig_server;
|
|
55
|
+
var _modernjsConfig_server, _pluginOptions_userConfig;
|
|
56
56
|
const modernjsConfig = useConfigContext();
|
|
57
57
|
const enableSSR = Boolean(modernjsConfig === null || modernjsConfig === void 0 ? void 0 : (_modernjsConfig_server = modernjsConfig.server) === null || _modernjsConfig_server === void 0 ? void 0 : _modernjsConfig_server.ssr);
|
|
58
|
-
if (!enableSSR) {
|
|
58
|
+
if (!enableSSR || ((_pluginOptions_userConfig = pluginOptions.userConfig) === null || _pluginOptions_userConfig === void 0 ? void 0 : _pluginOptions_userConfig.disableSSR)) {
|
|
59
59
|
return {};
|
|
60
60
|
}
|
|
61
61
|
setEnv();
|
|
@@ -82,26 +82,26 @@ const moduleFederationSSRPlugin = (userConfig) => ({
|
|
|
82
82
|
tools: {
|
|
83
83
|
rspack(config, { isServer }) {
|
|
84
84
|
if (isServer) {
|
|
85
|
-
if (!
|
|
85
|
+
if (!pluginOptions.nodePlugin) {
|
|
86
86
|
var _config_plugins;
|
|
87
|
-
|
|
88
|
-
(_config_plugins = config.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.push(
|
|
87
|
+
pluginOptions.nodePlugin = new import_rspack.ModuleFederationPlugin(pluginOptions.ssrConfig);
|
|
88
|
+
(_config_plugins = config.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.push(pluginOptions.nodePlugin);
|
|
89
89
|
}
|
|
90
90
|
} else {
|
|
91
91
|
var _config_output;
|
|
92
|
-
|
|
92
|
+
pluginOptions.distOutputDir = pluginOptions.distOutputDir || ((_config_output = config.output) === null || _config_output === void 0 ? void 0 : _config_output.path) || import_path.default.resolve(process.cwd(), "dist");
|
|
93
93
|
}
|
|
94
94
|
},
|
|
95
95
|
webpack(config, { isServer }) {
|
|
96
96
|
if (isServer) {
|
|
97
|
-
if (!
|
|
97
|
+
if (!pluginOptions.nodePlugin) {
|
|
98
98
|
var _config_plugins;
|
|
99
|
-
|
|
100
|
-
(_config_plugins = config.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.push(
|
|
99
|
+
pluginOptions.nodePlugin = new import_webpack.ModuleFederationPlugin(pluginOptions.ssrConfig);
|
|
100
|
+
(_config_plugins = config.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.push(pluginOptions.nodePlugin);
|
|
101
101
|
}
|
|
102
102
|
} else {
|
|
103
103
|
var _config_output;
|
|
104
|
-
|
|
104
|
+
pluginOptions.distOutputDir = pluginOptions.distOutputDir || ((_config_output = config.output) === null || _config_output === void 0 ? void 0 : _config_output.path) || import_path.default.resolve(process.cwd(), "dist");
|
|
105
105
|
}
|
|
106
106
|
},
|
|
107
107
|
devServer: {
|
|
@@ -147,11 +147,11 @@ const moduleFederationSSRPlugin = (userConfig) => ({
|
|
|
147
147
|
};
|
|
148
148
|
},
|
|
149
149
|
afterBuild: () => {
|
|
150
|
-
const { nodePlugin, browserPlugin, distOutputDir } =
|
|
150
|
+
const { nodePlugin, browserPlugin, distOutputDir } = pluginOptions;
|
|
151
151
|
(0, import_manifest.updateStatsAndManifest)(nodePlugin, browserPlugin, distOutputDir);
|
|
152
152
|
},
|
|
153
153
|
afterDev: () => {
|
|
154
|
-
const { nodePlugin, browserPlugin, distOutputDir } =
|
|
154
|
+
const { nodePlugin, browserPlugin, distOutputDir } = pluginOptions;
|
|
155
155
|
(0, import_manifest.updateStatsAndManifest)(nodePlugin, browserPlugin, distOutputDir);
|
|
156
156
|
}
|
|
157
157
|
};
|
package/dist/esm/cli/index.js
CHANGED
|
@@ -14,7 +14,8 @@ var moduleFederationPlugin = function() {
|
|
|
14
14
|
nodePlugin: void 0,
|
|
15
15
|
distOutputDir: "",
|
|
16
16
|
originPluginOptions: userConfig,
|
|
17
|
-
remoteIpStrategy: userConfig === null || userConfig === void 0 ? void 0 : userConfig.remoteIpStrategy
|
|
17
|
+
remoteIpStrategy: userConfig === null || userConfig === void 0 ? void 0 : userConfig.remoteIpStrategy,
|
|
18
|
+
userConfig
|
|
18
19
|
};
|
|
19
20
|
return {
|
|
20
21
|
name: "@modern-js/plugin-module-federation",
|
|
@@ -12,7 +12,7 @@ function setEnv() {
|
|
|
12
12
|
process.env["MF_DISABLE_EMIT_STATS"] = "true";
|
|
13
13
|
process.env["MF_SSR_PRJ"] = "true";
|
|
14
14
|
}
|
|
15
|
-
var moduleFederationSSRPlugin = function(
|
|
15
|
+
var moduleFederationSSRPlugin = function(pluginOptions) {
|
|
16
16
|
return {
|
|
17
17
|
name: "@modern-js/plugin-module-federation-ssr",
|
|
18
18
|
pre: [
|
|
@@ -21,12 +21,12 @@ var moduleFederationSSRPlugin = function(userConfig) {
|
|
|
21
21
|
],
|
|
22
22
|
setup: function() {
|
|
23
23
|
var _ref = _async_to_generator(function(param) {
|
|
24
|
-
var useConfigContext, useAppContext, _modernjsConfig_server, modernjsConfig, enableSSR;
|
|
24
|
+
var useConfigContext, useAppContext, _modernjsConfig_server, _pluginOptions_userConfig, modernjsConfig, enableSSR;
|
|
25
25
|
return _ts_generator(this, function(_state) {
|
|
26
26
|
useConfigContext = param.useConfigContext, useAppContext = param.useAppContext;
|
|
27
27
|
modernjsConfig = useConfigContext();
|
|
28
28
|
enableSSR = Boolean(modernjsConfig === null || modernjsConfig === void 0 ? void 0 : (_modernjsConfig_server = modernjsConfig.server) === null || _modernjsConfig_server === void 0 ? void 0 : _modernjsConfig_server.ssr);
|
|
29
|
-
if (!enableSSR) {
|
|
29
|
+
if (!enableSSR || ((_pluginOptions_userConfig = pluginOptions.userConfig) === null || _pluginOptions_userConfig === void 0 ? void 0 : _pluginOptions_userConfig.disableSSR)) {
|
|
30
30
|
return [
|
|
31
31
|
2,
|
|
32
32
|
{}
|
|
@@ -63,27 +63,27 @@ var moduleFederationSSRPlugin = function(userConfig) {
|
|
|
63
63
|
rspack: function rspack(config, param2) {
|
|
64
64
|
var isServer = param2.isServer;
|
|
65
65
|
if (isServer) {
|
|
66
|
-
if (!
|
|
66
|
+
if (!pluginOptions.nodePlugin) {
|
|
67
67
|
var _config_plugins;
|
|
68
|
-
|
|
69
|
-
(_config_plugins = config.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.push(
|
|
68
|
+
pluginOptions.nodePlugin = new RspackModuleFederationPlugin(pluginOptions.ssrConfig);
|
|
69
|
+
(_config_plugins = config.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.push(pluginOptions.nodePlugin);
|
|
70
70
|
}
|
|
71
71
|
} else {
|
|
72
72
|
var _config_output;
|
|
73
|
-
|
|
73
|
+
pluginOptions.distOutputDir = pluginOptions.distOutputDir || ((_config_output = config.output) === null || _config_output === void 0 ? void 0 : _config_output.path) || path.resolve(process.cwd(), "dist");
|
|
74
74
|
}
|
|
75
75
|
},
|
|
76
76
|
webpack: function webpack(config, param2) {
|
|
77
77
|
var isServer = param2.isServer;
|
|
78
78
|
if (isServer) {
|
|
79
|
-
if (!
|
|
79
|
+
if (!pluginOptions.nodePlugin) {
|
|
80
80
|
var _config_plugins;
|
|
81
|
-
|
|
82
|
-
(_config_plugins = config.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.push(
|
|
81
|
+
pluginOptions.nodePlugin = new ModuleFederationPlugin(pluginOptions.ssrConfig);
|
|
82
|
+
(_config_plugins = config.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.push(pluginOptions.nodePlugin);
|
|
83
83
|
}
|
|
84
84
|
} else {
|
|
85
85
|
var _config_output;
|
|
86
|
-
|
|
86
|
+
pluginOptions.distOutputDir = pluginOptions.distOutputDir || ((_config_output = config.output) === null || _config_output === void 0 ? void 0 : _config_output.path) || path.resolve(process.cwd(), "dist");
|
|
87
87
|
}
|
|
88
88
|
},
|
|
89
89
|
devServer: {
|
|
@@ -132,11 +132,11 @@ var moduleFederationSSRPlugin = function(userConfig) {
|
|
|
132
132
|
});
|
|
133
133
|
}),
|
|
134
134
|
afterBuild: function() {
|
|
135
|
-
var nodePlugin =
|
|
135
|
+
var nodePlugin = pluginOptions.nodePlugin, browserPlugin = pluginOptions.browserPlugin, distOutputDir = pluginOptions.distOutputDir;
|
|
136
136
|
updateStatsAndManifest(nodePlugin, browserPlugin, distOutputDir);
|
|
137
137
|
},
|
|
138
138
|
afterDev: function() {
|
|
139
|
-
var nodePlugin =
|
|
139
|
+
var nodePlugin = pluginOptions.nodePlugin, browserPlugin = pluginOptions.browserPlugin, distOutputDir = pluginOptions.distOutputDir;
|
|
140
140
|
updateStatsAndManifest(nodePlugin, browserPlugin, distOutputDir);
|
|
141
141
|
}
|
|
142
142
|
}
|
|
@@ -10,7 +10,8 @@ const moduleFederationPlugin = (userConfig = {}) => {
|
|
|
10
10
|
nodePlugin: void 0,
|
|
11
11
|
distOutputDir: "",
|
|
12
12
|
originPluginOptions: userConfig,
|
|
13
|
-
remoteIpStrategy: userConfig === null || userConfig === void 0 ? void 0 : userConfig.remoteIpStrategy
|
|
13
|
+
remoteIpStrategy: userConfig === null || userConfig === void 0 ? void 0 : userConfig.remoteIpStrategy,
|
|
14
|
+
userConfig
|
|
14
15
|
};
|
|
15
16
|
return {
|
|
16
17
|
name: "@modern-js/plugin-module-federation",
|
|
@@ -10,17 +10,17 @@ function setEnv() {
|
|
|
10
10
|
process.env["MF_DISABLE_EMIT_STATS"] = "true";
|
|
11
11
|
process.env["MF_SSR_PRJ"] = "true";
|
|
12
12
|
}
|
|
13
|
-
const moduleFederationSSRPlugin = (
|
|
13
|
+
const moduleFederationSSRPlugin = (pluginOptions) => ({
|
|
14
14
|
name: "@modern-js/plugin-module-federation-ssr",
|
|
15
15
|
pre: [
|
|
16
16
|
"@modern-js/plugin-module-federation-config",
|
|
17
17
|
"@modern-js/plugin-module-federation"
|
|
18
18
|
],
|
|
19
19
|
setup: async ({ useConfigContext, useAppContext }) => {
|
|
20
|
-
var _modernjsConfig_server;
|
|
20
|
+
var _modernjsConfig_server, _pluginOptions_userConfig;
|
|
21
21
|
const modernjsConfig = useConfigContext();
|
|
22
22
|
const enableSSR = Boolean(modernjsConfig === null || modernjsConfig === void 0 ? void 0 : (_modernjsConfig_server = modernjsConfig.server) === null || _modernjsConfig_server === void 0 ? void 0 : _modernjsConfig_server.ssr);
|
|
23
|
-
if (!enableSSR) {
|
|
23
|
+
if (!enableSSR || ((_pluginOptions_userConfig = pluginOptions.userConfig) === null || _pluginOptions_userConfig === void 0 ? void 0 : _pluginOptions_userConfig.disableSSR)) {
|
|
24
24
|
return {};
|
|
25
25
|
}
|
|
26
26
|
setEnv();
|
|
@@ -47,26 +47,26 @@ const moduleFederationSSRPlugin = (userConfig) => ({
|
|
|
47
47
|
tools: {
|
|
48
48
|
rspack(config, { isServer }) {
|
|
49
49
|
if (isServer) {
|
|
50
|
-
if (!
|
|
50
|
+
if (!pluginOptions.nodePlugin) {
|
|
51
51
|
var _config_plugins;
|
|
52
|
-
|
|
53
|
-
(_config_plugins = config.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.push(
|
|
52
|
+
pluginOptions.nodePlugin = new RspackModuleFederationPlugin(pluginOptions.ssrConfig);
|
|
53
|
+
(_config_plugins = config.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.push(pluginOptions.nodePlugin);
|
|
54
54
|
}
|
|
55
55
|
} else {
|
|
56
56
|
var _config_output;
|
|
57
|
-
|
|
57
|
+
pluginOptions.distOutputDir = pluginOptions.distOutputDir || ((_config_output = config.output) === null || _config_output === void 0 ? void 0 : _config_output.path) || path.resolve(process.cwd(), "dist");
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
60
|
webpack(config, { isServer }) {
|
|
61
61
|
if (isServer) {
|
|
62
|
-
if (!
|
|
62
|
+
if (!pluginOptions.nodePlugin) {
|
|
63
63
|
var _config_plugins;
|
|
64
|
-
|
|
65
|
-
(_config_plugins = config.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.push(
|
|
64
|
+
pluginOptions.nodePlugin = new ModuleFederationPlugin(pluginOptions.ssrConfig);
|
|
65
|
+
(_config_plugins = config.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.push(pluginOptions.nodePlugin);
|
|
66
66
|
}
|
|
67
67
|
} else {
|
|
68
68
|
var _config_output;
|
|
69
|
-
|
|
69
|
+
pluginOptions.distOutputDir = pluginOptions.distOutputDir || ((_config_output = config.output) === null || _config_output === void 0 ? void 0 : _config_output.path) || path.resolve(process.cwd(), "dist");
|
|
70
70
|
}
|
|
71
71
|
},
|
|
72
72
|
devServer: {
|
|
@@ -112,11 +112,11 @@ const moduleFederationSSRPlugin = (userConfig) => ({
|
|
|
112
112
|
};
|
|
113
113
|
},
|
|
114
114
|
afterBuild: () => {
|
|
115
|
-
const { nodePlugin, browserPlugin, distOutputDir } =
|
|
115
|
+
const { nodePlugin, browserPlugin, distOutputDir } = pluginOptions;
|
|
116
116
|
updateStatsAndManifest(nodePlugin, browserPlugin, distOutputDir);
|
|
117
117
|
},
|
|
118
118
|
afterDev: () => {
|
|
119
|
-
const { nodePlugin, browserPlugin, distOutputDir } =
|
|
119
|
+
const { nodePlugin, browserPlugin, distOutputDir } = pluginOptions;
|
|
120
120
|
updateStatsAndManifest(nodePlugin, browserPlugin, distOutputDir);
|
|
121
121
|
}
|
|
122
122
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CliPlugin, AppTools } from '@modern-js/app-tools';
|
|
2
2
|
import type { InternalModernPluginOptions } from '../types';
|
|
3
3
|
export declare function setEnv(): void;
|
|
4
|
-
export declare const moduleFederationSSRPlugin: (
|
|
4
|
+
export declare const moduleFederationSSRPlugin: (pluginOptions: Required<InternalModernPluginOptions>) => CliPlugin<AppTools>;
|
|
5
5
|
export default moduleFederationSSRPlugin;
|
|
@@ -4,6 +4,7 @@ import type { ModuleFederationPlugin as RspackModuleFederationPlugin } from '@mo
|
|
|
4
4
|
export interface PluginOptions {
|
|
5
5
|
config?: moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
6
6
|
configPath?: string;
|
|
7
|
+
disableSSR?: boolean;
|
|
7
8
|
remoteIpStrategy?: 'ipv4' | 'inherit';
|
|
8
9
|
}
|
|
9
10
|
export interface InternalModernPluginOptions {
|
|
@@ -14,5 +15,6 @@ export interface InternalModernPluginOptions {
|
|
|
14
15
|
browserPlugin?: BundlerPlugin;
|
|
15
16
|
nodePlugin?: BundlerPlugin;
|
|
16
17
|
remoteIpStrategy?: 'ipv4' | 'inherit';
|
|
18
|
+
userConfig?: PluginOptions;
|
|
17
19
|
}
|
|
18
20
|
export type BundlerPlugin = WebpackModuleFederationPlugin | RspackModuleFederationPlugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/modern-js",
|
|
3
|
-
"version": "0.0.0-next-
|
|
3
|
+
"version": "0.0.0-next-20241213035216",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist/",
|
|
6
6
|
"types.d.ts",
|
|
@@ -9,6 +9,11 @@
|
|
|
9
9
|
"publishConfig": {
|
|
10
10
|
"access": "public"
|
|
11
11
|
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/module-federation/core/",
|
|
15
|
+
"directory": "packages/repository"
|
|
16
|
+
},
|
|
12
17
|
"exports": {
|
|
13
18
|
".": {
|
|
14
19
|
"import": "./dist/esm/cli/index.js",
|
|
@@ -85,9 +90,9 @@
|
|
|
85
90
|
"hoist-non-react-statics": "3.3.2",
|
|
86
91
|
"node-fetch": "~3.3.0",
|
|
87
92
|
"react-error-boundary": "4.0.13",
|
|
88
|
-
"@module-federation/enhanced": "0.0.0-next-
|
|
89
|
-
"@module-federation/node": "0.0.0-next-
|
|
90
|
-
"@module-federation/sdk": "0.0.0-next-
|
|
93
|
+
"@module-federation/enhanced": "0.0.0-next-20241213035216",
|
|
94
|
+
"@module-federation/node": "0.0.0-next-20241213035216",
|
|
95
|
+
"@module-federation/sdk": "0.0.0-next-20241213035216"
|
|
91
96
|
},
|
|
92
97
|
"devDependencies": {
|
|
93
98
|
"@modern-js/app-tools": "2.60.6",
|
|
@@ -96,7 +101,7 @@
|
|
|
96
101
|
"@modern-js/runtime": "2.60.6",
|
|
97
102
|
"@modern-js/tsconfig": "2.60.6",
|
|
98
103
|
"@types/hoist-non-react-statics": "3.3.5",
|
|
99
|
-
"@module-federation/manifest": "0.0.0-next-
|
|
104
|
+
"@module-federation/manifest": "0.0.0-next-20241213035216"
|
|
100
105
|
},
|
|
101
106
|
"peerDependencies": {
|
|
102
107
|
"react": ">=17",
|