@module-federation/modern-js 0.0.0-perf-devtools-20260108034446 → 0.0.0-perf-website-code-usage-20260914033703
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 +297 -264
- package/dist/cjs/cli/index.js +24 -12
- package/dist/cjs/cli/mfRuntimePlugins/inject-node-fetch.js +14 -21
- package/dist/cjs/cli/mfRuntimePlugins/shared-strategy.js +12 -8
- package/dist/cjs/cli/server/data-fetch-server-plugin.js +9 -5
- package/dist/cjs/cli/ssrPlugin.js +51 -17
- package/dist/cjs/cli/utils.js +9 -5
- package/dist/cjs/constant.js +13 -9
- package/dist/cjs/logger.js +9 -5
- package/dist/cjs/react/data-fetch.js +62 -0
- package/dist/cjs/react/index.js +9 -5
- package/dist/cjs/react/plugin.js +12 -8
- package/dist/cjs/react/v18.js +9 -5
- package/dist/cjs/react/v19.js +9 -5
- package/dist/cjs/runtime/index.js +9 -5
- package/dist/cjs/server/fileCache.js +25 -23
- package/dist/cjs/server/index.js +9 -5
- package/dist/cjs/server/staticMiddleware.js +21 -10
- package/dist/cjs/ssr-runtime/SSRLiveReload.js +10 -5
- package/dist/cjs/ssr-runtime/devPlugin.js +11 -7
- package/dist/cjs/ssr-runtime/injectDataFetchFunctionPlugin.js +12 -9
- package/dist/esm/cli/configPlugin.mjs +80 -59
- package/dist/esm/cli/index.mjs +19 -10
- package/dist/esm/cli/mfRuntimePlugins/inject-node-fetch.mjs +4 -5
- package/dist/esm/cli/mfRuntimePlugins/shared-strategy.mjs +3 -3
- package/dist/esm/cli/server/data-fetch-server-plugin.mjs +3 -3
- package/dist/esm/cli/ssrPlugin.mjs +58 -14
- package/dist/esm/cli/utils.mjs +6 -6
- package/dist/esm/interfaces/bundler.mjs +1 -0
- package/dist/esm/logger.mjs +1 -1
- package/dist/esm/react/data-fetch.mjs +1 -0
- package/dist/esm/react/plugin.mjs +1 -2
- package/dist/esm/rslib-runtime.mjs +18 -0
- package/dist/esm/server/fileCache.mjs +44 -8
- package/dist/esm/server/index.mjs +4 -3
- package/dist/esm/server/staticMiddleware.mjs +42 -7
- package/dist/esm/ssr-runtime/SSRLiveReload.mjs +1 -0
- package/dist/esm/ssr-runtime/devPlugin.mjs +3 -3
- package/dist/esm/ssr-runtime/injectDataFetchFunctionPlugin.mjs +3 -4
- package/dist/esm/types/index.mjs +1 -0
- package/dist/esm-node/cli/configPlugin.mjs +62 -45
- package/dist/esm-node/cli/index.mjs +17 -8
- package/dist/esm-node/cli/mfRuntimePlugins/inject-node-fetch.mjs +2 -3
- package/dist/esm-node/cli/mfRuntimePlugins/shared-strategy.mjs +1 -1
- package/dist/esm-node/cli/server/data-fetch-server-plugin.mjs +1 -1
- package/dist/esm-node/cli/ssrPlugin.mjs +41 -10
- package/dist/esm-node/interfaces/bundler.mjs +1 -0
- package/dist/esm-node/logger.mjs +1 -1
- package/dist/esm-node/react/data-fetch.mjs +1 -0
- package/dist/esm-node/react/plugin.mjs +1 -2
- package/dist/esm-node/rslib-runtime.mjs +18 -0
- package/dist/esm-node/server/fileCache.mjs +16 -8
- package/dist/esm-node/server/index.mjs +2 -1
- package/dist/esm-node/server/staticMiddleware.mjs +10 -2
- package/dist/esm-node/ssr-runtime/SSRLiveReload.mjs +1 -0
- package/dist/esm-node/ssr-runtime/devPlugin.mjs +1 -1
- package/dist/esm-node/ssr-runtime/injectDataFetchFunctionPlugin.mjs +1 -2
- package/dist/esm-node/types/index.mjs +1 -0
- package/dist/types/cli/configPlugin.d.ts +2 -1
- package/dist/types/react/data-fetch.d.ts +1 -0
- package/dist/types/server/fileCache.d.ts +1 -0
- package/dist/types/ssr-runtime/SSRLiveReload.d.ts +2 -1
- package/dist/types/types/index.d.ts +8 -2
- package/package.json +34 -33
- package/dist/LICENSE +0 -21
- package/dist/cjs/cli/mfRuntimePlugins/resolve-entry-ipv4.js +0 -80
- package/dist/esm/cli/mfRuntimePlugins/resolve-entry-ipv4.mjs +0 -58
- package/dist/esm-node/cli/mfRuntimePlugins/resolve-entry-ipv4.mjs +0 -46
- package/dist/types/cli/configPlugin.spec.d.ts +0 -1
- package/dist/types/cli/mfRuntimePlugins/resolve-entry-ipv4.d.ts +0 -3
- package/dist/types/server/fileCache.spec.d.ts +0 -1
- package/dist/types/server/staticMiddleware.spec.d.ts +0 -1
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
2
|
+
var __webpack_modules__ = {
|
|
3
|
+
jiti (module) {
|
|
4
|
+
module.exports = require("jiti");
|
|
5
|
+
}
|
|
6
|
+
};
|
|
7
|
+
var __webpack_module_cache__ = {};
|
|
8
|
+
function __webpack_require__(moduleId) {
|
|
9
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
10
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
11
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
12
|
+
exports: {}
|
|
13
|
+
};
|
|
14
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
15
|
+
return module.exports;
|
|
16
|
+
}
|
|
3
17
|
(()=>{
|
|
4
18
|
__webpack_require__.n = (module)=>{
|
|
5
19
|
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
@@ -10,11 +24,15 @@ var __webpack_require__ = {};
|
|
|
10
24
|
};
|
|
11
25
|
})();
|
|
12
26
|
(()=>{
|
|
13
|
-
__webpack_require__.d = (exports1,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
27
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
28
|
+
var define = (defs, kind)=>{
|
|
29
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
[kind]: defs[key]
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
define(getters, "get");
|
|
35
|
+
define(values, "value");
|
|
18
36
|
};
|
|
19
37
|
})();
|
|
20
38
|
(()=>{
|
|
@@ -31,282 +49,295 @@ var __webpack_require__ = {};
|
|
|
31
49
|
};
|
|
32
50
|
})();
|
|
33
51
|
var __webpack_exports__ = {};
|
|
34
|
-
|
|
35
|
-
__webpack_require__.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
|
|
48
|
-
const external_utils_js_namespaceObject = require("./utils.js");
|
|
49
|
-
const sdk_namespaceObject = require("@module-federation/sdk");
|
|
50
|
-
const node_bundle_require_namespaceObject = require("@modern-js/node-bundle-require");
|
|
51
|
-
const external_constant_js_namespaceObject = require("../constant.js");
|
|
52
|
-
const utils_namespaceObject = require("@module-federation/rsbuild-plugin/utils");
|
|
53
|
-
const external_logger_js_namespaceObject = require("../logger.js");
|
|
54
|
-
var external_logger_js_default = /*#__PURE__*/ __webpack_require__.n(external_logger_js_namespaceObject);
|
|
55
|
-
const defaultPath = external_path_default().resolve(process.cwd(), 'module-federation.config.ts');
|
|
56
|
-
function setEnv(enableSSR) {
|
|
57
|
-
if (enableSSR) process.env['MF_SSR_PRJ'] = 'true';
|
|
58
|
-
}
|
|
59
|
-
const getMFConfig = async (userConfig)=>{
|
|
60
|
-
const { config, configPath } = userConfig;
|
|
61
|
-
if (config) return config;
|
|
62
|
-
const mfConfigPath = configPath ? configPath : defaultPath;
|
|
63
|
-
const preBundlePath = await (0, node_bundle_require_namespaceObject.bundle)(mfConfigPath);
|
|
64
|
-
const mfConfig = (await import(preBundlePath)).default;
|
|
65
|
-
return mfConfig;
|
|
66
|
-
};
|
|
67
|
-
const injectRuntimePlugins = (runtimePlugin, runtimePlugins)=>{
|
|
68
|
-
const pluginName = 'string' == typeof runtimePlugin ? runtimePlugin : runtimePlugin[0];
|
|
69
|
-
const hasPlugin = runtimePlugins.some((existingPlugin)=>{
|
|
70
|
-
if ('string' == typeof existingPlugin) return existingPlugin === pluginName;
|
|
71
|
-
return existingPlugin[0] === pluginName;
|
|
52
|
+
(()=>{
|
|
53
|
+
__webpack_require__.r(__webpack_exports__);
|
|
54
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
55
|
+
addMyTypes2Ignored: ()=>addMyTypes2Ignored,
|
|
56
|
+
default: ()=>configPlugin,
|
|
57
|
+
getMFConfig: ()=>getMFConfig,
|
|
58
|
+
isWebTarget: ()=>external_utils_js_namespaceObject.isWebTarget,
|
|
59
|
+
moduleFederationConfigPlugin: ()=>moduleFederationConfigPlugin,
|
|
60
|
+
patchBundlerConfig: ()=>patchBundlerConfig,
|
|
61
|
+
patchMFConfig: ()=>patchMFConfig,
|
|
62
|
+
setDefaultOptimizationTarget: ()=>setDefaultOptimizationTarget,
|
|
63
|
+
setEnv: ()=>setEnv,
|
|
64
|
+
skipByTarget: ()=>external_utils_js_namespaceObject.skipByTarget
|
|
72
65
|
});
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
66
|
+
const external_fs_namespaceObject = require("fs");
|
|
67
|
+
var external_fs_default = /*#__PURE__*/ __webpack_require__.n(external_fs_namespaceObject);
|
|
68
|
+
const external_path_namespaceObject = require("path");
|
|
69
|
+
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
|
|
70
|
+
const external_utils_js_namespaceObject = require("./utils.js");
|
|
71
|
+
const sdk_namespaceObject = require("@module-federation/sdk");
|
|
72
|
+
const external_constant_js_namespaceObject = require("../constant.js");
|
|
73
|
+
const utils_namespaceObject = require("@module-federation/rsbuild-plugin/utils");
|
|
74
|
+
const external_logger_js_namespaceObject = require("../logger.js");
|
|
75
|
+
var external_logger_js_default = /*#__PURE__*/ __webpack_require__.n(external_logger_js_namespaceObject);
|
|
76
|
+
const defaultPath = external_path_default().resolve(process.cwd(), 'module-federation.config.ts');
|
|
77
|
+
const resolvePackageFile = (packageName, esmRelativePath, cjsRelativePath)=>{
|
|
78
|
+
const packageEntry = require.resolve(packageName);
|
|
79
|
+
let packageRoot = external_path_default().dirname(packageEntry);
|
|
80
|
+
while(!external_fs_default().existsSync(external_path_default().join(packageRoot, 'package.json'))){
|
|
81
|
+
const parentDir = external_path_default().dirname(packageRoot);
|
|
82
|
+
if (parentDir === packageRoot) throw new Error(`Unable to resolve package root for ${packageName} from ${packageEntry}`);
|
|
83
|
+
packageRoot = parentDir;
|
|
84
|
+
}
|
|
85
|
+
return require.resolve(external_path_default().join(packageRoot, 'true' === process.env['IS_ESM_BUILD'] ? esmRelativePath : cjsRelativePath));
|
|
86
|
+
};
|
|
87
|
+
const resolveSharedStrategyPlugin = ()=>resolvePackageFile('@module-federation/modern-js', 'dist/esm/cli/mfRuntimePlugins/shared-strategy.mjs', 'dist/cjs/cli/mfRuntimePlugins/shared-strategy.js');
|
|
88
|
+
const resolveInjectNodeFetchPlugin = ()=>resolvePackageFile('@module-federation/modern-js', 'dist/esm/cli/mfRuntimePlugins/inject-node-fetch.mjs', 'dist/cjs/cli/mfRuntimePlugins/inject-node-fetch.js');
|
|
89
|
+
const resolveNodeRuntimePlugin = ()=>resolvePackageFile('@module-federation/node', 'dist/src/runtimePlugin.mjs', 'dist/src/runtimePlugin.js');
|
|
90
|
+
const resolveNodeRecordRemoteHashPlugin = ()=>resolvePackageFile('@module-federation/node', 'dist/src/recordDynamicRemoteEntryHashPlugin.mjs', 'dist/src/recordDynamicRemoteEntryHashPlugin.js');
|
|
91
|
+
function setEnv(enableSSR) {
|
|
92
|
+
if (enableSSR) process.env['MF_SSR_PRJ'] = 'true';
|
|
93
|
+
}
|
|
94
|
+
const getMFConfig = async (userConfig)=>{
|
|
95
|
+
const { config, configPath } = userConfig;
|
|
96
|
+
if (config) return config;
|
|
97
|
+
const mfConfigPath = configPath ? configPath : defaultPath;
|
|
98
|
+
const { createJiti } = __webpack_require__("jiti");
|
|
99
|
+
const jit = createJiti(__filename, {
|
|
100
|
+
interopDefault: true
|
|
85
101
|
});
|
|
102
|
+
const configModule = await jit(mfConfigPath);
|
|
103
|
+
const resolvedConfig = configModule && 'object' == typeof configModule && 'default' in configModule ? configModule.default : configModule;
|
|
104
|
+
return resolvedConfig;
|
|
86
105
|
};
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if (
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
var _mfConfig_dts2;
|
|
107
|
-
if ('boolean' == typeof mfConfig.dts.consumeTypes || (null == (_mfConfig_dts2 = mfConfig.dts) ? void 0 : _mfConfig_dts2.consumeTypes) === void 0) mfConfig.dts.consumeTypes = {
|
|
108
|
-
runtimePkgs: [
|
|
109
|
-
ModernJSRuntime
|
|
110
|
-
]
|
|
106
|
+
const injectRuntimePlugins = (runtimePlugin, runtimePlugins)=>{
|
|
107
|
+
const pluginName = 'string' == typeof runtimePlugin ? runtimePlugin : runtimePlugin[0];
|
|
108
|
+
const hasPlugin = runtimePlugins.some((existingPlugin)=>{
|
|
109
|
+
if ('string' == typeof existingPlugin) return existingPlugin === pluginName;
|
|
110
|
+
return existingPlugin[0] === pluginName;
|
|
111
|
+
});
|
|
112
|
+
if (!hasPlugin) runtimePlugins.push(runtimePlugin);
|
|
113
|
+
};
|
|
114
|
+
const patchDTSConfig = (mfConfig, isServer)=>{
|
|
115
|
+
if (isServer) return;
|
|
116
|
+
const ModernJSRuntime = '@module-federation/modern-js/runtime';
|
|
117
|
+
if (false !== mfConfig.dts) {
|
|
118
|
+
var _mfConfig_dts, _mfConfig_dts1;
|
|
119
|
+
if ('boolean' == typeof mfConfig.dts || void 0 === mfConfig.dts) mfConfig.dts = {
|
|
120
|
+
consumeTypes: {
|
|
121
|
+
runtimePkgs: [
|
|
122
|
+
ModernJSRuntime
|
|
123
|
+
]
|
|
124
|
+
}
|
|
111
125
|
};
|
|
112
|
-
else {
|
|
113
|
-
|
|
114
|
-
if (
|
|
126
|
+
else if ((null == (_mfConfig_dts = mfConfig.dts) ? void 0 : _mfConfig_dts.consumeTypes) || (null == (_mfConfig_dts1 = mfConfig.dts) ? void 0 : _mfConfig_dts1.consumeTypes) === void 0) {
|
|
127
|
+
var _mfConfig_dts2;
|
|
128
|
+
if ('boolean' == typeof mfConfig.dts.consumeTypes || (null == (_mfConfig_dts2 = mfConfig.dts) ? void 0 : _mfConfig_dts2.consumeTypes) === void 0) mfConfig.dts.consumeTypes = {
|
|
129
|
+
runtimePkgs: [
|
|
130
|
+
ModernJSRuntime
|
|
131
|
+
]
|
|
132
|
+
};
|
|
133
|
+
else {
|
|
134
|
+
mfConfig.dts.consumeTypes.runtimePkgs = mfConfig.dts.consumeTypes.runtimePkgs || [];
|
|
135
|
+
if (!mfConfig.dts.consumeTypes.runtimePkgs.includes(ModernJSRuntime)) mfConfig.dts.consumeTypes.runtimePkgs.push(ModernJSRuntime);
|
|
136
|
+
}
|
|
115
137
|
}
|
|
116
138
|
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
139
|
+
};
|
|
140
|
+
const patchMFConfig = (mfConfig, isServer)=>{
|
|
141
|
+
(0, utils_namespaceObject.addDataFetchExposes)(mfConfig.exposes, isServer);
|
|
142
|
+
if (void 0 === mfConfig.remoteType) mfConfig.remoteType = "script";
|
|
143
|
+
if (!mfConfig.name) throw new Error(`${external_constant_js_namespaceObject.PLUGIN_IDENTIFIER} mfConfig.name can not be empty!`);
|
|
144
|
+
const runtimePlugins = [
|
|
145
|
+
...mfConfig.runtimePlugins || []
|
|
146
|
+
];
|
|
147
|
+
patchDTSConfig(mfConfig, isServer);
|
|
148
|
+
injectRuntimePlugins(resolveSharedStrategyPlugin(), runtimePlugins);
|
|
149
|
+
if (isServer) {
|
|
150
|
+
injectRuntimePlugins(resolveNodeRuntimePlugin(), runtimePlugins);
|
|
151
|
+
if ((0, external_utils_js_namespaceObject.isDev)()) injectRuntimePlugins(resolveNodeRecordRemoteHashPlugin(), runtimePlugins);
|
|
152
|
+
injectRuntimePlugins(resolveInjectNodeFetchPlugin(), runtimePlugins);
|
|
153
|
+
if (mfConfig.library) {
|
|
154
|
+
if (!mfConfig.library.type) mfConfig.library.type = 'commonjs-module';
|
|
155
|
+
if (!mfConfig.library.name) mfConfig.library.name = mfConfig.name;
|
|
156
|
+
} else mfConfig.library = {
|
|
157
|
+
type: 'commonjs-module',
|
|
158
|
+
name: mfConfig.name
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
mfConfig.runtimePlugins = runtimePlugins;
|
|
162
|
+
if (!isServer) {
|
|
163
|
+
var _mfConfig_library;
|
|
164
|
+
if ((null == (_mfConfig_library = mfConfig.library) ? void 0 : _mfConfig_library.type) === 'commonjs-module') mfConfig.library.type = 'global';
|
|
165
|
+
return mfConfig;
|
|
166
|
+
}
|
|
167
|
+
mfConfig.dts = false;
|
|
168
|
+
mfConfig.dev = false;
|
|
146
169
|
return mfConfig;
|
|
170
|
+
};
|
|
171
|
+
const setDefaultOptimizationTarget = (mfConfig, enableSSR, isServer, autoOptimization = true)=>{
|
|
172
|
+
var _mfConfig, _mfConfig_experiments, _mfConfig_experiments_optimization;
|
|
173
|
+
if (!autoOptimization) return;
|
|
174
|
+
(_mfConfig = mfConfig).experiments || (_mfConfig.experiments = {});
|
|
175
|
+
(_mfConfig_experiments = mfConfig.experiments).optimization || (_mfConfig_experiments.optimization = {});
|
|
176
|
+
null != (_mfConfig_experiments_optimization = mfConfig.experiments.optimization).target || (_mfConfig_experiments_optimization.target = enableSSR && isServer ? 'node' : 'web');
|
|
177
|
+
};
|
|
178
|
+
function patchIgnoreWarning(chain) {
|
|
179
|
+
const ignoreWarnings = chain.get('ignoreWarnings') || [];
|
|
180
|
+
const ignoredMsgs = [
|
|
181
|
+
"external script",
|
|
182
|
+
'process.env.WS_NO_BUFFER_UTIL',
|
|
183
|
+
"Can't resolve 'utf-8-validate"
|
|
184
|
+
];
|
|
185
|
+
ignoreWarnings.push((warning)=>{
|
|
186
|
+
if (ignoredMsgs.some((msg)=>warning.message.includes(msg))) return true;
|
|
187
|
+
return false;
|
|
188
|
+
});
|
|
189
|
+
chain.ignoreWarnings(ignoreWarnings);
|
|
147
190
|
}
|
|
148
|
-
mfConfig
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
if (!watchOptions || !watchOptions.ignored) return void chain.watchOptions({
|
|
168
|
-
ignored: /[\\/](?:\.git|node_modules|@mf-types)[\\/]/
|
|
169
|
-
});
|
|
170
|
-
const ignored = watchOptions.ignored;
|
|
171
|
-
const DEFAULT_IGNORED_GLOB = '**/@mf-types/**';
|
|
172
|
-
if (Array.isArray(ignored)) {
|
|
173
|
-
if (false !== mfConfig.dts && 'object' == typeof mfConfig.dts && 'object' == typeof mfConfig.dts.consumeTypes && mfConfig.dts.consumeTypes.remoteTypesFolder) chain.watchOptions({
|
|
191
|
+
function addMyTypes2Ignored(chain, mfConfig) {
|
|
192
|
+
const watchOptions = chain.get('watchOptions');
|
|
193
|
+
if (!watchOptions || !watchOptions.ignored) return void chain.watchOptions({
|
|
194
|
+
ignored: /[\\/](?:\.git|node_modules|@mf-types)[\\/]/
|
|
195
|
+
});
|
|
196
|
+
const ignored = watchOptions.ignored;
|
|
197
|
+
const DEFAULT_IGNORED_GLOB = '**/@mf-types/**';
|
|
198
|
+
if (Array.isArray(ignored)) {
|
|
199
|
+
if (false !== mfConfig.dts && 'object' == typeof mfConfig.dts && 'object' == typeof mfConfig.dts.consumeTypes && mfConfig.dts.consumeTypes.remoteTypesFolder) chain.watchOptions({
|
|
200
|
+
...watchOptions,
|
|
201
|
+
ignored: ignored.concat(`**/${mfConfig.dts.consumeTypes.remoteTypesFolder}/**`)
|
|
202
|
+
});
|
|
203
|
+
else chain.watchOptions({
|
|
204
|
+
...watchOptions,
|
|
205
|
+
ignored: ignored.concat(DEFAULT_IGNORED_GLOB)
|
|
206
|
+
});
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
if ('string' != typeof ignored) return void chain.watchOptions({
|
|
174
210
|
...watchOptions,
|
|
175
|
-
ignored:
|
|
211
|
+
ignored: /[\\/](?:\.git|node_modules|@mf-types)[\\/]/
|
|
176
212
|
});
|
|
177
|
-
|
|
213
|
+
chain.watchOptions({
|
|
178
214
|
...watchOptions,
|
|
179
215
|
ignored: ignored.concat(DEFAULT_IGNORED_GLOB)
|
|
180
216
|
});
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
if ('string' != typeof ignored) return void chain.watchOptions({
|
|
184
|
-
...watchOptions,
|
|
185
|
-
ignored: /[\\/](?:\.git|node_modules|@mf-types)[\\/]/
|
|
186
|
-
});
|
|
187
|
-
chain.watchOptions({
|
|
188
|
-
...watchOptions,
|
|
189
|
-
ignored: ignored.concat(DEFAULT_IGNORED_GLOB)
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
function patchBundlerConfig(options) {
|
|
193
|
-
var _modernjsConfig_deploy;
|
|
194
|
-
const { chain, modernjsConfig, isServer, mfConfig, enableSSR } = options;
|
|
195
|
-
chain.optimization.delete('runtimeChunk');
|
|
196
|
-
patchIgnoreWarning(chain);
|
|
197
|
-
if (!chain.output.get('chunkLoadingGlobal')) chain.output.chunkLoadingGlobal(`chunk_${mfConfig.name}`);
|
|
198
|
-
if (!chain.output.get('uniqueName')) chain.output.uniqueName(mfConfig.name);
|
|
199
|
-
const splitChunkConfig = chain.optimization.splitChunks.entries();
|
|
200
|
-
if (!isServer) (0, utils_namespaceObject.autoDeleteSplitChunkCacheGroups)(mfConfig, splitChunkConfig);
|
|
201
|
-
if (!isServer && enableSSR && splitChunkConfig && 'object' == typeof splitChunkConfig && splitChunkConfig.cacheGroups) {
|
|
202
|
-
splitChunkConfig.chunks = 'async';
|
|
203
|
-
external_logger_js_default().warn('splitChunks.chunks = async is not allowed with stream SSR mode, it will auto changed to "async"');
|
|
204
217
|
}
|
|
205
|
-
|
|
206
|
-
var
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
chain
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
if ('
|
|
215
|
-
const
|
|
216
|
-
|
|
218
|
+
function patchBundlerConfig(options) {
|
|
219
|
+
var _modernjsConfig_deploy;
|
|
220
|
+
const { chain, modernjsConfig, isServer, mfConfig, enableSSR } = options;
|
|
221
|
+
chain.optimization.delete('runtimeChunk');
|
|
222
|
+
patchIgnoreWarning(chain);
|
|
223
|
+
if (!chain.output.get('chunkLoadingGlobal')) chain.output.chunkLoadingGlobal(`chunk_${mfConfig.name}`);
|
|
224
|
+
if (!chain.output.get('uniqueName')) chain.output.uniqueName(mfConfig.name);
|
|
225
|
+
const splitChunkConfig = chain.optimization.splitChunks.entries();
|
|
226
|
+
if (!isServer) (0, utils_namespaceObject.autoDeleteSplitChunkCacheGroups)(mfConfig, splitChunkConfig);
|
|
227
|
+
if (!isServer && enableSSR && splitChunkConfig && 'object' == typeof splitChunkConfig && splitChunkConfig.cacheGroups) {
|
|
228
|
+
const previousChunks = splitChunkConfig.chunks;
|
|
229
|
+
splitChunkConfig.chunks = 'async';
|
|
230
|
+
if (previousChunks && 'async' !== previousChunks) external_logger_js_default().warn(`splitChunks.chunks = "${previousChunks}" is not allowed with stream SSR mode; forcing "async"`);
|
|
231
|
+
}
|
|
232
|
+
if ((0, external_utils_js_namespaceObject.isDev)() && 'auto' === chain.output.get('publicPath')) {
|
|
233
|
+
var _modernjsConfig_dev, _modernjsConfig_server;
|
|
234
|
+
const port = (null == (_modernjsConfig_dev = modernjsConfig.dev) ? void 0 : _modernjsConfig_dev.port) || (null == (_modernjsConfig_server = modernjsConfig.server) ? void 0 : _modernjsConfig_server.port) || 8080;
|
|
235
|
+
const publicPath = `http://localhost:${port}/`;
|
|
236
|
+
chain.output.publicPath(publicPath);
|
|
237
|
+
}
|
|
238
|
+
if (isServer && enableSSR) {
|
|
239
|
+
const uniqueName = mfConfig.name || chain.output.get('uniqueName');
|
|
240
|
+
const chunkFileName = chain.output.get('chunkFilename');
|
|
241
|
+
if ('string' == typeof chunkFileName && uniqueName && !chunkFileName.includes(uniqueName)) {
|
|
242
|
+
const suffix = `${(0, sdk_namespaceObject.encodeName)(uniqueName)}-[contenthash].js`;
|
|
243
|
+
chain.output.chunkFilename(chunkFileName.replace('.js', suffix));
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
if ((0, external_utils_js_namespaceObject.isDev)() && enableSSR && !isServer) chain.resolve.fallback.set('crypto', false).set('stream', false).set('vm', false);
|
|
247
|
+
if ((null == (_modernjsConfig_deploy = modernjsConfig.deploy) ? void 0 : _modernjsConfig_deploy.microFrontend) && Object.keys(mfConfig.exposes || {}).length) {
|
|
248
|
+
external_logger_js_default().info('optimization.usedExports is set to "global" to avoid tree shaking issues in micro frontend mode.');
|
|
249
|
+
chain.optimization.usedExports('global');
|
|
217
250
|
}
|
|
218
251
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
'@modern-js/plugin-module-federation'
|
|
229
|
-
],
|
|
230
|
-
setup: async (api)=>{
|
|
231
|
-
var _userConfig_userConfig, _modernjsConfig_server;
|
|
232
|
-
const modernjsConfig = api.getConfig();
|
|
233
|
-
const mfConfig = await getMFConfig(userConfig.originPluginOptions);
|
|
234
|
-
const csrConfig = userConfig.csrConfig || JSON.parse(JSON.stringify(mfConfig));
|
|
235
|
-
const ssrConfig = userConfig.ssrConfig || JSON.parse(JSON.stringify(mfConfig));
|
|
236
|
-
userConfig.ssrConfig = ssrConfig;
|
|
237
|
-
userConfig.csrConfig = csrConfig;
|
|
238
|
-
var _ref;
|
|
239
|
-
const enableSSR = Boolean(null != (_ref = null == (_userConfig_userConfig = userConfig.userConfig) ? void 0 : _userConfig_userConfig.ssr) ? _ref : Boolean(null == modernjsConfig ? void 0 : null == (_modernjsConfig_server = modernjsConfig.server) ? void 0 : _modernjsConfig_server.ssr));
|
|
240
|
-
api.modifyBundlerChain((chain)=>{
|
|
241
|
-
const target = chain.get('target');
|
|
242
|
-
if ((0, external_utils_js_namespaceObject.skipByTarget)(target)) return;
|
|
243
|
-
const isWeb = (0, external_utils_js_namespaceObject.isWebTarget)(target);
|
|
244
|
-
addMyTypes2Ignored(chain, isWeb ? csrConfig : ssrConfig);
|
|
245
|
-
const targetMFConfig = isWeb ? csrConfig : ssrConfig;
|
|
246
|
-
patchMFConfig(targetMFConfig, !isWeb, userConfig.remoteIpStrategy || 'ipv4', enableSSR);
|
|
247
|
-
patchBundlerConfig({
|
|
248
|
-
chain,
|
|
249
|
-
isServer: !isWeb,
|
|
250
|
-
modernjsConfig,
|
|
251
|
-
mfConfig,
|
|
252
|
-
enableSSR
|
|
253
|
-
});
|
|
254
|
-
if (isWeb) userConfig.distOutputDir = chain.output.get('path') || external_path_default().resolve(process.cwd(), 'dist');
|
|
255
|
-
else if (enableSSR) {
|
|
256
|
-
var _userConfig, _userConfig_userConfig;
|
|
257
|
-
(_userConfig = userConfig).userConfig || (_userConfig.userConfig = {});
|
|
258
|
-
(_userConfig_userConfig = userConfig.userConfig).ssr || (_userConfig_userConfig.ssr = {});
|
|
259
|
-
if (true === userConfig.userConfig.ssr) userConfig.userConfig.ssr = {};
|
|
260
|
-
userConfig.userConfig.ssr.distOutputDir = chain.output.get('path') || external_path_default().resolve(process.cwd(), 'dist/bundles');
|
|
261
|
-
}
|
|
262
|
-
});
|
|
263
|
-
api.config(()=>{
|
|
264
|
-
var _modernjsConfig_tools, _userConfig_csrConfig, _modernjsConfig_source, _modernjsConfig_source1, _modernjsConfig_dev;
|
|
265
|
-
const bundlerType = 'rspack' === api.getAppContext().bundlerType ? 'rspack' : 'webpack';
|
|
266
|
-
const ipv4 = (0, external_utils_js_namespaceObject.getIPV4)();
|
|
267
|
-
if (void 0 === userConfig.remoteIpStrategy) if (enableSSR) userConfig.remoteIpStrategy = 'ipv4';
|
|
268
|
-
else userConfig.remoteIpStrategy = 'inherit';
|
|
269
|
-
const devServerConfig = null == (_modernjsConfig_tools = modernjsConfig.tools) ? void 0 : _modernjsConfig_tools.devServer;
|
|
270
|
-
const corsWarnMsgs = [
|
|
271
|
-
'View https://module-federation.io/guide/troubleshooting/other.html#cors-warn for more details.'
|
|
272
|
-
];
|
|
273
|
-
if ('object' != typeof devServerConfig || !('headers' in devServerConfig)) corsWarnMsgs.unshift('Detect devServer.headers is empty, mf modern plugin will add default cors header: devServer.headers["Access-Control-Allow-Headers"] = "*". It is recommended to specify an allowlist of trusted origins instead.');
|
|
274
|
-
const exposes = null == (_userConfig_csrConfig = userConfig.csrConfig) ? void 0 : _userConfig_csrConfig.exposes;
|
|
275
|
-
const hasExposes = exposes && Array.isArray(exposes) ? exposes.length : Object.keys(null != exposes ? exposes : {}).length;
|
|
276
|
-
if (corsWarnMsgs.length > 1 && hasExposes) external_logger_js_default().warn(corsWarnMsgs.join('\n'));
|
|
277
|
-
const corsHeaders = hasExposes ? {
|
|
278
|
-
'Access-Control-Allow-Origin': '*',
|
|
279
|
-
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',
|
|
280
|
-
'Access-Control-Allow-Headers': '*'
|
|
281
|
-
} : void 0;
|
|
282
|
-
const defineConfig = {
|
|
283
|
-
REMOTE_IP_STRATEGY: JSON.stringify(userConfig.remoteIpStrategy)
|
|
284
|
-
};
|
|
285
|
-
if (enableSSR && (0, external_utils_js_namespaceObject.isDev)()) defineConfig['FEDERATION_IPV4'] = JSON.stringify(ipv4);
|
|
252
|
+
const moduleFederationConfigPlugin = (userConfig)=>({
|
|
253
|
+
name: '@modern-js/plugin-module-federation-config',
|
|
254
|
+
pre: [
|
|
255
|
+
'@modern-js/plugin-initialize'
|
|
256
|
+
],
|
|
257
|
+
post: [
|
|
258
|
+
'@modern-js/plugin-module-federation'
|
|
259
|
+
],
|
|
260
|
+
setup: async (api)=>{
|
|
286
261
|
var _ref;
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
262
|
+
var _userConfig_userConfig, _modernjsConfig_server;
|
|
263
|
+
const modernjsConfig = api.getConfig();
|
|
264
|
+
const mfConfig = await getMFConfig(userConfig.originPluginOptions);
|
|
265
|
+
const csrConfig = userConfig.csrConfig || JSON.parse(JSON.stringify(mfConfig));
|
|
266
|
+
const ssrConfig = userConfig.ssrConfig || JSON.parse(JSON.stringify(mfConfig));
|
|
267
|
+
userConfig.ssrConfig = ssrConfig;
|
|
268
|
+
userConfig.csrConfig = csrConfig;
|
|
269
|
+
const enableSSR = Boolean(null != (_ref = null == (_userConfig_userConfig = userConfig.userConfig) ? void 0 : _userConfig_userConfig.ssr) ? _ref : Boolean(null == modernjsConfig ? void 0 : null == (_modernjsConfig_server = modernjsConfig.server) ? void 0 : _modernjsConfig_server.ssr));
|
|
270
|
+
api.modifyBundlerChain((chain)=>{
|
|
271
|
+
var _modernjsConfig_source, _targetMFConfig_experiments;
|
|
272
|
+
const bundlerType = 'rspack' === api.getAppContext().bundlerType ? 'rspack' : 'webpack';
|
|
273
|
+
const target = chain.get('target');
|
|
274
|
+
if ((0, external_utils_js_namespaceObject.skipByTarget)(target)) return;
|
|
275
|
+
const isWeb = (0, external_utils_js_namespaceObject.isWebTarget)(target);
|
|
276
|
+
addMyTypes2Ignored(chain, isWeb ? csrConfig : ssrConfig);
|
|
277
|
+
const targetMFConfig = isWeb ? csrConfig : ssrConfig;
|
|
278
|
+
setDefaultOptimizationTarget(targetMFConfig, enableSSR, !isWeb, userConfig.originPluginOptions.autoOptimization);
|
|
279
|
+
patchMFConfig(targetMFConfig, !isWeb);
|
|
280
|
+
if ('rspack' === bundlerType && (null == (_modernjsConfig_source = modernjsConfig.source) ? void 0 : _modernjsConfig_source.enableAsyncEntry) !== true && (null == (_targetMFConfig_experiments = targetMFConfig.experiments) ? void 0 : _targetMFConfig_experiments.asyncStartup) !== false) {
|
|
281
|
+
var _targetMFConfig;
|
|
282
|
+
(_targetMFConfig = targetMFConfig).experiments || (_targetMFConfig.experiments = {});
|
|
283
|
+
targetMFConfig.experiments.asyncStartup = true;
|
|
304
284
|
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
285
|
+
patchBundlerConfig({
|
|
286
|
+
chain,
|
|
287
|
+
isServer: !isWeb,
|
|
288
|
+
modernjsConfig,
|
|
289
|
+
mfConfig,
|
|
290
|
+
enableSSR
|
|
291
|
+
});
|
|
292
|
+
if (isWeb) userConfig.distOutputDir = chain.output.get('path') || external_path_default().resolve(process.cwd(), 'dist');
|
|
293
|
+
else if (enableSSR) {
|
|
294
|
+
var _userConfig, _userConfig_userConfig;
|
|
295
|
+
(_userConfig = userConfig).userConfig || (_userConfig.userConfig = {});
|
|
296
|
+
(_userConfig_userConfig = userConfig.userConfig).ssr || (_userConfig_userConfig.ssr = {});
|
|
297
|
+
if (true === userConfig.userConfig.ssr) userConfig.userConfig.ssr = {};
|
|
298
|
+
userConfig.userConfig.ssr.distOutputDir = chain.output.get('path') || external_path_default().resolve(process.cwd(), 'dist/bundles');
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
api.config(()=>{
|
|
302
|
+
var _ref;
|
|
303
|
+
var _modernjsConfig_tools, _userConfig_csrConfig, _modernjsConfig_source, _modernjsConfig_source1, _modernjsConfig_dev;
|
|
304
|
+
const bundlerType = 'rspack' === api.getAppContext().bundlerType ? 'rspack' : 'webpack';
|
|
305
|
+
const devServerConfig = null == (_modernjsConfig_tools = modernjsConfig.tools) ? void 0 : _modernjsConfig_tools.devServer;
|
|
306
|
+
const corsWarnMsgs = [
|
|
307
|
+
'View https://module-federation.io/guide/troubleshooting/other.html#cors-warn for more details.'
|
|
308
|
+
];
|
|
309
|
+
if ('object' != typeof devServerConfig || !('headers' in devServerConfig)) corsWarnMsgs.unshift('Detect devServer.headers is empty, mf modern plugin will add default cors header: devServer.headers["Access-Control-Allow-Headers"] = "*". It is recommended to specify an allowlist of trusted origins instead.');
|
|
310
|
+
const exposes = null == (_userConfig_csrConfig = userConfig.csrConfig) ? void 0 : _userConfig_csrConfig.exposes;
|
|
311
|
+
const hasExposes = exposes && Array.isArray(exposes) ? exposes.length : Object.keys(null != exposes ? exposes : {}).length;
|
|
312
|
+
if (corsWarnMsgs.length > 1 && hasExposes) external_logger_js_default().warn(corsWarnMsgs.join('\n'));
|
|
313
|
+
const corsHeaders = hasExposes ? {
|
|
314
|
+
'Access-Control-Allow-Origin': '*',
|
|
315
|
+
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',
|
|
316
|
+
'Access-Control-Allow-Headers': '*'
|
|
317
|
+
} : void 0;
|
|
318
|
+
return {
|
|
319
|
+
tools: {
|
|
320
|
+
devServer: {
|
|
321
|
+
headers: corsHeaders
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
resolve: {
|
|
325
|
+
alias: {
|
|
326
|
+
'@modern-js/runtime/mf': require.resolve('@module-federation/modern-js/runtime')
|
|
327
|
+
}
|
|
328
|
+
},
|
|
329
|
+
source: {
|
|
330
|
+
enableAsyncEntry: 'rspack' === bundlerType ? null != (_ref = null == (_modernjsConfig_source = modernjsConfig.source) ? void 0 : _modernjsConfig_source.enableAsyncEntry) ? _ref : true : null == (_modernjsConfig_source1 = modernjsConfig.source) ? void 0 : _modernjsConfig_source1.enableAsyncEntry
|
|
331
|
+
},
|
|
332
|
+
dev: {
|
|
333
|
+
assetPrefix: (null == modernjsConfig ? void 0 : null == (_modernjsConfig_dev = modernjsConfig.dev) ? void 0 : _modernjsConfig_dev.assetPrefix) ? modernjsConfig.dev.assetPrefix : true
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
const configPlugin = moduleFederationConfigPlugin;
|
|
340
|
+
})();
|
|
310
341
|
exports.addMyTypes2Ignored = __webpack_exports__.addMyTypes2Ignored;
|
|
311
342
|
exports["default"] = __webpack_exports__["default"];
|
|
312
343
|
exports.getMFConfig = __webpack_exports__.getMFConfig;
|
|
@@ -314,6 +345,7 @@ exports.isWebTarget = __webpack_exports__.isWebTarget;
|
|
|
314
345
|
exports.moduleFederationConfigPlugin = __webpack_exports__.moduleFederationConfigPlugin;
|
|
315
346
|
exports.patchBundlerConfig = __webpack_exports__.patchBundlerConfig;
|
|
316
347
|
exports.patchMFConfig = __webpack_exports__.patchMFConfig;
|
|
348
|
+
exports.setDefaultOptimizationTarget = __webpack_exports__.setDefaultOptimizationTarget;
|
|
317
349
|
exports.setEnv = __webpack_exports__.setEnv;
|
|
318
350
|
exports.skipByTarget = __webpack_exports__.skipByTarget;
|
|
319
351
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
@@ -324,6 +356,7 @@ for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
|
324
356
|
"moduleFederationConfigPlugin",
|
|
325
357
|
"patchBundlerConfig",
|
|
326
358
|
"patchMFConfig",
|
|
359
|
+
"setDefaultOptimizationTarget",
|
|
327
360
|
"setEnv",
|
|
328
361
|
"skipByTarget"
|
|
329
362
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|