@module-federation/modern-js 0.0.0-chore-bump-node-22-20260710161714
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/cjs/cli/configPlugin.js +346 -0
- package/dist/cjs/cli/index.js +115 -0
- package/dist/cjs/cli/mfRuntimePlugins/inject-node-fetch.js +54 -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 +314 -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/data-fetch.js +58 -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 +82 -0
- package/dist/cjs/server/index.js +71 -0
- package/dist/cjs/server/staticMiddleware.js +97 -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 +47 -0
- package/dist/cjs/types/index.js +18 -0
- package/dist/esm/cli/configPlugin.mjs +321 -0
- package/dist/esm/cli/index.mjs +91 -0
- package/dist/esm/cli/mfRuntimePlugins/inject-node-fetch.mjs +12 -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 +297 -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/data-fetch.mjs +1 -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 +125 -0
- package/dist/esm/server/index.mjs +36 -0
- package/dist/esm/server/staticMiddleware.mjs +122 -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 +33 -0
- package/dist/esm/types/index.mjs +0 -0
- package/dist/esm-node/cli/configPlugin.mjs +276 -0
- package/dist/esm-node/cli/index.mjs +75 -0
- package/dist/esm-node/cli/mfRuntimePlugins/inject-node-fetch.mjs +10 -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 +258 -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/data-fetch.mjs +1 -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 +45 -0
- package/dist/esm-node/server/index.mjs +34 -0
- package/dist/esm-node/server/staticMiddleware.mjs +50 -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 +13 -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/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/ssrPlugin.spec.d.ts +1 -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 +18 -0
- package/dist/types/logger.d.ts +2 -0
- package/dist/types/react/data-fetch.d.ts +1 -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 +35 -0
- package/package.json +192 -0
- package/types.d.ts +6 -0
|
@@ -0,0 +1,314 @@
|
|
|
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: ()=>ssrPlugin,
|
|
37
|
+
moduleFederationSSRPlugin: ()=>moduleFederationSSRPlugin,
|
|
38
|
+
setEnv: ()=>setEnv,
|
|
39
|
+
CHAIN_MF_PLUGIN_ID: ()=>CHAIN_MF_PLUGIN_ID
|
|
40
|
+
});
|
|
41
|
+
const external_path_namespaceObject = require("path");
|
|
42
|
+
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
|
|
43
|
+
const external_fs_namespaceObject = require("fs");
|
|
44
|
+
var external_fs_default = /*#__PURE__*/ __webpack_require__.n(external_fs_namespaceObject);
|
|
45
|
+
const enhanced_namespaceObject = require("@module-federation/enhanced");
|
|
46
|
+
const rspack_namespaceObject = require("@module-federation/enhanced/rspack");
|
|
47
|
+
const universe_entry_chunk_tracker_plugin_namespaceObject = require("@module-federation/node/universe-entry-chunk-tracker-plugin");
|
|
48
|
+
var universe_entry_chunk_tracker_plugin_default = /*#__PURE__*/ __webpack_require__.n(universe_entry_chunk_tracker_plugin_namespaceObject);
|
|
49
|
+
const external_logger_js_namespaceObject = require("../logger.js");
|
|
50
|
+
var external_logger_js_default = /*#__PURE__*/ __webpack_require__.n(external_logger_js_namespaceObject);
|
|
51
|
+
const external_utils_js_namespaceObject = require("./utils.js");
|
|
52
|
+
const utils_namespaceObject = require("@module-federation/rsbuild-plugin/utils");
|
|
53
|
+
const sdk_namespaceObject = require("@module-federation/sdk");
|
|
54
|
+
function setEnv() {
|
|
55
|
+
process.env['MF_SSR_PRJ'] = 'true';
|
|
56
|
+
}
|
|
57
|
+
const CHAIN_MF_PLUGIN_ID = 'plugin-module-federation-server';
|
|
58
|
+
function getManifestAssetFileNames(manifestOption) {
|
|
59
|
+
if (!manifestOption) return {
|
|
60
|
+
statsFileName: sdk_namespaceObject.StatsFileName,
|
|
61
|
+
manifestFileName: sdk_namespaceObject.ManifestFileName
|
|
62
|
+
};
|
|
63
|
+
const JSON_EXT = '.json';
|
|
64
|
+
const filePath = 'boolean' == typeof manifestOption ? '' : manifestOption.filePath || '';
|
|
65
|
+
const baseFileName = 'boolean' == typeof manifestOption ? '' : manifestOption.fileName || '';
|
|
66
|
+
const ensureExt = (name)=>name.endsWith(JSON_EXT) ? name : `${name}${JSON_EXT}`;
|
|
67
|
+
const withSuffix = (name, suffix)=>name.replace(JSON_EXT, `${suffix}${JSON_EXT}`);
|
|
68
|
+
const manifestFileName = baseFileName ? ensureExt(baseFileName) : sdk_namespaceObject.ManifestFileName;
|
|
69
|
+
const statsFileName = baseFileName ? withSuffix(manifestFileName, '-stats') : sdk_namespaceObject.StatsFileName;
|
|
70
|
+
return {
|
|
71
|
+
statsFileName: (0, sdk_namespaceObject.simpleJoinRemoteEntry)(filePath, statsFileName),
|
|
72
|
+
manifestFileName: (0, sdk_namespaceObject.simpleJoinRemoteEntry)(filePath, manifestFileName)
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
const STATIC_ASSET_MODULE_TYPES = [
|
|
76
|
+
'asset',
|
|
77
|
+
'asset/resource'
|
|
78
|
+
];
|
|
79
|
+
const preserveStaticAssetPublicPath = (config, publicPath)=>{
|
|
80
|
+
var _config, _moduleConfig;
|
|
81
|
+
if ('string' != typeof publicPath || '' === publicPath || 'auto' === publicPath) return;
|
|
82
|
+
(_config = config).module || (_config.module = {});
|
|
83
|
+
const moduleConfig = config.module;
|
|
84
|
+
(_moduleConfig = moduleConfig).generator || (_moduleConfig.generator = {});
|
|
85
|
+
for (const moduleType of STATIC_ASSET_MODULE_TYPES){
|
|
86
|
+
var _moduleConfig_generator, _moduleType, _moduleConfig_generator_moduleType;
|
|
87
|
+
(_moduleConfig_generator = moduleConfig.generator)[_moduleType = moduleType] || (_moduleConfig_generator[_moduleType] = {});
|
|
88
|
+
null != (_moduleConfig_generator_moduleType = moduleConfig.generator[moduleType]).publicPath || (_moduleConfig_generator_moduleType.publicPath = publicPath);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
const mfSSRRsbuildPlugin = (pluginOptions)=>({
|
|
92
|
+
name: '@modern-js/plugin-mf-post-config',
|
|
93
|
+
pre: [
|
|
94
|
+
'@modern-js/builder-plugin-ssr'
|
|
95
|
+
],
|
|
96
|
+
setup (api) {
|
|
97
|
+
var _pluginOptions_csrConfig, _pluginOptions_assetFileNames, _pluginOptions_ssrConfig;
|
|
98
|
+
if (pluginOptions.csrConfig.getPublicPath) return;
|
|
99
|
+
let csrOutputPath = '';
|
|
100
|
+
let ssrOutputPath = '';
|
|
101
|
+
let ssrEnv = '';
|
|
102
|
+
let csrEnv = '';
|
|
103
|
+
const browserAssetFileNames = pluginOptions.assetFileNames.browser || getManifestAssetFileNames(null == (_pluginOptions_csrConfig = pluginOptions.csrConfig) ? void 0 : _pluginOptions_csrConfig.manifest);
|
|
104
|
+
const nodeAssetFileNames = (null == (_pluginOptions_assetFileNames = pluginOptions.assetFileNames) ? void 0 : _pluginOptions_assetFileNames.node) || getManifestAssetFileNames(null == (_pluginOptions_ssrConfig = pluginOptions.ssrConfig) ? void 0 : _pluginOptions_ssrConfig.manifest);
|
|
105
|
+
const collectAssets = (assets, fileNames, tag)=>{
|
|
106
|
+
const statsAsset = assets[fileNames.statsFileName];
|
|
107
|
+
const manifestAsset = assets[fileNames.manifestFileName];
|
|
108
|
+
if (!statsAsset || !manifestAsset) return;
|
|
109
|
+
try {
|
|
110
|
+
const statsRaw = statsAsset.source();
|
|
111
|
+
const manifestRaw = manifestAsset.source();
|
|
112
|
+
const statsContent = 'string' == typeof statsRaw ? statsRaw : statsRaw.toString();
|
|
113
|
+
const manifestContent = 'string' == typeof manifestRaw ? manifestRaw : manifestRaw.toString();
|
|
114
|
+
return {
|
|
115
|
+
stats: {
|
|
116
|
+
data: JSON.parse(statsContent),
|
|
117
|
+
filename: fileNames.statsFileName
|
|
118
|
+
},
|
|
119
|
+
manifest: {
|
|
120
|
+
data: JSON.parse(manifestContent),
|
|
121
|
+
filename: fileNames.manifestFileName
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
} catch (err) {
|
|
125
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
126
|
+
external_logger_js_default().error(`Failed to parse ${tag} manifest assets: ${message}`);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
api.modifyEnvironmentConfig((config, { name })=>{
|
|
131
|
+
const target = config.output.target;
|
|
132
|
+
if ((0, external_utils_js_namespaceObject.skipByTarget)(target)) return config;
|
|
133
|
+
if ((0, external_utils_js_namespaceObject.isWebTarget)(target)) {
|
|
134
|
+
csrOutputPath = config.output.distPath.root;
|
|
135
|
+
csrEnv = name;
|
|
136
|
+
} else {
|
|
137
|
+
ssrOutputPath = config.output.distPath.root;
|
|
138
|
+
ssrEnv = name;
|
|
139
|
+
}
|
|
140
|
+
return config;
|
|
141
|
+
});
|
|
142
|
+
const modifySSRPublicPath = (config, utils)=>{
|
|
143
|
+
if (ssrEnv !== utils.environment.name) return config;
|
|
144
|
+
const userSSRConfig = pluginOptions.userConfig.ssr ? 'object' == typeof pluginOptions.userConfig.ssr ? pluginOptions.userConfig.ssr : {} : {};
|
|
145
|
+
if (!userSSRConfig.distOutputDir) return;
|
|
146
|
+
const publicPath = config.output.publicPath;
|
|
147
|
+
preserveStaticAssetPublicPath(config, publicPath);
|
|
148
|
+
config.output.publicPath = `${publicPath}${external_path_default().relative(csrOutputPath, ssrOutputPath)}/`;
|
|
149
|
+
return config;
|
|
150
|
+
};
|
|
151
|
+
api.modifyWebpackConfig((config, utils)=>{
|
|
152
|
+
modifySSRPublicPath(config, utils);
|
|
153
|
+
return config;
|
|
154
|
+
});
|
|
155
|
+
api.modifyRspackConfig((config, utils)=>{
|
|
156
|
+
modifySSRPublicPath(config, utils);
|
|
157
|
+
return config;
|
|
158
|
+
});
|
|
159
|
+
api.processAssets({
|
|
160
|
+
stage: 'report'
|
|
161
|
+
}, ({ assets, environment: envContext })=>{
|
|
162
|
+
var _pluginOptions_csrConfig, _pluginOptions_ssrConfig;
|
|
163
|
+
const envName = envContext.name;
|
|
164
|
+
if ((null == (_pluginOptions_csrConfig = pluginOptions.csrConfig) ? void 0 : _pluginOptions_csrConfig.manifest) !== false && csrEnv && envName === csrEnv) {
|
|
165
|
+
const browserAssets = collectAssets(assets, browserAssetFileNames, 'browser');
|
|
166
|
+
if (browserAssets) pluginOptions.assetResources.browser = browserAssets;
|
|
167
|
+
}
|
|
168
|
+
if ((null == (_pluginOptions_ssrConfig = pluginOptions.ssrConfig) ? void 0 : _pluginOptions_ssrConfig.manifest) !== false && ssrEnv && envName === ssrEnv) {
|
|
169
|
+
const nodeAssets = collectAssets(assets, nodeAssetFileNames, 'node');
|
|
170
|
+
if (nodeAssets) pluginOptions.assetResources.node = nodeAssets;
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
const moduleFederationSSRPlugin = (pluginOptions)=>({
|
|
176
|
+
name: '@modern-js/plugin-module-federation-ssr',
|
|
177
|
+
pre: [
|
|
178
|
+
'@modern-js/plugin-module-federation-config',
|
|
179
|
+
'@modern-js/plugin-module-federation'
|
|
180
|
+
],
|
|
181
|
+
setup: async (api)=>{
|
|
182
|
+
var _ref;
|
|
183
|
+
var _pluginOptions_userConfig, _modernjsConfig_server;
|
|
184
|
+
const modernjsConfig = api.getConfig();
|
|
185
|
+
const enableSSR = null != (_ref = null == (_pluginOptions_userConfig = pluginOptions.userConfig) ? void 0 : _pluginOptions_userConfig.ssr) ? _ref : Boolean(null == modernjsConfig ? void 0 : null == (_modernjsConfig_server = modernjsConfig.server) ? void 0 : _modernjsConfig_server.ssr);
|
|
186
|
+
const { secondarySharedTreeShaking } = pluginOptions;
|
|
187
|
+
if (!enableSSR) return;
|
|
188
|
+
setEnv();
|
|
189
|
+
api._internalRuntimePlugins(({ entrypoint, plugins })=>{
|
|
190
|
+
if (secondarySharedTreeShaking) return {
|
|
191
|
+
entrypoint,
|
|
192
|
+
plugins
|
|
193
|
+
};
|
|
194
|
+
const { fetchServerQuery } = pluginOptions;
|
|
195
|
+
plugins.push({
|
|
196
|
+
name: 'injectDataFetchFunction',
|
|
197
|
+
path: '@module-federation/modern-js/ssr-inject-data-fetch-function-plugin',
|
|
198
|
+
config: {
|
|
199
|
+
fetchServerQuery
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
if (!(0, external_utils_js_namespaceObject.isDev)()) return {
|
|
203
|
+
entrypoint,
|
|
204
|
+
plugins
|
|
205
|
+
};
|
|
206
|
+
plugins.push({
|
|
207
|
+
name: 'mfSSRDev',
|
|
208
|
+
path: '@module-federation/modern-js/ssr-dev-plugin',
|
|
209
|
+
config: {}
|
|
210
|
+
});
|
|
211
|
+
return {
|
|
212
|
+
entrypoint,
|
|
213
|
+
plugins
|
|
214
|
+
};
|
|
215
|
+
});
|
|
216
|
+
if (pluginOptions.ssrConfig.remotes) api._internalServerPlugins(({ plugins })=>{
|
|
217
|
+
plugins.push({
|
|
218
|
+
name: '@module-federation/modern-js/data-fetch-server-plugin',
|
|
219
|
+
options: {}
|
|
220
|
+
});
|
|
221
|
+
return {
|
|
222
|
+
plugins
|
|
223
|
+
};
|
|
224
|
+
});
|
|
225
|
+
api.modifyBundlerChain((chain)=>{
|
|
226
|
+
const target = chain.get('target');
|
|
227
|
+
if ((0, external_utils_js_namespaceObject.skipByTarget)(target)) return;
|
|
228
|
+
const bundlerType = 'rspack' === api.getAppContext().bundlerType ? 'rspack' : 'webpack';
|
|
229
|
+
const MFPlugin = 'webpack' === bundlerType ? enhanced_namespaceObject.ModuleFederationPlugin : rspack_namespaceObject.ModuleFederationPlugin;
|
|
230
|
+
const TreeShakingSharedPlugin = 'webpack' === bundlerType ? enhanced_namespaceObject.TreeShakingSharedPlugin : rspack_namespaceObject.TreeShakingSharedPlugin;
|
|
231
|
+
const isWeb = (0, external_utils_js_namespaceObject.isWebTarget)(target);
|
|
232
|
+
if (!isWeb) {
|
|
233
|
+
if (!chain.plugins.has(CHAIN_MF_PLUGIN_ID)) if (secondarySharedTreeShaking) chain.plugin(CHAIN_MF_PLUGIN_ID).use(TreeShakingSharedPlugin, [
|
|
234
|
+
{
|
|
235
|
+
mfConfig: pluginOptions.ssrConfig,
|
|
236
|
+
secondary: true
|
|
237
|
+
}
|
|
238
|
+
]);
|
|
239
|
+
else chain.plugin(CHAIN_MF_PLUGIN_ID).use(MFPlugin, [
|
|
240
|
+
pluginOptions.ssrConfig
|
|
241
|
+
]).init((Plugin, args)=>{
|
|
242
|
+
pluginOptions.nodePlugin = new Plugin(args[0]);
|
|
243
|
+
return pluginOptions.nodePlugin;
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
if (!isWeb && !secondarySharedTreeShaking) {
|
|
247
|
+
chain.target('async-node');
|
|
248
|
+
if ((0, external_utils_js_namespaceObject.isDev)()) chain.plugin('UniverseEntryChunkTrackerPlugin').use(universe_entry_chunk_tracker_plugin_default());
|
|
249
|
+
}
|
|
250
|
+
if ((0, external_utils_js_namespaceObject.isDev)() && isWeb) chain.externals({
|
|
251
|
+
'@module-federation/node/utils': 'NOT_USED_IN_BROWSER'
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
api.config(()=>({
|
|
255
|
+
builderPlugins: [
|
|
256
|
+
mfSSRRsbuildPlugin(pluginOptions)
|
|
257
|
+
],
|
|
258
|
+
tools: {
|
|
259
|
+
devServer: {
|
|
260
|
+
before: [
|
|
261
|
+
(req, res, next)=>{
|
|
262
|
+
if (!enableSSR) return void next();
|
|
263
|
+
try {
|
|
264
|
+
var _req_url, _req_url1;
|
|
265
|
+
if ((null == (_req_url = req.url) ? void 0 : _req_url.includes('.json')) && !(null == (_req_url1 = req.url) ? void 0 : _req_url1.includes('hot-update'))) {
|
|
266
|
+
const filepath = external_path_default().join(process.cwd(), `dist${req.url}`);
|
|
267
|
+
external_fs_default().statSync(filepath);
|
|
268
|
+
res.setHeader('Access-Control-Allow-Origin', '*');
|
|
269
|
+
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, PATCH, OPTIONS');
|
|
270
|
+
res.setHeader('Access-Control-Allow-Headers', '*');
|
|
271
|
+
external_fs_default().createReadStream(filepath).pipe(res);
|
|
272
|
+
} else next();
|
|
273
|
+
} catch (err) {
|
|
274
|
+
external_logger_js_default().debug(err);
|
|
275
|
+
next();
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
]
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}));
|
|
282
|
+
const writeMergedManifest = ()=>{
|
|
283
|
+
const { distOutputDir, assetResources } = pluginOptions;
|
|
284
|
+
const browserAssets = assetResources.browser;
|
|
285
|
+
const nodeAssets = assetResources.node;
|
|
286
|
+
if (!distOutputDir || !browserAssets || !nodeAssets) return;
|
|
287
|
+
try {
|
|
288
|
+
(0, utils_namespaceObject.updateStatsAndManifest)(nodeAssets, browserAssets, distOutputDir);
|
|
289
|
+
} catch (err) {
|
|
290
|
+
external_logger_js_default().error(err);
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
api.onAfterBuild(()=>{
|
|
294
|
+
writeMergedManifest();
|
|
295
|
+
});
|
|
296
|
+
api.onDevCompileDone(()=>{
|
|
297
|
+
writeMergedManifest();
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
const ssrPlugin = moduleFederationSSRPlugin;
|
|
302
|
+
exports.CHAIN_MF_PLUGIN_ID = __webpack_exports__.CHAIN_MF_PLUGIN_ID;
|
|
303
|
+
exports["default"] = __webpack_exports__["default"];
|
|
304
|
+
exports.moduleFederationSSRPlugin = __webpack_exports__.moduleFederationSSRPlugin;
|
|
305
|
+
exports.setEnv = __webpack_exports__.setEnv;
|
|
306
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
307
|
+
"CHAIN_MF_PLUGIN_ID",
|
|
308
|
+
"default",
|
|
309
|
+
"moduleFederationSSRPlugin",
|
|
310
|
+
"setEnv"
|
|
311
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
312
|
+
Object.defineProperty(exports, '__esModule', {
|
|
313
|
+
value: true
|
|
314
|
+
});
|
|
@@ -0,0 +1,93 @@
|
|
|
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
|
+
getIPV4: ()=>getIPV4,
|
|
37
|
+
isDev: ()=>isDev,
|
|
38
|
+
isWebTarget: ()=>isWebTarget,
|
|
39
|
+
skipByTarget: ()=>skipByTarget
|
|
40
|
+
});
|
|
41
|
+
const external_os_namespaceObject = require("os");
|
|
42
|
+
var external_os_default = /*#__PURE__*/ __webpack_require__.n(external_os_namespaceObject);
|
|
43
|
+
const localIpv4 = '127.0.0.1';
|
|
44
|
+
const getIpv4Interfaces = ()=>{
|
|
45
|
+
try {
|
|
46
|
+
const interfaces = external_os_default().networkInterfaces();
|
|
47
|
+
const ipv4Interfaces = [];
|
|
48
|
+
Object.values(interfaces).forEach((detail)=>{
|
|
49
|
+
null == detail || detail.forEach((detail)=>{
|
|
50
|
+
const familyV4Value = 'string' == typeof detail.family ? 'IPv4' : 4;
|
|
51
|
+
if (detail.family === familyV4Value && detail.address !== localIpv4) ipv4Interfaces.push(detail);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
return ipv4Interfaces;
|
|
55
|
+
} catch (_err) {
|
|
56
|
+
return [];
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const getIPV4 = ()=>{
|
|
60
|
+
const ipv4Interfaces = getIpv4Interfaces();
|
|
61
|
+
const ipv4Interface = ipv4Interfaces[0] || {
|
|
62
|
+
address: localIpv4
|
|
63
|
+
};
|
|
64
|
+
return ipv4Interface.address;
|
|
65
|
+
};
|
|
66
|
+
const isWebTarget = (target)=>{
|
|
67
|
+
const WEB_TARGET = 'web';
|
|
68
|
+
if (Array.isArray(target)) return target.includes(WEB_TARGET);
|
|
69
|
+
if ('string' == typeof target) return target === WEB_TARGET;
|
|
70
|
+
return false;
|
|
71
|
+
};
|
|
72
|
+
const skipByTarget = (target)=>{
|
|
73
|
+
const IGNORE_TARGET = 'webworker';
|
|
74
|
+
if (Array.isArray(target)) return target.includes(IGNORE_TARGET);
|
|
75
|
+
if ('string' == typeof target) return target === IGNORE_TARGET;
|
|
76
|
+
return false;
|
|
77
|
+
};
|
|
78
|
+
function isDev() {
|
|
79
|
+
return 'development' === process.env.NODE_ENV;
|
|
80
|
+
}
|
|
81
|
+
exports.getIPV4 = __webpack_exports__.getIPV4;
|
|
82
|
+
exports.isDev = __webpack_exports__.isDev;
|
|
83
|
+
exports.isWebTarget = __webpack_exports__.isWebTarget;
|
|
84
|
+
exports.skipByTarget = __webpack_exports__.skipByTarget;
|
|
85
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
86
|
+
"getIPV4",
|
|
87
|
+
"isDev",
|
|
88
|
+
"isWebTarget",
|
|
89
|
+
"skipByTarget"
|
|
90
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
91
|
+
Object.defineProperty(exports, '__esModule', {
|
|
92
|
+
value: true
|
|
93
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
LOCALHOST: ()=>LOCALHOST,
|
|
28
|
+
PLUGIN_IDENTIFIER: ()=>PLUGIN_IDENTIFIER
|
|
29
|
+
});
|
|
30
|
+
const LOCALHOST = 'localhost';
|
|
31
|
+
const PLUGIN_IDENTIFIER = '[ Modern.js Module Federation ]';
|
|
32
|
+
exports.LOCALHOST = __webpack_exports__.LOCALHOST;
|
|
33
|
+
exports.PLUGIN_IDENTIFIER = __webpack_exports__.PLUGIN_IDENTIFIER;
|
|
34
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
35
|
+
"LOCALHOST",
|
|
36
|
+
"PLUGIN_IDENTIFIER"
|
|
37
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
38
|
+
Object.defineProperty(exports, '__esModule', {
|
|
39
|
+
value: true
|
|
40
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.r = (exports1)=>{
|
|
5
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
6
|
+
value: 'Module'
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
9
|
+
value: true
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
})();
|
|
13
|
+
var __webpack_exports__ = {};
|
|
14
|
+
__webpack_require__.r(__webpack_exports__);
|
|
15
|
+
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
16
|
+
Object.defineProperty(exports, '__esModule', {
|
|
17
|
+
value: true
|
|
18
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
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: ()=>src_logger
|
|
28
|
+
});
|
|
29
|
+
const sdk_namespaceObject = require("@module-federation/sdk");
|
|
30
|
+
const external_constant_js_namespaceObject = require("./constant.js");
|
|
31
|
+
const logger = (0, sdk_namespaceObject.createLogger)(external_constant_js_namespaceObject.PLUGIN_IDENTIFIER);
|
|
32
|
+
const src_logger = logger;
|
|
33
|
+
exports["default"] = __webpack_exports__["default"];
|
|
34
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
35
|
+
"default"
|
|
36
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
37
|
+
Object.defineProperty(exports, '__esModule', {
|
|
38
|
+
value: true
|
|
39
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_modules__ = {
|
|
3
|
+
"@module-federation/bridge-react/data-fetch" (module) {
|
|
4
|
+
module.exports = require("@module-federation/bridge-react/data-fetch");
|
|
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
|
+
var _module_federation_bridge_react_data_fetch__rspack_import_0 = __webpack_require__("@module-federation/bridge-react/data-fetch");
|
|
51
|
+
var __rspack_reexport = {};
|
|
52
|
+
for(const __rspack_import_key in _module_federation_bridge_react_data_fetch__rspack_import_0)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_module_federation_bridge_react_data_fetch__rspack_import_0[__rspack_import_key];
|
|
53
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
54
|
+
})();
|
|
55
|
+
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
56
|
+
Object.defineProperty(exports, '__esModule', {
|
|
57
|
+
value: true
|
|
58
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_modules__ = {
|
|
3
|
+
"@module-federation/bridge-react" (module) {
|
|
4
|
+
module.exports = require("@module-federation/bridge-react");
|
|
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
|
+
var _module_federation_bridge_react__rspack_import_0 = __webpack_require__("@module-federation/bridge-react");
|
|
51
|
+
var __rspack_reexport = {};
|
|
52
|
+
for(const __rspack_import_key in _module_federation_bridge_react__rspack_import_0)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>_module_federation_bridge_react__rspack_import_0[__rspack_import_key];
|
|
53
|
+
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
54
|
+
})();
|
|
55
|
+
for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
56
|
+
Object.defineProperty(exports, '__esModule', {
|
|
57
|
+
value: true
|
|
58
|
+
});
|