@module-federation/modern-js 0.0.0-next-20240716104220 → 0.0.0-next-20240716130450
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/configPlugin.js +6 -4
- package/dist/cjs/cli/index.js +2 -1
- package/dist/cjs/cli/utils.js +6 -3
- package/dist/cjs/runtime/createRemoteSSRComponent.js +2 -1
- package/dist/esm/cli/configPlugin.js +6 -4
- package/dist/esm/cli/index.js +2 -1
- package/dist/esm/cli/utils.js +6 -3
- package/dist/esm/runtime/createRemoteSSRComponent.js +5 -1
- package/dist/esm-node/cli/configPlugin.js +6 -4
- package/dist/esm-node/cli/index.js +2 -1
- package/dist/esm-node/cli/utils.js +6 -3
- package/dist/esm-node/runtime/createRemoteSSRComponent.js +2 -1
- package/dist/types/cli/configPlugin.d.ts +1 -0
- package/dist/types/cli/utils.d.ts +1 -1
- package/dist/types/runtime/createRemoteSSRComponent.d.ts +4 -1
- package/dist/types/types/index.d.ts +2 -0
- package/package.json +5 -5
|
@@ -43,8 +43,8 @@ function setEnv(enableSSR) {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
function modifyBundlerConfig(options) {
|
|
46
|
-
const { mfConfig, config, isServer, modernjsConfig, bundlerType } = options;
|
|
47
|
-
(0, import_utils.patchMFConfig)(mfConfig, isServer);
|
|
46
|
+
const { mfConfig, config, isServer, modernjsConfig, bundlerType, remoteIpStrategy = "ipv4" } = options;
|
|
47
|
+
(0, import_utils.patchMFConfig)(mfConfig, isServer, remoteIpStrategy);
|
|
48
48
|
(0, import_utils.patchBundlerConfig)({
|
|
49
49
|
bundlerConfig: config,
|
|
50
50
|
isServer,
|
|
@@ -88,7 +88,8 @@ const moduleFederationConfigPlugin = (userConfig) => ({
|
|
|
88
88
|
mfConfig: isServer ? ssrConfig : csrConfig,
|
|
89
89
|
config,
|
|
90
90
|
isServer,
|
|
91
|
-
modernjsConfig
|
|
91
|
+
modernjsConfig,
|
|
92
|
+
remoteIpStrategy: userConfig.remoteIpStrategy
|
|
92
93
|
});
|
|
93
94
|
userConfig.distOutputDir = ((_config_output = config.output) === null || _config_output === void 0 ? void 0 : _config_output.path) || import_path.default.resolve(process.cwd(), "dist");
|
|
94
95
|
},
|
|
@@ -99,7 +100,8 @@ const moduleFederationConfigPlugin = (userConfig) => ({
|
|
|
99
100
|
mfConfig: isServer ? ssrConfig : csrConfig,
|
|
100
101
|
config,
|
|
101
102
|
isServer,
|
|
102
|
-
modernjsConfig
|
|
103
|
+
modernjsConfig,
|
|
104
|
+
remoteIpStrategy: userConfig.remoteIpStrategy
|
|
103
105
|
});
|
|
104
106
|
userConfig.distOutputDir = ((_config_output = config.output) === null || _config_output === void 0 ? void 0 : _config_output.path) || import_path.default.resolve(process.cwd(), "dist");
|
|
105
107
|
},
|
package/dist/cjs/cli/index.js
CHANGED
|
@@ -35,7 +35,8 @@ const moduleFederationPlugin = (userConfig = {}) => {
|
|
|
35
35
|
browserPlugin: void 0,
|
|
36
36
|
nodePlugin: void 0,
|
|
37
37
|
distOutputDir: "",
|
|
38
|
-
originPluginOptions: userConfig
|
|
38
|
+
originPluginOptions: userConfig,
|
|
39
|
+
remoteIpStrategy: userConfig === null || userConfig === void 0 ? void 0 : userConfig.remoteIpStrategy
|
|
39
40
|
};
|
|
40
41
|
return {
|
|
41
42
|
name: "@modern-js/plugin-module-federation",
|
package/dist/cjs/cli/utils.js
CHANGED
|
@@ -56,7 +56,10 @@ const injectRuntimePlugins = (runtimePlugin, runtimePlugins) => {
|
|
|
56
56
|
runtimePlugins.push(runtimePlugin);
|
|
57
57
|
}
|
|
58
58
|
};
|
|
59
|
-
const replaceRemoteUrl = (mfConfig) => {
|
|
59
|
+
const replaceRemoteUrl = (mfConfig, remoteIpStrategy) => {
|
|
60
|
+
if (remoteIpStrategy && remoteIpStrategy === "inherit") {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
60
63
|
if (!mfConfig.remotes) {
|
|
61
64
|
return;
|
|
62
65
|
}
|
|
@@ -118,8 +121,8 @@ const patchDTSConfig = (mfConfig, isServer) => {
|
|
|
118
121
|
}
|
|
119
122
|
}
|
|
120
123
|
};
|
|
121
|
-
const patchMFConfig = (mfConfig, isServer) => {
|
|
122
|
-
replaceRemoteUrl(mfConfig);
|
|
124
|
+
const patchMFConfig = (mfConfig, isServer, remoteIpStrategy) => {
|
|
125
|
+
replaceRemoteUrl(mfConfig, remoteIpStrategy);
|
|
123
126
|
if (mfConfig.remoteType === void 0) {
|
|
124
127
|
mfConfig.remoteType = "script";
|
|
125
128
|
}
|
|
@@ -140,6 +140,7 @@ function collectSSRAssets(options) {
|
|
|
140
140
|
}
|
|
141
141
|
function createRemoteSSRComponent(info) {
|
|
142
142
|
return (props) => {
|
|
143
|
+
const { key, ...rest } = props;
|
|
143
144
|
const exportName = (info === null || info === void 0 ? void 0 : info.export) || "default";
|
|
144
145
|
const LazyComponent = /* @__PURE__ */ import_react.default.lazy(async () => {
|
|
145
146
|
try {
|
|
@@ -158,7 +159,7 @@ function createRemoteSSRComponent(info) {
|
|
|
158
159
|
children: [
|
|
159
160
|
assets,
|
|
160
161
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Com, {
|
|
161
|
-
...
|
|
162
|
+
...rest
|
|
162
163
|
})
|
|
163
164
|
]
|
|
164
165
|
})
|
|
@@ -9,8 +9,8 @@ function setEnv(enableSSR) {
|
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
function modifyBundlerConfig(options) {
|
|
12
|
-
var mfConfig = options.mfConfig, config = options.config, isServer = options.isServer, modernjsConfig = options.modernjsConfig, bundlerType = options.bundlerType;
|
|
13
|
-
patchMFConfig(mfConfig, isServer);
|
|
12
|
+
var mfConfig = options.mfConfig, config = options.config, isServer = options.isServer, modernjsConfig = options.modernjsConfig, bundlerType = options.bundlerType, _options_remoteIpStrategy = options.remoteIpStrategy, remoteIpStrategy = _options_remoteIpStrategy === void 0 ? "ipv4" : _options_remoteIpStrategy;
|
|
13
|
+
patchMFConfig(mfConfig, isServer, remoteIpStrategy);
|
|
14
14
|
patchBundlerConfig({
|
|
15
15
|
bundlerConfig: config,
|
|
16
16
|
isServer,
|
|
@@ -72,7 +72,8 @@ var moduleFederationConfigPlugin = function(userConfig) {
|
|
|
72
72
|
mfConfig: isServer ? ssrConfig : csrConfig,
|
|
73
73
|
config,
|
|
74
74
|
isServer,
|
|
75
|
-
modernjsConfig
|
|
75
|
+
modernjsConfig,
|
|
76
|
+
remoteIpStrategy: userConfig.remoteIpStrategy
|
|
76
77
|
});
|
|
77
78
|
userConfig.distOutputDir = ((_config_output = config.output) === null || _config_output === void 0 ? void 0 : _config_output.path) || path.resolve(process.cwd(), "dist");
|
|
78
79
|
},
|
|
@@ -84,7 +85,8 @@ var moduleFederationConfigPlugin = function(userConfig) {
|
|
|
84
85
|
mfConfig: isServer ? ssrConfig : csrConfig,
|
|
85
86
|
config,
|
|
86
87
|
isServer,
|
|
87
|
-
modernjsConfig
|
|
88
|
+
modernjsConfig,
|
|
89
|
+
remoteIpStrategy: userConfig.remoteIpStrategy
|
|
88
90
|
});
|
|
89
91
|
userConfig.distOutputDir = ((_config_output = config.output) === null || _config_output === void 0 ? void 0 : _config_output.path) || path.resolve(process.cwd(), "dist");
|
|
90
92
|
},
|
package/dist/esm/cli/index.js
CHANGED
|
@@ -12,7 +12,8 @@ var moduleFederationPlugin = function() {
|
|
|
12
12
|
browserPlugin: void 0,
|
|
13
13
|
nodePlugin: void 0,
|
|
14
14
|
distOutputDir: "",
|
|
15
|
-
originPluginOptions: userConfig
|
|
15
|
+
originPluginOptions: userConfig,
|
|
16
|
+
remoteIpStrategy: userConfig === null || userConfig === void 0 ? void 0 : userConfig.remoteIpStrategy
|
|
16
17
|
};
|
|
17
18
|
return {
|
|
18
19
|
name: "@modern-js/plugin-module-federation",
|
package/dist/esm/cli/utils.js
CHANGED
|
@@ -52,7 +52,10 @@ var injectRuntimePlugins = function(runtimePlugin, runtimePlugins) {
|
|
|
52
52
|
runtimePlugins.push(runtimePlugin);
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
|
-
var replaceRemoteUrl = function(mfConfig) {
|
|
55
|
+
var replaceRemoteUrl = function(mfConfig, remoteIpStrategy) {
|
|
56
|
+
if (remoteIpStrategy && remoteIpStrategy === "inherit") {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
56
59
|
if (!mfConfig.remotes) {
|
|
57
60
|
return;
|
|
58
61
|
}
|
|
@@ -114,8 +117,8 @@ var patchDTSConfig = function(mfConfig, isServer) {
|
|
|
114
117
|
}
|
|
115
118
|
}
|
|
116
119
|
};
|
|
117
|
-
var patchMFConfig = function(mfConfig, isServer) {
|
|
118
|
-
replaceRemoteUrl(mfConfig);
|
|
120
|
+
var patchMFConfig = function(mfConfig, isServer, remoteIpStrategy) {
|
|
121
|
+
replaceRemoteUrl(mfConfig, remoteIpStrategy);
|
|
119
122
|
if (mfConfig.remoteType === void 0) {
|
|
120
123
|
mfConfig.remoteType = "script";
|
|
121
124
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
2
|
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
3
3
|
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
4
|
+
import { _ as _object_without_properties } from "@swc/helpers/_/_object_without_properties";
|
|
4
5
|
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
|
5
6
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
6
7
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
@@ -98,6 +99,9 @@ function collectSSRAssets(options) {
|
|
|
98
99
|
}
|
|
99
100
|
function createRemoteSSRComponent(info) {
|
|
100
101
|
return function(props) {
|
|
102
|
+
var key = props.key, rest = _object_without_properties(props, [
|
|
103
|
+
"key"
|
|
104
|
+
]);
|
|
101
105
|
var exportName = (info === null || info === void 0 ? void 0 : info.export) || "default";
|
|
102
106
|
var LazyComponent = /* @__PURE__ */ React.lazy(/* @__PURE__ */ _async_to_generator(function() {
|
|
103
107
|
var m, moduleId, assets, Com, err, FallbackFunctionComponent, FallbackNode;
|
|
@@ -132,7 +136,7 @@ function createRemoteSSRComponent(info) {
|
|
|
132
136
|
return /* @__PURE__ */ _jsxs(_Fragment, {
|
|
133
137
|
children: [
|
|
134
138
|
assets,
|
|
135
|
-
/* @__PURE__ */ _jsx(Com, _object_spread({},
|
|
139
|
+
/* @__PURE__ */ _jsx(Com, _object_spread({}, rest))
|
|
136
140
|
]
|
|
137
141
|
});
|
|
138
142
|
}
|
|
@@ -7,8 +7,8 @@ function setEnv(enableSSR) {
|
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
function modifyBundlerConfig(options) {
|
|
10
|
-
const { mfConfig, config, isServer, modernjsConfig, bundlerType } = options;
|
|
11
|
-
patchMFConfig(mfConfig, isServer);
|
|
10
|
+
const { mfConfig, config, isServer, modernjsConfig, bundlerType, remoteIpStrategy = "ipv4" } = options;
|
|
11
|
+
patchMFConfig(mfConfig, isServer, remoteIpStrategy);
|
|
12
12
|
patchBundlerConfig({
|
|
13
13
|
bundlerConfig: config,
|
|
14
14
|
isServer,
|
|
@@ -52,7 +52,8 @@ const moduleFederationConfigPlugin = (userConfig) => ({
|
|
|
52
52
|
mfConfig: isServer ? ssrConfig : csrConfig,
|
|
53
53
|
config,
|
|
54
54
|
isServer,
|
|
55
|
-
modernjsConfig
|
|
55
|
+
modernjsConfig,
|
|
56
|
+
remoteIpStrategy: userConfig.remoteIpStrategy
|
|
56
57
|
});
|
|
57
58
|
userConfig.distOutputDir = ((_config_output = config.output) === null || _config_output === void 0 ? void 0 : _config_output.path) || path.resolve(process.cwd(), "dist");
|
|
58
59
|
},
|
|
@@ -63,7 +64,8 @@ const moduleFederationConfigPlugin = (userConfig) => ({
|
|
|
63
64
|
mfConfig: isServer ? ssrConfig : csrConfig,
|
|
64
65
|
config,
|
|
65
66
|
isServer,
|
|
66
|
-
modernjsConfig
|
|
67
|
+
modernjsConfig,
|
|
68
|
+
remoteIpStrategy: userConfig.remoteIpStrategy
|
|
67
69
|
});
|
|
68
70
|
userConfig.distOutputDir = ((_config_output = config.output) === null || _config_output === void 0 ? void 0 : _config_output.path) || path.resolve(process.cwd(), "dist");
|
|
69
71
|
},
|
|
@@ -9,7 +9,8 @@ const moduleFederationPlugin = (userConfig = {}) => {
|
|
|
9
9
|
browserPlugin: void 0,
|
|
10
10
|
nodePlugin: void 0,
|
|
11
11
|
distOutputDir: "",
|
|
12
|
-
originPluginOptions: userConfig
|
|
12
|
+
originPluginOptions: userConfig,
|
|
13
|
+
remoteIpStrategy: userConfig === null || userConfig === void 0 ? void 0 : userConfig.remoteIpStrategy
|
|
13
14
|
};
|
|
14
15
|
return {
|
|
15
16
|
name: "@modern-js/plugin-module-federation",
|
|
@@ -20,7 +20,10 @@ const injectRuntimePlugins = (runtimePlugin, runtimePlugins) => {
|
|
|
20
20
|
runtimePlugins.push(runtimePlugin);
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
|
-
const replaceRemoteUrl = (mfConfig) => {
|
|
23
|
+
const replaceRemoteUrl = (mfConfig, remoteIpStrategy) => {
|
|
24
|
+
if (remoteIpStrategy && remoteIpStrategy === "inherit") {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
24
27
|
if (!mfConfig.remotes) {
|
|
25
28
|
return;
|
|
26
29
|
}
|
|
@@ -82,8 +85,8 @@ const patchDTSConfig = (mfConfig, isServer) => {
|
|
|
82
85
|
}
|
|
83
86
|
}
|
|
84
87
|
};
|
|
85
|
-
const patchMFConfig = (mfConfig, isServer) => {
|
|
86
|
-
replaceRemoteUrl(mfConfig);
|
|
88
|
+
const patchMFConfig = (mfConfig, isServer, remoteIpStrategy) => {
|
|
89
|
+
replaceRemoteUrl(mfConfig, remoteIpStrategy);
|
|
87
90
|
if (mfConfig.remoteType === void 0) {
|
|
88
91
|
mfConfig.remoteType = "script";
|
|
89
92
|
}
|
|
@@ -106,6 +106,7 @@ function collectSSRAssets(options) {
|
|
|
106
106
|
}
|
|
107
107
|
function createRemoteSSRComponent(info) {
|
|
108
108
|
return (props) => {
|
|
109
|
+
const { key, ...rest } = props;
|
|
109
110
|
const exportName = (info === null || info === void 0 ? void 0 : info.export) || "default";
|
|
110
111
|
const LazyComponent = /* @__PURE__ */ React.lazy(async () => {
|
|
111
112
|
try {
|
|
@@ -124,7 +125,7 @@ function createRemoteSSRComponent(info) {
|
|
|
124
125
|
children: [
|
|
125
126
|
assets,
|
|
126
127
|
/* @__PURE__ */ _jsx(Com, {
|
|
127
|
-
...
|
|
128
|
+
...rest
|
|
128
129
|
})
|
|
129
130
|
]
|
|
130
131
|
})
|
|
@@ -9,6 +9,7 @@ export declare function modifyBundlerConfig<T extends Bundler>(options: {
|
|
|
9
9
|
config: BundlerConfig<T>;
|
|
10
10
|
isServer: boolean;
|
|
11
11
|
modernjsConfig: UserConfig<AppTools>;
|
|
12
|
+
remoteIpStrategy?: 'ipv4' | 'inherit';
|
|
12
13
|
}): void;
|
|
13
14
|
export declare const moduleFederationConfigPlugin: (userConfig: InternalModernPluginOptions) => CliPlugin<AppTools>;
|
|
14
15
|
export default moduleFederationConfigPlugin;
|
|
@@ -4,7 +4,7 @@ import { PluginOptions } from '../types';
|
|
|
4
4
|
import { BundlerConfig } from '../interfaces/bundler';
|
|
5
5
|
export type ConfigType<T> = T extends 'webpack' ? webpack.Configuration : T extends 'rspack' ? Rspack.Configuration : never;
|
|
6
6
|
export declare const getMFConfig: (userConfig: PluginOptions) => Promise<moduleFederationPlugin.ModuleFederationPluginOptions>;
|
|
7
|
-
export declare const patchMFConfig: (mfConfig: moduleFederationPlugin.ModuleFederationPluginOptions, isServer: boolean) => moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
7
|
+
export declare const patchMFConfig: (mfConfig: moduleFederationPlugin.ModuleFederationPluginOptions, isServer: boolean, remoteIpStrategy?: "ipv4" | "inherit") => moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
8
8
|
export declare function patchBundlerConfig<T extends Bundler>(options: {
|
|
9
9
|
bundlerConfig: BundlerConfig<T>;
|
|
10
10
|
isServer: boolean;
|
|
@@ -5,11 +5,14 @@ type IProps = {
|
|
|
5
5
|
injectScript?: boolean;
|
|
6
6
|
injectLink?: boolean;
|
|
7
7
|
};
|
|
8
|
+
type IKey = {
|
|
9
|
+
key?: React.Key | null;
|
|
10
|
+
};
|
|
8
11
|
export declare function collectSSRAssets(options: IProps): React.ReactNode[];
|
|
9
12
|
export declare function createRemoteSSRComponent<T, E extends keyof T>(info: {
|
|
10
13
|
loader: () => Promise<T>;
|
|
11
14
|
loading: React.ReactNode;
|
|
12
15
|
fallback: ErrorBoundaryPropsWithComponent['FallbackComponent'];
|
|
13
16
|
export?: E;
|
|
14
|
-
}): (props: T[E] extends (...args: any) => any ? Parameters<T[E]>[0] extends undefined ?
|
|
17
|
+
}): (props: T[E] extends (...args: any) => any ? Parameters<T[E]>[0] extends undefined ? IKey : Parameters<T[E]>[0] & IKey : IKey) => React.JSX.Element;
|
|
15
18
|
export {};
|
|
@@ -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
|
+
remoteIpStrategy?: 'ipv4' | 'inherit';
|
|
7
8
|
}
|
|
8
9
|
export interface InternalModernPluginOptions {
|
|
9
10
|
csrConfig?: moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
@@ -12,5 +13,6 @@ export interface InternalModernPluginOptions {
|
|
|
12
13
|
originPluginOptions: PluginOptions;
|
|
13
14
|
browserPlugin?: BundlerPlugin;
|
|
14
15
|
nodePlugin?: BundlerPlugin;
|
|
16
|
+
remoteIpStrategy?: 'ipv4' | 'inherit';
|
|
15
17
|
}
|
|
16
18
|
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-20240716130450",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist/",
|
|
6
6
|
"types.d.ts",
|
|
@@ -61,9 +61,9 @@
|
|
|
61
61
|
"node-fetch": "~3.3.0",
|
|
62
62
|
"react-error-boundary": "4.0.13",
|
|
63
63
|
"hoist-non-react-statics": "3.3.2",
|
|
64
|
-
"@module-federation/sdk": "0.0.0-next-
|
|
65
|
-
"@module-federation/enhanced": "0.0.0-next-
|
|
66
|
-
"@module-federation/node": "0.0.0-next-
|
|
64
|
+
"@module-federation/sdk": "0.0.0-next-20240716130450",
|
|
65
|
+
"@module-federation/enhanced": "0.0.0-next-20240716130450",
|
|
66
|
+
"@module-federation/node": "0.0.0-next-20240716130450"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@types/hoist-non-react-statics": "3.3.2",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"@modern-js/runtime": "^2.55.0",
|
|
73
73
|
"@modern-js/module-tools": "^2.55.0",
|
|
74
74
|
"@modern-js/tsconfig": "^2.55.0",
|
|
75
|
-
"@module-federation/manifest": "0.0.0-next-
|
|
75
|
+
"@module-federation/manifest": "0.0.0-next-20240716130450"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
78
|
"react": ">=17",
|