@module-federation/modern-js-v3 0.0.0-docs-ssg-mg-fix-20260212083348
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/LICENSE +21 -0
- package/README.md +5 -0
- package/dist/LICENSE +21 -0
- package/dist/cjs/cli/configPlugin.js +351 -0
- package/dist/cjs/cli/index.js +99 -0
- package/dist/cjs/cli/mfRuntimePlugins/inject-node-fetch.js +54 -0
- package/dist/cjs/cli/mfRuntimePlugins/resolve-entry-ipv4.js +80 -0
- package/dist/cjs/cli/mfRuntimePlugins/shared-strategy.js +53 -0
- package/dist/cjs/cli/server/data-fetch-server-plugin.js +59 -0
- package/dist/cjs/cli/ssrPlugin.js +286 -0
- package/dist/cjs/cli/utils.js +93 -0
- package/dist/cjs/constant.js +40 -0
- package/dist/cjs/interfaces/bundler.js +18 -0
- package/dist/cjs/logger.js +39 -0
- package/dist/cjs/react/index.js +58 -0
- package/dist/cjs/react/plugin.js +65 -0
- package/dist/cjs/react/v18.js +58 -0
- package/dist/cjs/react/v19.js +58 -0
- package/dist/cjs/runtime/index.js +58 -0
- package/dist/cjs/server/fileCache.js +84 -0
- package/dist/cjs/server/index.js +71 -0
- package/dist/cjs/server/staticMiddleware.js +90 -0
- package/dist/cjs/ssr-runtime/SSRLiveReload.js +50 -0
- package/dist/cjs/ssr-runtime/devPlugin.js +67 -0
- package/dist/cjs/ssr-runtime/injectDataFetchFunctionPlugin.js +48 -0
- package/dist/cjs/types/index.js +18 -0
- package/dist/esm/cli/configPlugin.mjs +319 -0
- package/dist/esm/cli/index.mjs +69 -0
- package/dist/esm/cli/mfRuntimePlugins/inject-node-fetch.mjs +12 -0
- package/dist/esm/cli/mfRuntimePlugins/resolve-entry-ipv4.mjs +58 -0
- package/dist/esm/cli/mfRuntimePlugins/shared-strategy.mjs +21 -0
- package/dist/esm/cli/server/data-fetch-server-plugin.mjs +17 -0
- package/dist/esm/cli/ssrPlugin.mjs +258 -0
- package/dist/esm/cli/utils.mjs +40 -0
- package/dist/esm/constant.mjs +3 -0
- package/dist/esm/interfaces/bundler.mjs +0 -0
- package/dist/esm/logger.mjs +5 -0
- package/dist/esm/react/index.mjs +1 -0
- package/dist/esm/react/plugin.mjs +3 -0
- package/dist/esm/react/v18.mjs +1 -0
- package/dist/esm/react/v19.mjs +1 -0
- package/dist/esm/runtime/index.mjs +1 -0
- package/dist/esm/server/fileCache.mjs +90 -0
- package/dist/esm/server/index.mjs +36 -0
- package/dist/esm/server/staticMiddleware.mjs +87 -0
- package/dist/esm/ssr-runtime/SSRLiveReload.mjs +23 -0
- package/dist/esm/ssr-runtime/devPlugin.mjs +70 -0
- package/dist/esm/ssr-runtime/injectDataFetchFunctionPlugin.mjs +34 -0
- package/dist/esm/types/index.mjs +0 -0
- package/dist/esm-node/cli/configPlugin.mjs +282 -0
- package/dist/esm-node/cli/index.mjs +59 -0
- package/dist/esm-node/cli/mfRuntimePlugins/inject-node-fetch.mjs +10 -0
- package/dist/esm-node/cli/mfRuntimePlugins/resolve-entry-ipv4.mjs +46 -0
- package/dist/esm-node/cli/mfRuntimePlugins/shared-strategy.mjs +19 -0
- package/dist/esm-node/cli/server/data-fetch-server-plugin.mjs +15 -0
- package/dist/esm-node/cli/ssrPlugin.mjs +230 -0
- package/dist/esm-node/cli/utils.mjs +40 -0
- package/dist/esm-node/constant.mjs +3 -0
- package/dist/esm-node/interfaces/bundler.mjs +0 -0
- package/dist/esm-node/logger.mjs +5 -0
- package/dist/esm-node/react/index.mjs +1 -0
- package/dist/esm-node/react/plugin.mjs +3 -0
- package/dist/esm-node/react/v18.mjs +1 -0
- package/dist/esm-node/react/v19.mjs +1 -0
- package/dist/esm-node/runtime/index.mjs +1 -0
- package/dist/esm-node/server/fileCache.mjs +37 -0
- package/dist/esm-node/server/index.mjs +34 -0
- package/dist/esm-node/server/staticMiddleware.mjs +42 -0
- package/dist/esm-node/ssr-runtime/SSRLiveReload.mjs +16 -0
- package/dist/esm-node/ssr-runtime/devPlugin.mjs +33 -0
- package/dist/esm-node/ssr-runtime/injectDataFetchFunctionPlugin.mjs +14 -0
- package/dist/esm-node/types/index.mjs +0 -0
- package/dist/types/cli/configPlugin.d.ts +21 -0
- package/dist/types/cli/configPlugin.spec.d.ts +1 -0
- package/dist/types/cli/index.d.ts +6 -0
- package/dist/types/cli/mfRuntimePlugins/inject-node-fetch.d.ts +3 -0
- package/dist/types/cli/mfRuntimePlugins/resolve-entry-ipv4.d.ts +3 -0
- package/dist/types/cli/mfRuntimePlugins/shared-strategy.d.ts +3 -0
- package/dist/types/cli/server/data-fetch-server-plugin.d.ts +3 -0
- package/dist/types/cli/ssrPlugin.d.ts +6 -0
- package/dist/types/cli/utils.d.ts +6 -0
- package/dist/types/constant.d.ts +2 -0
- package/dist/types/interfaces/bundler.d.ts +14 -0
- package/dist/types/logger.d.ts +2 -0
- package/dist/types/react/index.d.ts +1 -0
- package/dist/types/react/plugin.d.ts +2 -0
- package/dist/types/react/v18.d.ts +1 -0
- package/dist/types/react/v19.d.ts +1 -0
- package/dist/types/runtime/index.d.ts +1 -0
- package/dist/types/server/fileCache.d.ts +14 -0
- package/dist/types/server/fileCache.spec.d.ts +1 -0
- package/dist/types/server/index.d.ts +4 -0
- package/dist/types/server/staticMiddleware.d.ts +7 -0
- package/dist/types/server/staticMiddleware.spec.d.ts +1 -0
- package/dist/types/ssr-runtime/SSRLiveReload.d.ts +2 -0
- package/dist/types/ssr-runtime/devPlugin.d.ts +2 -0
- package/dist/types/ssr-runtime/injectDataFetchFunctionPlugin.d.ts +4 -0
- package/dist/types/types/index.d.ts +37 -0
- package/package.json +188 -0
- package/types.d.ts +6 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-present zhanghang(2heal1)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
package/dist/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-present zhanghang(2heal1)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
"use strict";
|
|
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
|
+
}
|
|
17
|
+
(()=>{
|
|
18
|
+
__webpack_require__.n = (module)=>{
|
|
19
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
20
|
+
__webpack_require__.d(getter, {
|
|
21
|
+
a: getter
|
|
22
|
+
});
|
|
23
|
+
return getter;
|
|
24
|
+
};
|
|
25
|
+
})();
|
|
26
|
+
(()=>{
|
|
27
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
28
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
get: definition[key]
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
})();
|
|
34
|
+
(()=>{
|
|
35
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
36
|
+
})();
|
|
37
|
+
(()=>{
|
|
38
|
+
__webpack_require__.r = (exports1)=>{
|
|
39
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
40
|
+
value: 'Module'
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
43
|
+
value: true
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
})();
|
|
47
|
+
var __webpack_exports__ = {};
|
|
48
|
+
(()=>{
|
|
49
|
+
__webpack_require__.r(__webpack_exports__);
|
|
50
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
51
|
+
patchMFConfig: ()=>patchMFConfig,
|
|
52
|
+
default: ()=>configPlugin,
|
|
53
|
+
getMFConfig: ()=>getMFConfig,
|
|
54
|
+
isWebTarget: ()=>external_utils_js_namespaceObject.isWebTarget,
|
|
55
|
+
moduleFederationConfigPlugin: ()=>moduleFederationConfigPlugin,
|
|
56
|
+
addMyTypes2Ignored: ()=>addMyTypes2Ignored,
|
|
57
|
+
skipByTarget: ()=>external_utils_js_namespaceObject.skipByTarget,
|
|
58
|
+
setEnv: ()=>setEnv,
|
|
59
|
+
patchBundlerConfig: ()=>patchBundlerConfig
|
|
60
|
+
});
|
|
61
|
+
const external_path_namespaceObject = require("path");
|
|
62
|
+
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
|
|
63
|
+
const external_utils_js_namespaceObject = require("./utils.js");
|
|
64
|
+
const sdk_namespaceObject = require("@module-federation/sdk");
|
|
65
|
+
const external_constant_js_namespaceObject = require("../constant.js");
|
|
66
|
+
const utils_namespaceObject = require("@module-federation/rsbuild-plugin/utils");
|
|
67
|
+
const external_logger_js_namespaceObject = require("../logger.js");
|
|
68
|
+
var external_logger_js_default = /*#__PURE__*/ __webpack_require__.n(external_logger_js_namespaceObject);
|
|
69
|
+
const defaultPath = external_path_default().resolve(process.cwd(), 'module-federation.config.ts');
|
|
70
|
+
function setEnv(enableSSR) {
|
|
71
|
+
if (enableSSR) process.env['MF_SSR_PRJ'] = 'true';
|
|
72
|
+
}
|
|
73
|
+
const getMFConfig = async (userConfig)=>{
|
|
74
|
+
const { config, configPath } = userConfig;
|
|
75
|
+
if (config) return config;
|
|
76
|
+
const mfConfigPath = configPath ? configPath : defaultPath;
|
|
77
|
+
const { createJiti } = __webpack_require__("jiti");
|
|
78
|
+
const jit = createJiti(__filename, {
|
|
79
|
+
interopDefault: true,
|
|
80
|
+
esmResolve: true
|
|
81
|
+
});
|
|
82
|
+
const configModule = await jit(mfConfigPath);
|
|
83
|
+
const resolvedConfig = configModule && 'object' == typeof configModule && 'default' in configModule ? configModule.default : configModule;
|
|
84
|
+
return resolvedConfig;
|
|
85
|
+
};
|
|
86
|
+
const injectRuntimePlugins = (runtimePlugin, runtimePlugins)=>{
|
|
87
|
+
const pluginName = 'string' == typeof runtimePlugin ? runtimePlugin : runtimePlugin[0];
|
|
88
|
+
const hasPlugin = runtimePlugins.some((existingPlugin)=>{
|
|
89
|
+
if ('string' == typeof existingPlugin) return existingPlugin === pluginName;
|
|
90
|
+
return existingPlugin[0] === pluginName;
|
|
91
|
+
});
|
|
92
|
+
if (!hasPlugin) runtimePlugins.push(runtimePlugin);
|
|
93
|
+
};
|
|
94
|
+
const replaceRemoteUrl = (mfConfig, remoteIpStrategy)=>{
|
|
95
|
+
if (remoteIpStrategy && 'inherit' === remoteIpStrategy) return;
|
|
96
|
+
if (!mfConfig.remotes) return;
|
|
97
|
+
const ipv4 = (0, external_utils_js_namespaceObject.getIPV4)();
|
|
98
|
+
const handleRemoteObject = (remoteObject)=>{
|
|
99
|
+
Object.keys(remoteObject).forEach((remoteKey)=>{
|
|
100
|
+
const remote = remoteObject[remoteKey];
|
|
101
|
+
if (Array.isArray(remote)) return;
|
|
102
|
+
if ('string' == typeof remote && remote.includes(external_constant_js_namespaceObject.LOCALHOST)) remoteObject[remoteKey] = remote.replace(external_constant_js_namespaceObject.LOCALHOST, ipv4);
|
|
103
|
+
if ('object' == typeof remote && !Array.isArray(remote.external) && remote.external.includes(external_constant_js_namespaceObject.LOCALHOST)) remote.external = remote.external.replace(external_constant_js_namespaceObject.LOCALHOST, ipv4);
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
if (Array.isArray(mfConfig.remotes)) mfConfig.remotes.forEach((remoteObject)=>{
|
|
107
|
+
if ('string' == typeof remoteObject) return;
|
|
108
|
+
handleRemoteObject(remoteObject);
|
|
109
|
+
});
|
|
110
|
+
else if ('string' != typeof mfConfig.remotes) handleRemoteObject(mfConfig.remotes);
|
|
111
|
+
};
|
|
112
|
+
const patchDTSConfig = (mfConfig, isServer)=>{
|
|
113
|
+
if (isServer) return;
|
|
114
|
+
const ModernJSRuntime = '@module-federation/modern-js-v3/runtime';
|
|
115
|
+
if (false !== mfConfig.dts) {
|
|
116
|
+
var _mfConfig_dts, _mfConfig_dts1;
|
|
117
|
+
if ('boolean' == typeof mfConfig.dts || void 0 === mfConfig.dts) mfConfig.dts = {
|
|
118
|
+
consumeTypes: {
|
|
119
|
+
runtimePkgs: [
|
|
120
|
+
ModernJSRuntime
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
else if ((null == (_mfConfig_dts = mfConfig.dts) ? void 0 : _mfConfig_dts.consumeTypes) || (null == (_mfConfig_dts1 = mfConfig.dts) ? void 0 : _mfConfig_dts1.consumeTypes) === void 0) {
|
|
125
|
+
var _mfConfig_dts2;
|
|
126
|
+
if ('boolean' == typeof mfConfig.dts.consumeTypes || (null == (_mfConfig_dts2 = mfConfig.dts) ? void 0 : _mfConfig_dts2.consumeTypes) === void 0) mfConfig.dts.consumeTypes = {
|
|
127
|
+
runtimePkgs: [
|
|
128
|
+
ModernJSRuntime
|
|
129
|
+
]
|
|
130
|
+
};
|
|
131
|
+
else {
|
|
132
|
+
mfConfig.dts.consumeTypes.runtimePkgs = mfConfig.dts.consumeTypes.runtimePkgs || [];
|
|
133
|
+
if (!mfConfig.dts.consumeTypes.runtimePkgs.includes(ModernJSRuntime)) mfConfig.dts.consumeTypes.runtimePkgs.push(ModernJSRuntime);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
const patchMFConfig = (mfConfig, isServer, remoteIpStrategy, enableSSR)=>{
|
|
139
|
+
replaceRemoteUrl(mfConfig, remoteIpStrategy);
|
|
140
|
+
(0, utils_namespaceObject.addDataFetchExposes)(mfConfig.exposes, isServer);
|
|
141
|
+
if (void 0 === mfConfig.remoteType) mfConfig.remoteType = "script";
|
|
142
|
+
if (!mfConfig.name) throw new Error(`${external_constant_js_namespaceObject.PLUGIN_IDENTIFIER} mfConfig.name can not be empty!`);
|
|
143
|
+
const runtimePlugins = [
|
|
144
|
+
...mfConfig.runtimePlugins || []
|
|
145
|
+
];
|
|
146
|
+
patchDTSConfig(mfConfig, isServer);
|
|
147
|
+
injectRuntimePlugins(require.resolve('@module-federation/modern-js-v3/shared-strategy'), runtimePlugins);
|
|
148
|
+
if (enableSSR && (0, external_utils_js_namespaceObject.isDev)()) injectRuntimePlugins(require.resolve('@module-federation/modern-js-v3/resolve-entry-ipv4'), runtimePlugins);
|
|
149
|
+
if (isServer) {
|
|
150
|
+
injectRuntimePlugins(require.resolve('@module-federation/node/runtimePlugin'), runtimePlugins);
|
|
151
|
+
if ((0, external_utils_js_namespaceObject.isDev)()) injectRuntimePlugins(require.resolve('@module-federation/node/record-dynamic-remote-entry-hash-plugin'), runtimePlugins);
|
|
152
|
+
injectRuntimePlugins(require.resolve('@module-federation/modern-js-v3/inject-node-fetch'), 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;
|
|
169
|
+
return mfConfig;
|
|
170
|
+
};
|
|
171
|
+
function patchIgnoreWarning(chain) {
|
|
172
|
+
const ignoreWarnings = chain.get('ignoreWarnings') || [];
|
|
173
|
+
const ignoredMsgs = [
|
|
174
|
+
"external script",
|
|
175
|
+
'process.env.WS_NO_BUFFER_UTIL',
|
|
176
|
+
"Can't resolve 'utf-8-validate"
|
|
177
|
+
];
|
|
178
|
+
ignoreWarnings.push((warning)=>{
|
|
179
|
+
if (ignoredMsgs.some((msg)=>warning.message.includes(msg))) return true;
|
|
180
|
+
return false;
|
|
181
|
+
});
|
|
182
|
+
chain.ignoreWarnings(ignoreWarnings);
|
|
183
|
+
}
|
|
184
|
+
function addMyTypes2Ignored(chain, mfConfig) {
|
|
185
|
+
const watchOptions = chain.get('watchOptions');
|
|
186
|
+
if (!watchOptions || !watchOptions.ignored) return void chain.watchOptions({
|
|
187
|
+
ignored: /[\\/](?:\.git|node_modules|@mf-types)[\\/]/
|
|
188
|
+
});
|
|
189
|
+
const ignored = watchOptions.ignored;
|
|
190
|
+
const DEFAULT_IGNORED_GLOB = '**/@mf-types/**';
|
|
191
|
+
if (Array.isArray(ignored)) {
|
|
192
|
+
if (false !== mfConfig.dts && 'object' == typeof mfConfig.dts && 'object' == typeof mfConfig.dts.consumeTypes && mfConfig.dts.consumeTypes.remoteTypesFolder) chain.watchOptions({
|
|
193
|
+
...watchOptions,
|
|
194
|
+
ignored: ignored.concat(`**/${mfConfig.dts.consumeTypes.remoteTypesFolder}/**`)
|
|
195
|
+
});
|
|
196
|
+
else chain.watchOptions({
|
|
197
|
+
...watchOptions,
|
|
198
|
+
ignored: ignored.concat(DEFAULT_IGNORED_GLOB)
|
|
199
|
+
});
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
if ('string' != typeof ignored) return void chain.watchOptions({
|
|
203
|
+
...watchOptions,
|
|
204
|
+
ignored: /[\\/](?:\.git|node_modules|@mf-types)[\\/]/
|
|
205
|
+
});
|
|
206
|
+
chain.watchOptions({
|
|
207
|
+
...watchOptions,
|
|
208
|
+
ignored: ignored.concat(DEFAULT_IGNORED_GLOB)
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
function patchBundlerConfig(options) {
|
|
212
|
+
var _modernjsConfig_deploy;
|
|
213
|
+
const { chain, modernjsConfig, isServer, mfConfig, enableSSR } = options;
|
|
214
|
+
chain.optimization.delete('runtimeChunk');
|
|
215
|
+
patchIgnoreWarning(chain);
|
|
216
|
+
if (!chain.output.get('chunkLoadingGlobal')) chain.output.chunkLoadingGlobal(`chunk_${mfConfig.name}`);
|
|
217
|
+
if (!chain.output.get('uniqueName')) chain.output.uniqueName(mfConfig.name);
|
|
218
|
+
const splitChunkConfig = chain.optimization.splitChunks.entries();
|
|
219
|
+
if (!isServer) (0, utils_namespaceObject.autoDeleteSplitChunkCacheGroups)(mfConfig, splitChunkConfig);
|
|
220
|
+
if (!isServer && enableSSR && splitChunkConfig && 'object' == typeof splitChunkConfig && splitChunkConfig.cacheGroups) {
|
|
221
|
+
splitChunkConfig.chunks = 'async';
|
|
222
|
+
external_logger_js_default().warn('splitChunks.chunks = async is not allowed with stream SSR mode, it will auto changed to "async"');
|
|
223
|
+
}
|
|
224
|
+
if ((0, external_utils_js_namespaceObject.isDev)() && 'auto' === chain.output.get('publicPath')) {
|
|
225
|
+
var _modernjsConfig_server;
|
|
226
|
+
const port = (null == (_modernjsConfig_server = modernjsConfig.server) ? void 0 : _modernjsConfig_server.port) || 8080;
|
|
227
|
+
const publicPath = `http://localhost:${port}/`;
|
|
228
|
+
chain.output.publicPath(publicPath);
|
|
229
|
+
}
|
|
230
|
+
if (isServer && enableSSR) {
|
|
231
|
+
const uniqueName = mfConfig.name || chain.output.get('uniqueName');
|
|
232
|
+
const chunkFileName = chain.output.get('chunkFilename');
|
|
233
|
+
if ('string' == typeof chunkFileName && uniqueName && !chunkFileName.includes(uniqueName)) {
|
|
234
|
+
const suffix = `${(0, sdk_namespaceObject.encodeName)(uniqueName)}-[contenthash].js`;
|
|
235
|
+
chain.output.chunkFilename(chunkFileName.replace('.js', suffix));
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
if ((0, external_utils_js_namespaceObject.isDev)() && enableSSR && !isServer) chain.resolve.fallback.set('crypto', false).set('stream', false).set('vm', false);
|
|
239
|
+
if ((null == (_modernjsConfig_deploy = modernjsConfig.deploy) ? void 0 : _modernjsConfig_deploy.microFrontend) && Object.keys(mfConfig.exposes || {}).length) chain.optimization.usedExports(false);
|
|
240
|
+
}
|
|
241
|
+
const moduleFederationConfigPlugin = (userConfig)=>({
|
|
242
|
+
name: '@modern-js/plugin-module-federation-config',
|
|
243
|
+
pre: [
|
|
244
|
+
'@modern-js/plugin-initialize'
|
|
245
|
+
],
|
|
246
|
+
post: [
|
|
247
|
+
'@modern-js/plugin-module-federation'
|
|
248
|
+
],
|
|
249
|
+
setup: async (api)=>{
|
|
250
|
+
var _ref;
|
|
251
|
+
var _userConfig_userConfig, _modernjsConfig_server;
|
|
252
|
+
const modernjsConfig = api.getConfig();
|
|
253
|
+
const mfConfig = await getMFConfig(userConfig.originPluginOptions);
|
|
254
|
+
const csrConfig = userConfig.csrConfig || JSON.parse(JSON.stringify(mfConfig));
|
|
255
|
+
const ssrConfig = userConfig.ssrConfig || JSON.parse(JSON.stringify(mfConfig));
|
|
256
|
+
userConfig.ssrConfig = ssrConfig;
|
|
257
|
+
userConfig.csrConfig = csrConfig;
|
|
258
|
+
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));
|
|
259
|
+
api.modifyBundlerChain((chain)=>{
|
|
260
|
+
const target = chain.get('target');
|
|
261
|
+
if ((0, external_utils_js_namespaceObject.skipByTarget)(target)) return;
|
|
262
|
+
const isWeb = (0, external_utils_js_namespaceObject.isWebTarget)(target);
|
|
263
|
+
addMyTypes2Ignored(chain, isWeb ? csrConfig : ssrConfig);
|
|
264
|
+
const targetMFConfig = isWeb ? csrConfig : ssrConfig;
|
|
265
|
+
patchMFConfig(targetMFConfig, !isWeb, userConfig.remoteIpStrategy || 'ipv4', enableSSR);
|
|
266
|
+
patchBundlerConfig({
|
|
267
|
+
chain,
|
|
268
|
+
isServer: !isWeb,
|
|
269
|
+
modernjsConfig,
|
|
270
|
+
mfConfig,
|
|
271
|
+
enableSSR
|
|
272
|
+
});
|
|
273
|
+
if (isWeb) userConfig.distOutputDir = chain.output.get('path') || external_path_default().resolve(process.cwd(), 'dist');
|
|
274
|
+
else if (enableSSR) {
|
|
275
|
+
var _userConfig, _userConfig_userConfig;
|
|
276
|
+
(_userConfig = userConfig).userConfig || (_userConfig.userConfig = {});
|
|
277
|
+
(_userConfig_userConfig = userConfig.userConfig).ssr || (_userConfig_userConfig.ssr = {});
|
|
278
|
+
if (true === userConfig.userConfig.ssr) userConfig.userConfig.ssr = {};
|
|
279
|
+
userConfig.userConfig.ssr.distOutputDir = chain.output.get('path') || external_path_default().resolve(process.cwd(), 'dist/bundles');
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
api.config(()=>{
|
|
283
|
+
var _ref;
|
|
284
|
+
var _modernjsConfig_tools, _userConfig_csrConfig, _modernjsConfig_source, _modernjsConfig_dev;
|
|
285
|
+
const ipv4 = (0, external_utils_js_namespaceObject.getIPV4)();
|
|
286
|
+
if (void 0 === userConfig.remoteIpStrategy) if (enableSSR) userConfig.remoteIpStrategy = 'ipv4';
|
|
287
|
+
else userConfig.remoteIpStrategy = 'inherit';
|
|
288
|
+
const devServerConfig = null == (_modernjsConfig_tools = modernjsConfig.tools) ? void 0 : _modernjsConfig_tools.devServer;
|
|
289
|
+
const corsWarnMsgs = [
|
|
290
|
+
'View https://module-federation.io/guide/troubleshooting/other.html#cors-warn for more details.'
|
|
291
|
+
];
|
|
292
|
+
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.');
|
|
293
|
+
const exposes = null == (_userConfig_csrConfig = userConfig.csrConfig) ? void 0 : _userConfig_csrConfig.exposes;
|
|
294
|
+
const hasExposes = exposes && Array.isArray(exposes) ? exposes.length : Object.keys(null != exposes ? exposes : {}).length;
|
|
295
|
+
if (corsWarnMsgs.length > 1 && hasExposes) external_logger_js_default().warn(corsWarnMsgs.join('\n'));
|
|
296
|
+
const corsHeaders = hasExposes ? {
|
|
297
|
+
'Access-Control-Allow-Origin': '*',
|
|
298
|
+
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',
|
|
299
|
+
'Access-Control-Allow-Headers': '*'
|
|
300
|
+
} : void 0;
|
|
301
|
+
const defineConfig = {
|
|
302
|
+
REMOTE_IP_STRATEGY: JSON.stringify(userConfig.remoteIpStrategy)
|
|
303
|
+
};
|
|
304
|
+
if (enableSSR && (0, external_utils_js_namespaceObject.isDev)()) defineConfig['FEDERATION_IPV4'] = JSON.stringify(ipv4);
|
|
305
|
+
return {
|
|
306
|
+
tools: {
|
|
307
|
+
devServer: {
|
|
308
|
+
headers: corsHeaders
|
|
309
|
+
}
|
|
310
|
+
},
|
|
311
|
+
resolve: {
|
|
312
|
+
alias: {
|
|
313
|
+
'@modern-js/runtime/mf': require.resolve('@module-federation/modern-js-v3/runtime')
|
|
314
|
+
}
|
|
315
|
+
},
|
|
316
|
+
source: {
|
|
317
|
+
define: defineConfig,
|
|
318
|
+
enableAsyncEntry: null != (_ref = null == (_modernjsConfig_source = modernjsConfig.source) ? void 0 : _modernjsConfig_source.enableAsyncEntry) ? _ref : true
|
|
319
|
+
},
|
|
320
|
+
dev: {
|
|
321
|
+
assetPrefix: (null == modernjsConfig ? void 0 : null == (_modernjsConfig_dev = modernjsConfig.dev) ? void 0 : _modernjsConfig_dev.assetPrefix) ? modernjsConfig.dev.assetPrefix : 'auto'
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
const configPlugin = moduleFederationConfigPlugin;
|
|
328
|
+
})();
|
|
329
|
+
exports.addMyTypes2Ignored = __webpack_exports__.addMyTypes2Ignored;
|
|
330
|
+
exports["default"] = __webpack_exports__["default"];
|
|
331
|
+
exports.getMFConfig = __webpack_exports__.getMFConfig;
|
|
332
|
+
exports.isWebTarget = __webpack_exports__.isWebTarget;
|
|
333
|
+
exports.moduleFederationConfigPlugin = __webpack_exports__.moduleFederationConfigPlugin;
|
|
334
|
+
exports.patchBundlerConfig = __webpack_exports__.patchBundlerConfig;
|
|
335
|
+
exports.patchMFConfig = __webpack_exports__.patchMFConfig;
|
|
336
|
+
exports.setEnv = __webpack_exports__.setEnv;
|
|
337
|
+
exports.skipByTarget = __webpack_exports__.skipByTarget;
|
|
338
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
339
|
+
"addMyTypes2Ignored",
|
|
340
|
+
"default",
|
|
341
|
+
"getMFConfig",
|
|
342
|
+
"isWebTarget",
|
|
343
|
+
"moduleFederationConfigPlugin",
|
|
344
|
+
"patchBundlerConfig",
|
|
345
|
+
"patchMFConfig",
|
|
346
|
+
"setEnv",
|
|
347
|
+
"skipByTarget"
|
|
348
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
349
|
+
Object.defineProperty(exports, '__esModule', {
|
|
350
|
+
value: true
|
|
351
|
+
});
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
moduleFederationPlugin: ()=>moduleFederationPlugin,
|
|
28
|
+
createModuleFederationConfig: ()=>enhanced_namespaceObject.createModuleFederationConfig,
|
|
29
|
+
default: ()=>cli
|
|
30
|
+
});
|
|
31
|
+
const rspack_namespaceObject = require("@module-federation/enhanced/rspack");
|
|
32
|
+
const external_configPlugin_js_namespaceObject = require("./configPlugin.js");
|
|
33
|
+
const external_ssrPlugin_js_namespaceObject = require("./ssrPlugin.js");
|
|
34
|
+
const external_utils_js_namespaceObject = require("./utils.js");
|
|
35
|
+
const enhanced_namespaceObject = require("@module-federation/enhanced");
|
|
36
|
+
const moduleFederationPlugin = (userConfig = {})=>{
|
|
37
|
+
var _userConfig_fetchServerQuery, _userConfig_secondarySharedTreeShaking;
|
|
38
|
+
const internalModernPluginOptions = {
|
|
39
|
+
csrConfig: void 0,
|
|
40
|
+
ssrConfig: void 0,
|
|
41
|
+
browserPlugin: void 0,
|
|
42
|
+
nodePlugin: void 0,
|
|
43
|
+
assetResources: {},
|
|
44
|
+
distOutputDir: '',
|
|
45
|
+
originPluginOptions: {
|
|
46
|
+
...userConfig
|
|
47
|
+
},
|
|
48
|
+
remoteIpStrategy: null == userConfig ? void 0 : userConfig.remoteIpStrategy,
|
|
49
|
+
userConfig: userConfig || {},
|
|
50
|
+
assetFileNames: {},
|
|
51
|
+
fetchServerQuery: null != (_userConfig_fetchServerQuery = userConfig.fetchServerQuery) ? _userConfig_fetchServerQuery : void 0,
|
|
52
|
+
secondarySharedTreeShaking: null != (_userConfig_secondarySharedTreeShaking = userConfig.secondarySharedTreeShaking) ? _userConfig_secondarySharedTreeShaking : false
|
|
53
|
+
};
|
|
54
|
+
return {
|
|
55
|
+
name: '@modern-js/plugin-module-federation',
|
|
56
|
+
setup: async (api)=>{
|
|
57
|
+
api.modifyBundlerChain((chain)=>{
|
|
58
|
+
const browserPluginOptions = internalModernPluginOptions.csrConfig;
|
|
59
|
+
const { secondarySharedTreeShaking } = internalModernPluginOptions;
|
|
60
|
+
if ((0, external_utils_js_namespaceObject.isWebTarget)(chain.get('target'))) if (secondarySharedTreeShaking) chain.plugin('plugin-module-federation').use(rspack_namespaceObject.TreeShakingSharedPlugin, [
|
|
61
|
+
{
|
|
62
|
+
mfConfig: browserPluginOptions,
|
|
63
|
+
secondary: true
|
|
64
|
+
}
|
|
65
|
+
]);
|
|
66
|
+
else chain.plugin('plugin-module-federation').use(rspack_namespaceObject.ModuleFederationPlugin, [
|
|
67
|
+
browserPluginOptions
|
|
68
|
+
]).init((Plugin, args)=>{
|
|
69
|
+
internalModernPluginOptions.browserPlugin = new Plugin(args[0]);
|
|
70
|
+
return internalModernPluginOptions.browserPlugin;
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
api._internalServerPlugins(({ plugins })=>{
|
|
74
|
+
plugins.push({
|
|
75
|
+
name: '@module-federation/modern-js-v3/server'
|
|
76
|
+
});
|
|
77
|
+
return {
|
|
78
|
+
plugins
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
usePlugins: [
|
|
83
|
+
(0, external_configPlugin_js_namespaceObject.moduleFederationConfigPlugin)(internalModernPluginOptions),
|
|
84
|
+
(0, external_ssrPlugin_js_namespaceObject.moduleFederationSSRPlugin)(internalModernPluginOptions)
|
|
85
|
+
]
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
const cli = moduleFederationPlugin;
|
|
89
|
+
exports.createModuleFederationConfig = __webpack_exports__.createModuleFederationConfig;
|
|
90
|
+
exports["default"] = __webpack_exports__["default"];
|
|
91
|
+
exports.moduleFederationPlugin = __webpack_exports__.moduleFederationPlugin;
|
|
92
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
93
|
+
"createModuleFederationConfig",
|
|
94
|
+
"default",
|
|
95
|
+
"moduleFederationPlugin"
|
|
96
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
97
|
+
Object.defineProperty(exports, '__esModule', {
|
|
98
|
+
value: true
|
|
99
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: definition[key]
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
})();
|
|
20
|
+
(()=>{
|
|
21
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
+
})();
|
|
23
|
+
(()=>{
|
|
24
|
+
__webpack_require__.r = (exports1)=>{
|
|
25
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
+
value: 'Module'
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
+
value: true
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
})();
|
|
33
|
+
var __webpack_exports__ = {};
|
|
34
|
+
__webpack_require__.r(__webpack_exports__);
|
|
35
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
+
default: ()=>inject_node_fetch
|
|
37
|
+
});
|
|
38
|
+
const external_node_fetch_namespaceObject = require("node-fetch");
|
|
39
|
+
var external_node_fetch_default = /*#__PURE__*/ __webpack_require__.n(external_node_fetch_namespaceObject);
|
|
40
|
+
const injectNodeFetchPlugin = ()=>({
|
|
41
|
+
name: 'inject-node-fetch-plugin',
|
|
42
|
+
beforeInit (args) {
|
|
43
|
+
if (!globalThis.fetch) globalThis.fetch = external_node_fetch_default();
|
|
44
|
+
return args;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
const inject_node_fetch = injectNodeFetchPlugin;
|
|
48
|
+
exports["default"] = __webpack_exports__["default"];
|
|
49
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
50
|
+
"default"
|
|
51
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
52
|
+
Object.defineProperty(exports, '__esModule', {
|
|
53
|
+
value: true
|
|
54
|
+
});
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
default: ()=>resolve_entry_ipv4
|
|
28
|
+
});
|
|
29
|
+
const external_constant_js_namespaceObject = require("../../constant.js");
|
|
30
|
+
const ipv4 = "u" > typeof FEDERATION_IPV4 ? FEDERATION_IPV4 : '127.0.0.1';
|
|
31
|
+
const remoteIpStrategy = "u" > typeof REMOTE_IP_STRATEGY ? REMOTE_IP_STRATEGY : 'inherit';
|
|
32
|
+
function replaceObjectLocalhost(key, obj) {
|
|
33
|
+
if ('ipv4' !== remoteIpStrategy) return;
|
|
34
|
+
if (!(key in obj)) return;
|
|
35
|
+
const remote = obj[key];
|
|
36
|
+
if (remote && 'string' == typeof remote && remote.includes(external_constant_js_namespaceObject.LOCALHOST)) obj[key] = replaceLocalhost(remote);
|
|
37
|
+
}
|
|
38
|
+
function replaceLocalhost(url) {
|
|
39
|
+
return url.replace(external_constant_js_namespaceObject.LOCALHOST, ipv4);
|
|
40
|
+
}
|
|
41
|
+
const resolveEntryIpv4Plugin = ()=>({
|
|
42
|
+
name: 'resolve-entry-ipv4',
|
|
43
|
+
beforeRegisterRemote (args) {
|
|
44
|
+
const { remote } = args;
|
|
45
|
+
replaceObjectLocalhost('entry', remote);
|
|
46
|
+
return args;
|
|
47
|
+
},
|
|
48
|
+
async afterResolve (args) {
|
|
49
|
+
const { remoteInfo } = args;
|
|
50
|
+
replaceObjectLocalhost('entry', remoteInfo);
|
|
51
|
+
return args;
|
|
52
|
+
},
|
|
53
|
+
beforeLoadRemoteSnapshot (args) {
|
|
54
|
+
const { moduleInfo } = args;
|
|
55
|
+
if ('entry' in moduleInfo) {
|
|
56
|
+
replaceObjectLocalhost('entry', moduleInfo);
|
|
57
|
+
return args;
|
|
58
|
+
}
|
|
59
|
+
if ('version' in moduleInfo) replaceObjectLocalhost('version', moduleInfo);
|
|
60
|
+
return args;
|
|
61
|
+
},
|
|
62
|
+
loadRemoteSnapshot (args) {
|
|
63
|
+
const { remoteSnapshot } = args;
|
|
64
|
+
if ('publicPath' in remoteSnapshot) replaceObjectLocalhost('publicPath', remoteSnapshot);
|
|
65
|
+
if ('getPublicPath' in remoteSnapshot) replaceObjectLocalhost('getPublicPath', remoteSnapshot);
|
|
66
|
+
if (remoteSnapshot.remotesInfo) Object.keys(remoteSnapshot.remotesInfo).forEach((key)=>{
|
|
67
|
+
const remoteInfo = remoteSnapshot.remotesInfo[key];
|
|
68
|
+
replaceObjectLocalhost('matchedVersion', remoteInfo);
|
|
69
|
+
});
|
|
70
|
+
return args;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
const resolve_entry_ipv4 = resolveEntryIpv4Plugin;
|
|
74
|
+
exports["default"] = __webpack_exports__["default"];
|
|
75
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
76
|
+
"default"
|
|
77
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
78
|
+
Object.defineProperty(exports, '__esModule', {
|
|
79
|
+
value: true
|
|
80
|
+
});
|