@module-federation/rsbuild-plugin 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/utils.js CHANGED
@@ -1,264 +1,96 @@
1
1
  "use strict";
2
- const __rslib_import_meta_url__ = /*#__PURE__*/ function() {
3
- return 'undefined' == typeof document ? new (require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
4
- }();
5
- var __webpack_require__ = {};
6
- (()=>{
7
- __webpack_require__.n = (module)=>{
8
- var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
9
- __webpack_require__.d(getter, {
10
- a: getter
11
- });
12
- return getter;
13
- };
2
+ const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
3
+ return typeof document === 'undefined'
4
+ ? new (require('url'.replace('', '')).URL)('file:' + __filename).href
5
+ : (document.currentScript && document.currentScript.src) ||
6
+ new URL('main.js', document.baseURI).href;
14
7
  })();
15
- (()=>{
16
- __webpack_require__.d = (exports1, definition)=>{
17
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
18
- enumerable: true,
19
- get: definition[key]
20
- });
21
- };
8
+ ;
9
+ var __webpack_modules__ = ({
10
+ "./utils/index"(module) {
11
+ module.exports = require("./utils/index.js");
12
+
13
+ },
14
+
15
+ });
16
+ // The module cache
17
+ var __webpack_module_cache__ = {};
18
+
19
+ // The require function
20
+ function __webpack_require__(moduleId) {
21
+
22
+ // Check if module is in cache
23
+ var cachedModule = __webpack_module_cache__[moduleId];
24
+ if (cachedModule !== undefined) {
25
+ return cachedModule.exports;
26
+ }
27
+ // Create a new module (and put it into the cache)
28
+ var module = (__webpack_module_cache__[moduleId] = {
29
+ exports: {}
30
+ });
31
+ // Execute the module function
32
+ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
33
+
34
+ // Return the exports of the module
35
+ return module.exports;
36
+
37
+ }
38
+
39
+ // webpack/runtime/compat_get_default_export
40
+ (() => {
41
+ // getDefaultExport function for compatibility with non-ESM modules
42
+ __webpack_require__.n = (module) => {
43
+ var getter = module && module.__esModule ?
44
+ () => (module['default']) :
45
+ () => (module);
46
+ __webpack_require__.d(getter, { a: getter });
47
+ return getter;
48
+ };
49
+
22
50
  })();
23
- (()=>{
24
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
51
+ // webpack/runtime/define_property_getters
52
+ (() => {
53
+ __webpack_require__.d = (exports, getters, values) => {
54
+ var define = (defs, kind) => {
55
+ for(var key in defs) {
56
+ if(__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) {
57
+ Object.defineProperty(exports, key, { enumerable: true, [kind]: defs[key] });
58
+ }
59
+ }
60
+ };
61
+ define(getters, "get");
62
+ define(values, "value");
63
+ };
25
64
  })();
26
- (()=>{
27
- __webpack_require__.r = (exports1)=>{
28
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
29
- value: 'Module'
30
- });
31
- Object.defineProperty(exports1, '__esModule', {
32
- value: true
33
- });
34
- };
65
+ // webpack/runtime/has_own_property
66
+ (() => {
67
+ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
68
+ })();
69
+ // webpack/runtime/make_namespace_object
70
+ (() => {
71
+ // define __esModule on exports
72
+ __webpack_require__.r = (exports) => {
73
+ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
74
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
75
+ }
76
+ Object.defineProperty(exports, '__esModule', { value: true });
77
+ };
35
78
  })();
36
79
  var __webpack_exports__ = {};
80
+ // This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
81
+ (() => {
37
82
  __webpack_require__.r(__webpack_exports__);
38
- __webpack_require__.d(__webpack_exports__, {
39
- createSSRREnvConfig: ()=>createSSRREnvConfig,
40
- DEFAULT_ASSET_PREFIX: ()=>"/",
41
- SSR_ENV_NAME: ()=>SSR_ENV_NAME,
42
- autoDeleteSplitChunkCacheGroups: ()=>autoDeleteSplitChunkCacheGroups,
43
- setSSREnv: ()=>setSSREnv,
44
- updateStatsAndManifest: ()=>updateStatsAndManifest,
45
- isRegExp: ()=>isRegExp,
46
- patchSSRRspackConfig: ()=>patchSSRRspackConfig,
47
- SSR_DIR: ()=>SSR_DIR,
48
- createSSRMFConfig: ()=>createSSRMFConfig,
49
- addDataFetchExposes: ()=>addDataFetchExposes
50
- });
51
- const external_util_namespaceObject = require("util");
52
- var external_util_default = /*#__PURE__*/ __webpack_require__.n(external_util_namespaceObject);
53
- const SPLIT_CHUNK_MAP = {
54
- REACT: 'react',
55
- ROUTER: 'router',
56
- LODASH: 'lib-lodash',
57
- ANTD: 'lib-antd',
58
- ARCO: 'lib-arco',
59
- SEMI: 'lib-semi',
60
- AXIOS: 'lib-axios'
61
- };
62
- const SHARED_SPLIT_CHUNK_MAP = {
63
- react: SPLIT_CHUNK_MAP.REACT,
64
- 'react-dom': SPLIT_CHUNK_MAP.REACT,
65
- 'react-router': SPLIT_CHUNK_MAP.ROUTER,
66
- 'react-router-dom': SPLIT_CHUNK_MAP.ROUTER,
67
- '@remix-run/router': SPLIT_CHUNK_MAP.ROUTER,
68
- lodash: SPLIT_CHUNK_MAP.LODASH,
69
- 'lodash-es': SPLIT_CHUNK_MAP.LODASH,
70
- antd: SPLIT_CHUNK_MAP.ANTD,
71
- '@arco-design/web-react': SPLIT_CHUNK_MAP.ARCO,
72
- '@douyinfe/semi-ui': SPLIT_CHUNK_MAP.SEMI,
73
- axios: SPLIT_CHUNK_MAP.AXIOS
74
- };
75
- function autoDeleteSplitChunkCacheGroups(mfConfig, splitChunks) {
76
- if (!mfConfig.shared) return;
77
- if (!splitChunks || !(null == splitChunks ? void 0 : splitChunks.cacheGroups)) return;
78
- const arrayShared = Array.isArray(mfConfig.shared) ? mfConfig.shared : Object.keys(mfConfig.shared);
79
- for (const shared of arrayShared){
80
- const splitChunkKey = SHARED_SPLIT_CHUNK_MAP[shared];
81
- if (splitChunkKey) {
82
- if (splitChunks.cacheGroups[splitChunkKey]) delete splitChunks.cacheGroups[splitChunkKey];
83
- }
84
- }
85
- return splitChunks;
86
- }
87
- const external_fs_extra_namespaceObject = require("fs-extra");
88
- var external_fs_extra_default = /*#__PURE__*/ __webpack_require__.n(external_fs_extra_namespaceObject);
89
- const external_path_namespaceObject = require("path");
90
- var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
91
- const sdk_namespaceObject = require("@module-federation/sdk");
92
- const DATA_FETCH_CLIENT_SUFFIX = '.client';
93
- const CALL_NAME_MAP = {
94
- RSPRESS: 'rspress',
95
- RSLIB: 'rslib'
96
- };
97
- const addDataFetchExpose = (exposes, key, filepath, suffix = '')=>{
98
- if (!external_fs_extra_default().existsSync(filepath)) return false;
99
- const dataFetchKey = '.' === key ? `./data${suffix}` : `${key}.data${suffix}`;
100
- if (exposes[dataFetchKey] && exposes[dataFetchKey] !== filepath) throw new Error(`data fetch key ${dataFetchKey} already exists, please modify this expose key, do not end with 'data' or '${DATA_FETCH_CLIENT_SUFFIX}'`);
101
- exposes[dataFetchKey] = filepath;
102
- return dataFetchKey;
103
- };
104
- const addExcludeDtsSuffix = (filepath)=>`${filepath}?exclude-mf-dts=true`;
105
- function addDataFetchExposes(exposes, isServer) {
106
- if ('object' != typeof exposes || Array.isArray(exposes)) return;
107
- if (0 === Object.keys(exposes).length) return;
108
- const tempDataFetch = external_path_default().resolve(process.cwd(), `node_modules/${sdk_namespaceObject.TEMP_DIR}`);
109
- const content = "export const fetchData=()=>{throw new Error('should not be called')};";
110
- external_fs_extra_default().ensureDirSync(tempDataFetch);
111
- Object.keys(exposes).forEach((key, index)=>{
112
- const expose = exposes[key];
113
- if ('string' != typeof expose) return;
114
- const absPath = external_path_default().resolve(process.cwd(), expose);
115
- const dataFetchPath = `${absPath.replace(external_path_default().extname(absPath), '')}.data.ts`;
116
- const dataFetchClientPath = `${absPath.replace(external_path_default().extname(absPath), '')}.data.client.ts`;
117
- const tempFile = external_path_default().join(tempDataFetch, `data-fetch-fallback${index}.ts`);
118
- external_fs_extra_default().writeFileSync(tempFile, content);
119
- const dateFetchClientKey = addDataFetchExpose(exposes, key, dataFetchClientPath, DATA_FETCH_CLIENT_SUFFIX);
120
- if (!isServer && dateFetchClientKey) {
121
- exposes[dateFetchClientKey.replace(DATA_FETCH_CLIENT_SUFFIX, '')] = addExcludeDtsSuffix(tempFile);
122
- return;
123
- }
124
- const dataFetchKey = addDataFetchExpose(exposes, key, dataFetchPath);
125
- if (dataFetchKey && external_fs_extra_default().existsSync(dataFetchClientPath)) exposes[`${dataFetchKey}${DATA_FETCH_CLIENT_SUFFIX}`] = addExcludeDtsSuffix(tempFile);
126
- });
127
- }
128
- function mergeStats(browserStats, nodeStats) {
129
- const ssrRemoteEntry = nodeStats.metaData.remoteEntry;
130
- browserStats.metaData.ssrRemoteEntry = ssrRemoteEntry;
131
- if ('publicPath' in browserStats.metaData) browserStats.metaData.ssrPublicPath = nodeStats.metaData.publicPath;
132
- return browserStats;
133
- }
134
- function mergeManifest(browserManifest, nodeManifest) {
135
- const ssrRemoteEntry = nodeManifest.metaData.remoteEntry;
136
- browserManifest.metaData.ssrRemoteEntry = ssrRemoteEntry;
137
- if ('publicPath' in browserManifest.metaData) browserManifest.metaData.ssrPublicPath = nodeManifest.metaData.publicPath;
138
- return browserManifest;
139
- }
140
- function mergeStatsAndManifest(nodeAssets, browserAssets) {
141
- const { stats: browserStats, manifest: browserManifest } = browserAssets;
142
- const { stats: nodeStats, manifest: nodeManifest } = nodeAssets;
143
- if (!browserStats || !nodeStats || !browserManifest || !nodeManifest) throw new Error('Failed to read stats or manifest assets for merge');
144
- const mergedStats = mergeStats(browserStats.data, nodeStats.data);
145
- const mergedManifest = mergeManifest(browserManifest.data, nodeManifest.data);
146
- return {
147
- mergedStats: mergedStats,
148
- mergedStatsFilePath: browserStats.filename,
149
- mergedManifest: mergedManifest,
150
- mergedManifestFilePath: browserManifest.filename
151
- };
152
- }
153
- function updateStatsAndManifest(nodeAssets, browserAssets, outputDir) {
154
- const { mergedStats, mergedStatsFilePath, mergedManifest, mergedManifestFilePath } = mergeStatsAndManifest(nodeAssets, browserAssets);
155
- external_fs_extra_default().writeFileSync(external_path_default().resolve(outputDir, mergedStatsFilePath), JSON.stringify(mergedStats, null, 2));
156
- external_fs_extra_default().writeFileSync(external_path_default().resolve(outputDir, mergedManifestFilePath), JSON.stringify(mergedManifest, null, 2));
157
- }
158
- const external_node_module_namespaceObject = require("node:module");
159
- const ssr_require = (0, external_node_module_namespaceObject.createRequire)(__rslib_import_meta_url__);
160
- const resolve = ssr_require.resolve;
161
- const SSR_DIR = 'ssr';
162
- const SSR_ENV_NAME = 'mf-ssr';
163
- function setSSREnv() {
164
- process.env['MF_SSR_PRJ'] = 'true';
165
- }
166
- const isDev = ()=>'development' === process.env['NODE_ENV'];
167
- function patchSSRRspackConfig(config, mfConfig, ssrDir, callerName, resetEntry = true, modifyPublicPath = true) {
168
- var _config_output;
169
- config.output ||= {};
170
- if (modifyPublicPath) {
171
- var _config_output1;
172
- if ('string' != typeof (null == (_config_output1 = config.output) ? void 0 : _config_output1.publicPath)) throw new Error('publicPath must be string!');
173
- const publicPath = config.output.publicPath;
174
- if ('auto' === publicPath) throw new Error('publicPath can not be "auto"!');
175
- const publicPathWithSSRDir = `${publicPath}${ssrDir}/`;
176
- config.output.publicPath = publicPathWithSSRDir;
177
- }
178
- if (callerName === CALL_NAME_MAP.RSPRESS && resetEntry) config.entry = 'data:application/node;base64,';
179
- config.target = 'async-node';
180
- const UniverseEntryChunkTrackerPlugin = ssr_require('@module-federation/node/universe-entry-chunk-tracker-plugin').default;
181
- config.plugins ||= [];
182
- isDev() && config.plugins.push(new UniverseEntryChunkTrackerPlugin());
183
- const uniqueName = mfConfig.name || (null == (_config_output = config.output) ? void 0 : _config_output.uniqueName);
184
- const chunkFileName = config.output.chunkFilename;
185
- if ('string' == typeof chunkFileName && uniqueName && !chunkFileName.includes(uniqueName)) {
186
- const suffix = `${(0, sdk_namespaceObject.encodeName)(uniqueName)}-[contenthash].js`;
187
- config.output.chunkFilename = chunkFileName.replace('.js', suffix);
188
- }
189
- return config;
190
- }
191
- function createSSRREnvConfig(envConfig, mfConfig, ssrDir, rsbuildConfig, callerName) {
192
- var _ssrEnvConfig_output, _ssrEnvConfig_output_distPath, _ssrEnvConfig_output1, _rsbuildConfig_output_distPath, _rsbuildConfig_output;
193
- const ssrEnvConfig = {
194
- ...envConfig,
195
- tools: {
196
- rspack: (config, { environment })=>{
197
- if (environment.name !== SSR_ENV_NAME) return;
198
- patchSSRRspackConfig(config, mfConfig, ssrDir, callerName);
199
- }
200
- }
201
- };
202
- ssrEnvConfig.output = {
203
- ...ssrEnvConfig.output,
204
- target: 'node',
205
- distPath: {
206
- ...null == (_ssrEnvConfig_output = ssrEnvConfig.output) ? void 0 : _ssrEnvConfig_output.distPath,
207
- root: external_path_default().join((null == (_ssrEnvConfig_output1 = ssrEnvConfig.output) ? void 0 : null == (_ssrEnvConfig_output_distPath = _ssrEnvConfig_output1.distPath) ? void 0 : _ssrEnvConfig_output_distPath.root) || (null == (_rsbuildConfig_output = rsbuildConfig.output) ? void 0 : null == (_rsbuildConfig_output_distPath = _rsbuildConfig_output.distPath) ? void 0 : _rsbuildConfig_output_distPath.root) || '', ssrDir)
208
- },
209
- emitAssets: true
210
- };
211
- return ssrEnvConfig;
212
- }
213
- function createSSRMFConfig(mfConfig) {
214
- var _mfConfig_library;
215
- const ssrMFConfig = {
216
- ...mfConfig,
217
- exposes: {
218
- ...mfConfig.exposes
219
- },
220
- library: {
221
- ...mfConfig.library,
222
- name: mfConfig.name,
223
- type: (null == (_mfConfig_library = mfConfig.library) ? void 0 : _mfConfig_library.type) ?? 'commonjs-module'
224
- },
225
- dts: false,
226
- dev: false,
227
- runtimePlugins: [
228
- ...mfConfig.runtimePlugins || []
229
- ]
230
- };
231
- ssrMFConfig.runtimePlugins.push(resolve('@module-federation/node/runtimePlugin'));
232
- if (isDev()) ssrMFConfig.runtimePlugins.push(resolve('@module-federation/node/record-dynamic-remote-entry-hash-plugin'));
233
- return ssrMFConfig;
234
- }
235
- function isRegExp(target) {
236
- return external_util_default().types.isRegExp(target);
83
+ /* import */ var _utils_index__rspack_import_0 = __webpack_require__("./utils/index");
84
+ /* import */ var _utils_index__rspack_import_0_default = /*#__PURE__*/__webpack_require__.n(_utils_index__rspack_import_0);
85
+
86
+ /* reexport */ var __rspack_reexport = {};
87
+ /* reexport */ for( const __rspack_import_key in _utils_index__rspack_import_0) if(__rspack_import_key !== "default") __rspack_reexport[__rspack_import_key] =() => _utils_index__rspack_import_0[__rspack_import_key]
88
+ /* reexport */ __webpack_require__.d(__webpack_exports__, __rspack_reexport);
89
+
90
+
91
+ })();
92
+
93
+ for(var __rspack_i in __webpack_exports__) {
94
+ exports[__rspack_i] = __webpack_exports__[__rspack_i];
237
95
  }
238
- exports.DEFAULT_ASSET_PREFIX = __webpack_exports__.DEFAULT_ASSET_PREFIX;
239
- exports.SSR_DIR = __webpack_exports__.SSR_DIR;
240
- exports.SSR_ENV_NAME = __webpack_exports__.SSR_ENV_NAME;
241
- exports.addDataFetchExposes = __webpack_exports__.addDataFetchExposes;
242
- exports.autoDeleteSplitChunkCacheGroups = __webpack_exports__.autoDeleteSplitChunkCacheGroups;
243
- exports.createSSRMFConfig = __webpack_exports__.createSSRMFConfig;
244
- exports.createSSRREnvConfig = __webpack_exports__.createSSRREnvConfig;
245
- exports.isRegExp = __webpack_exports__.isRegExp;
246
- exports.patchSSRRspackConfig = __webpack_exports__.patchSSRRspackConfig;
247
- exports.setSSREnv = __webpack_exports__.setSSREnv;
248
- exports.updateStatsAndManifest = __webpack_exports__.updateStatsAndManifest;
249
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
250
- "DEFAULT_ASSET_PREFIX",
251
- "SSR_DIR",
252
- "SSR_ENV_NAME",
253
- "addDataFetchExposes",
254
- "autoDeleteSplitChunkCacheGroups",
255
- "createSSRMFConfig",
256
- "createSSRREnvConfig",
257
- "isRegExp",
258
- "patchSSRRspackConfig",
259
- "setSSREnv",
260
- "updateStatsAndManifest"
261
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
262
- Object.defineProperty(exports, '__esModule', {
263
- value: true
264
- });
96
+ Object.defineProperty(exports, '__esModule', { value: true });
package/dist/utils.mjs CHANGED
@@ -1,186 +1,4 @@
1
- import util from "util";
2
- import fs_extra from "fs-extra";
3
- import path from "path";
4
- import { TEMP_DIR, encodeName } from "@module-federation/sdk";
5
- import { createRequire } from "node:module";
6
- const DATA_FETCH_CLIENT_SUFFIX = '.client';
7
- const CALL_NAME_MAP = {
8
- RSPRESS: 'rspress',
9
- RSLIB: 'rslib'
10
- };
11
- const SPLIT_CHUNK_MAP = {
12
- REACT: 'react',
13
- ROUTER: 'router',
14
- LODASH: 'lib-lodash',
15
- ANTD: 'lib-antd',
16
- ARCO: 'lib-arco',
17
- SEMI: 'lib-semi',
18
- AXIOS: 'lib-axios'
19
- };
20
- const SHARED_SPLIT_CHUNK_MAP = {
21
- react: SPLIT_CHUNK_MAP.REACT,
22
- 'react-dom': SPLIT_CHUNK_MAP.REACT,
23
- 'react-router': SPLIT_CHUNK_MAP.ROUTER,
24
- 'react-router-dom': SPLIT_CHUNK_MAP.ROUTER,
25
- '@remix-run/router': SPLIT_CHUNK_MAP.ROUTER,
26
- lodash: SPLIT_CHUNK_MAP.LODASH,
27
- 'lodash-es': SPLIT_CHUNK_MAP.LODASH,
28
- antd: SPLIT_CHUNK_MAP.ANTD,
29
- '@arco-design/web-react': SPLIT_CHUNK_MAP.ARCO,
30
- '@douyinfe/semi-ui': SPLIT_CHUNK_MAP.SEMI,
31
- axios: SPLIT_CHUNK_MAP.AXIOS
32
- };
33
- function autoDeleteSplitChunkCacheGroups(mfConfig, splitChunks) {
34
- if (!mfConfig.shared) return;
35
- if (!splitChunks || !(null == splitChunks ? void 0 : splitChunks.cacheGroups)) return;
36
- const arrayShared = Array.isArray(mfConfig.shared) ? mfConfig.shared : Object.keys(mfConfig.shared);
37
- for (const shared of arrayShared){
38
- const splitChunkKey = SHARED_SPLIT_CHUNK_MAP[shared];
39
- if (splitChunkKey) {
40
- if (splitChunks.cacheGroups[splitChunkKey]) delete splitChunks.cacheGroups[splitChunkKey];
41
- }
42
- }
43
- return splitChunks;
44
- }
45
- const addDataFetchExpose = (exposes, key, filepath, suffix = '')=>{
46
- if (!fs_extra.existsSync(filepath)) return false;
47
- const dataFetchKey = '.' === key ? `./data${suffix}` : `${key}.data${suffix}`;
48
- if (exposes[dataFetchKey] && exposes[dataFetchKey] !== filepath) throw new Error(`data fetch key ${dataFetchKey} already exists, please modify this expose key, do not end with 'data' or '${DATA_FETCH_CLIENT_SUFFIX}'`);
49
- exposes[dataFetchKey] = filepath;
50
- return dataFetchKey;
51
- };
52
- const addExcludeDtsSuffix = (filepath)=>`${filepath}?exclude-mf-dts=true`;
53
- function addDataFetchExposes(exposes, isServer) {
54
- if ('object' != typeof exposes || Array.isArray(exposes)) return;
55
- if (0 === Object.keys(exposes).length) return;
56
- const tempDataFetch = path.resolve(process.cwd(), `node_modules/${TEMP_DIR}`);
57
- const content = "export const fetchData=()=>{throw new Error('should not be called')};";
58
- fs_extra.ensureDirSync(tempDataFetch);
59
- Object.keys(exposes).forEach((key, index)=>{
60
- const expose = exposes[key];
61
- if ('string' != typeof expose) return;
62
- const absPath = path.resolve(process.cwd(), expose);
63
- const dataFetchPath = `${absPath.replace(path.extname(absPath), '')}.data.ts`;
64
- const dataFetchClientPath = `${absPath.replace(path.extname(absPath), '')}.data.client.ts`;
65
- const tempFile = path.join(tempDataFetch, `data-fetch-fallback${index}.ts`);
66
- fs_extra.writeFileSync(tempFile, content);
67
- const dateFetchClientKey = addDataFetchExpose(exposes, key, dataFetchClientPath, DATA_FETCH_CLIENT_SUFFIX);
68
- if (!isServer && dateFetchClientKey) {
69
- exposes[dateFetchClientKey.replace(DATA_FETCH_CLIENT_SUFFIX, '')] = addExcludeDtsSuffix(tempFile);
70
- return;
71
- }
72
- const dataFetchKey = addDataFetchExpose(exposes, key, dataFetchPath);
73
- if (dataFetchKey && fs_extra.existsSync(dataFetchClientPath)) exposes[`${dataFetchKey}${DATA_FETCH_CLIENT_SUFFIX}`] = addExcludeDtsSuffix(tempFile);
74
- });
75
- }
76
- function mergeStats(browserStats, nodeStats) {
77
- const ssrRemoteEntry = nodeStats.metaData.remoteEntry;
78
- browserStats.metaData.ssrRemoteEntry = ssrRemoteEntry;
79
- if ('publicPath' in browserStats.metaData) browserStats.metaData.ssrPublicPath = nodeStats.metaData.publicPath;
80
- return browserStats;
81
- }
82
- function mergeManifest(browserManifest, nodeManifest) {
83
- const ssrRemoteEntry = nodeManifest.metaData.remoteEntry;
84
- browserManifest.metaData.ssrRemoteEntry = ssrRemoteEntry;
85
- if ('publicPath' in browserManifest.metaData) browserManifest.metaData.ssrPublicPath = nodeManifest.metaData.publicPath;
86
- return browserManifest;
87
- }
88
- function mergeStatsAndManifest(nodeAssets, browserAssets) {
89
- const { stats: browserStats, manifest: browserManifest } = browserAssets;
90
- const { stats: nodeStats, manifest: nodeManifest } = nodeAssets;
91
- if (!browserStats || !nodeStats || !browserManifest || !nodeManifest) throw new Error('Failed to read stats or manifest assets for merge');
92
- const mergedStats = mergeStats(browserStats.data, nodeStats.data);
93
- const mergedManifest = mergeManifest(browserManifest.data, nodeManifest.data);
94
- return {
95
- mergedStats: mergedStats,
96
- mergedStatsFilePath: browserStats.filename,
97
- mergedManifest: mergedManifest,
98
- mergedManifestFilePath: browserManifest.filename
99
- };
100
- }
101
- function updateStatsAndManifest(nodeAssets, browserAssets, outputDir) {
102
- const { mergedStats, mergedStatsFilePath, mergedManifest, mergedManifestFilePath } = mergeStatsAndManifest(nodeAssets, browserAssets);
103
- fs_extra.writeFileSync(path.resolve(outputDir, mergedStatsFilePath), JSON.stringify(mergedStats, null, 2));
104
- fs_extra.writeFileSync(path.resolve(outputDir, mergedManifestFilePath), JSON.stringify(mergedManifest, null, 2));
105
- }
106
- const ssr_require = createRequire(import.meta.url);
107
- const resolve = ssr_require.resolve;
108
- const SSR_DIR = 'ssr';
109
- const SSR_ENV_NAME = 'mf-ssr';
110
- function setSSREnv() {
111
- process.env['MF_SSR_PRJ'] = 'true';
112
- }
113
- const isDev = ()=>'development' === process.env['NODE_ENV'];
114
- function patchSSRRspackConfig(config, mfConfig, ssrDir, callerName, resetEntry = true, modifyPublicPath = true) {
115
- var _config_output;
116
- config.output ||= {};
117
- if (modifyPublicPath) {
118
- var _config_output1;
119
- if ('string' != typeof (null == (_config_output1 = config.output) ? void 0 : _config_output1.publicPath)) throw new Error('publicPath must be string!');
120
- const publicPath = config.output.publicPath;
121
- if ('auto' === publicPath) throw new Error('publicPath can not be "auto"!');
122
- const publicPathWithSSRDir = `${publicPath}${ssrDir}/`;
123
- config.output.publicPath = publicPathWithSSRDir;
124
- }
125
- if (callerName === CALL_NAME_MAP.RSPRESS && resetEntry) config.entry = 'data:application/node;base64,';
126
- config.target = 'async-node';
127
- const UniverseEntryChunkTrackerPlugin = ssr_require('@module-federation/node/universe-entry-chunk-tracker-plugin').default;
128
- config.plugins ||= [];
129
- isDev() && config.plugins.push(new UniverseEntryChunkTrackerPlugin());
130
- const uniqueName = mfConfig.name || (null == (_config_output = config.output) ? void 0 : _config_output.uniqueName);
131
- const chunkFileName = config.output.chunkFilename;
132
- if ('string' == typeof chunkFileName && uniqueName && !chunkFileName.includes(uniqueName)) {
133
- const suffix = `${encodeName(uniqueName)}-[contenthash].js`;
134
- config.output.chunkFilename = chunkFileName.replace('.js', suffix);
135
- }
136
- return config;
137
- }
138
- function createSSRREnvConfig(envConfig, mfConfig, ssrDir, rsbuildConfig, callerName) {
139
- var _ssrEnvConfig_output, _ssrEnvConfig_output_distPath, _ssrEnvConfig_output1, _rsbuildConfig_output_distPath, _rsbuildConfig_output;
140
- const ssrEnvConfig = {
141
- ...envConfig,
142
- tools: {
143
- rspack: (config, { environment })=>{
144
- if (environment.name !== SSR_ENV_NAME) return;
145
- patchSSRRspackConfig(config, mfConfig, ssrDir, callerName);
146
- }
147
- }
148
- };
149
- ssrEnvConfig.output = {
150
- ...ssrEnvConfig.output,
151
- target: 'node',
152
- distPath: {
153
- ...null == (_ssrEnvConfig_output = ssrEnvConfig.output) ? void 0 : _ssrEnvConfig_output.distPath,
154
- root: path.join((null == (_ssrEnvConfig_output1 = ssrEnvConfig.output) ? void 0 : null == (_ssrEnvConfig_output_distPath = _ssrEnvConfig_output1.distPath) ? void 0 : _ssrEnvConfig_output_distPath.root) || (null == (_rsbuildConfig_output = rsbuildConfig.output) ? void 0 : null == (_rsbuildConfig_output_distPath = _rsbuildConfig_output.distPath) ? void 0 : _rsbuildConfig_output_distPath.root) || '', ssrDir)
155
- },
156
- emitAssets: true
157
- };
158
- return ssrEnvConfig;
159
- }
160
- function createSSRMFConfig(mfConfig) {
161
- var _mfConfig_library;
162
- const ssrMFConfig = {
163
- ...mfConfig,
164
- exposes: {
165
- ...mfConfig.exposes
166
- },
167
- library: {
168
- ...mfConfig.library,
169
- name: mfConfig.name,
170
- type: (null == (_mfConfig_library = mfConfig.library) ? void 0 : _mfConfig_library.type) ?? 'commonjs-module'
171
- },
172
- dts: false,
173
- dev: false,
174
- runtimePlugins: [
175
- ...mfConfig.runtimePlugins || []
176
- ]
177
- };
178
- ssrMFConfig.runtimePlugins.push(resolve('@module-federation/node/runtimePlugin'));
179
- if (isDev()) ssrMFConfig.runtimePlugins.push(resolve('@module-federation/node/record-dynamic-remote-entry-hash-plugin'));
180
- return ssrMFConfig;
181
- }
182
- function isRegExp(target) {
183
- return util.types.isRegExp(target);
184
- }
185
- var __webpack_exports__DEFAULT_ASSET_PREFIX = "/";
186
- export { SSR_DIR, SSR_ENV_NAME, addDataFetchExposes, autoDeleteSplitChunkCacheGroups, createSSRMFConfig, createSSRREnvConfig, isRegExp, patchSSRRspackConfig, setSSREnv, updateStatsAndManifest, __webpack_exports__DEFAULT_ASSET_PREFIX as DEFAULT_ASSET_PREFIX };
1
+ export * from "./utils/index.mjs";
2
+
3
+
4
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/rsbuild-plugin",
3
- "version": "0.0.0-perf-devtools-20260108034446",
3
+ "version": "0.0.0-perf-website-code-usage-20260914033703",
4
4
  "description": "Module Federation plugin for Rsbuild",
5
5
  "homepage": "https://module-federation.io",
6
6
  "bugs": {
@@ -49,17 +49,18 @@
49
49
  "dist"
50
50
  ],
51
51
  "dependencies": {
52
- "fs-extra": "11.3.0",
53
- "@module-federation/sdk": "0.0.0-perf-devtools-20260108034446",
54
- "@module-federation/enhanced": "0.0.0-perf-devtools-20260108034446",
55
- "@module-federation/node": "0.0.0-perf-devtools-20260108034446"
52
+ "@module-federation/sdk": "0.0.0-perf-website-code-usage-20260914033703",
53
+ "@module-federation/enhanced": "0.0.0-perf-website-code-usage-20260914033703",
54
+ "@module-federation/node": "0.0.0-perf-website-code-usage-20260914033703"
56
55
  },
57
56
  "devDependencies": {
58
- "@rslib/core": "^0.12.4",
59
- "@rsbuild/core": "^1.3.21"
57
+ "@rslib/core": "^0.23.2",
58
+ "@rsbuild/core": "2.1.4",
59
+ "@rstest/core": "^0.10.6",
60
+ "typescript": "7.0.2"
60
61
  },
61
62
  "peerDependencies": {
62
- "@rsbuild/core": "^1.3.21"
63
+ "@rsbuild/core": "^1.3.21 || ^2.0.0-0"
63
64
  },
64
65
  "peerDependenciesMeta": {
65
66
  "@rsbuild/core": {
@@ -72,5 +73,11 @@
72
73
  "publishConfig": {
73
74
  "access": "public",
74
75
  "registry": "https://registry.npmjs.org/"
76
+ },
77
+ "scripts": {
78
+ "build": "rslib build",
79
+ "lint": "ESLINT_USE_FLAT_CONFIG=false pnpm exec eslint --ignore-pattern node_modules \"**/*.ts\" \"package.json\"",
80
+ "test": "pnpm exec rstest --passWithNoTests",
81
+ "pre-release": "pnpm run test && pnpm run build"
75
82
  }
76
83
  }