@module-federation/rsbuild-plugin 0.0.0-perf-devtools-20260107043700 → 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.
@@ -0,0 +1,62 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { TEMP_DIR } from "@module-federation/sdk";
4
+ import { DATA_FETCH_CLIENT_SUFFIX, DATA_FETCH_IDENTIFIER } from "../constant.mjs";
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+ const addDataFetchExpose = (exposes, key, filepath, suffix = '')=>{
15
+ if (!fs.existsSync(filepath)) {
16
+ return false;
17
+ }
18
+ const dataFetchKey = key === '.' ? `./${DATA_FETCH_IDENTIFIER}${suffix}` : `${key}.${DATA_FETCH_IDENTIFIER}${suffix}`;
19
+ if (exposes[dataFetchKey] && exposes[dataFetchKey] !== filepath) {
20
+ throw new Error(`data fetch key ${dataFetchKey} already exists, please modify this expose key, do not end with '${DATA_FETCH_IDENTIFIER}' or '${DATA_FETCH_CLIENT_SUFFIX}'`);
21
+ }
22
+ exposes[dataFetchKey] = filepath;
23
+ return dataFetchKey;
24
+ };
25
+ const addExcludeDtsSuffix = (filepath)=>{
26
+ return `${filepath}?exclude-mf-dts=true`;
27
+ };
28
+ function addDataFetchExposes(exposes, isServer) {
29
+ if (typeof exposes !== 'object' || Array.isArray(exposes)) {
30
+ return;
31
+ }
32
+ if (Object.keys(exposes).length === 0) {
33
+ return;
34
+ }
35
+ const tempDataFetch = path.resolve(process.cwd(), `node_modules/${TEMP_DIR}`);
36
+ const content = `export const fetchData=()=>{throw new Error('should not be called')};`;
37
+ fs.mkdirSync(tempDataFetch, {
38
+ recursive: true
39
+ });
40
+ Object.keys(exposes).forEach((key, index)=>{
41
+ const expose = exposes[key];
42
+ if (typeof expose !== 'string') {
43
+ return;
44
+ }
45
+ const absPath = path.resolve(process.cwd(), expose);
46
+ const dataFetchPath = `${absPath.replace(path.extname(absPath), '')}.${DATA_FETCH_IDENTIFIER}.ts`;
47
+ const dataFetchClientPath = `${absPath.replace(path.extname(absPath), '')}.${DATA_FETCH_IDENTIFIER}.client.ts`;
48
+ const tempFile = path.join(tempDataFetch, `data-fetch-fallback${index}.ts`);
49
+ fs.writeFileSync(tempFile, content);
50
+ const dateFetchClientKey = addDataFetchExpose(exposes, key, dataFetchClientPath, DATA_FETCH_CLIENT_SUFFIX);
51
+ if (!isServer && dateFetchClientKey) {
52
+ exposes[dateFetchClientKey.replace(DATA_FETCH_CLIENT_SUFFIX, '')] = addExcludeDtsSuffix(tempFile);
53
+ return;
54
+ }
55
+ const dataFetchKey = addDataFetchExpose(exposes, key, dataFetchPath);
56
+ if (dataFetchKey && fs.existsSync(dataFetchClientPath)) {
57
+ exposes[`${dataFetchKey}${DATA_FETCH_CLIENT_SUFFIX}`] = addExcludeDtsSuffix(tempFile);
58
+ }
59
+ });
60
+ }
61
+
62
+ export { addDataFetchExposes };
@@ -0,0 +1,102 @@
1
+ "use strict";
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;
7
+ })();
8
+ ;
9
+ // The require scope
10
+ var __webpack_require__ = {};
11
+
12
+ // webpack/runtime/define_property_getters
13
+ (() => {
14
+ __webpack_require__.d = (exports, getters, values) => {
15
+ var define = (defs, kind) => {
16
+ for(var key in defs) {
17
+ if(__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) {
18
+ Object.defineProperty(exports, key, { enumerable: true, [kind]: defs[key] });
19
+ }
20
+ }
21
+ };
22
+ define(getters, "get");
23
+ define(values, "value");
24
+ };
25
+ })();
26
+ // webpack/runtime/has_own_property
27
+ (() => {
28
+ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
29
+ })();
30
+ // webpack/runtime/make_namespace_object
31
+ (() => {
32
+ // define __esModule on exports
33
+ __webpack_require__.r = (exports) => {
34
+ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
35
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
36
+ }
37
+ Object.defineProperty(exports, '__esModule', { value: true });
38
+ };
39
+ })();
40
+ var __webpack_exports__ = {};
41
+ __webpack_require__.r(__webpack_exports__);
42
+ // lib-polyfill.js: include core-js,@babel/runtime,@swc/helpers,tslib.
43
+ // lib-react.js: include react,react-dom.
44
+ // lib-router.js: include react-router,react-router-dom,history,@remix-run/router.
45
+ // lib-lodash.js: include lodash,lodash-es.
46
+ // lib-antd.js: include antd.
47
+ // lib-arco.js: include @arco-design/web-react.
48
+ // lib-semi.js: include @douyinfe/semi-ui.
49
+ // lib-axios.js: include axios.
50
+ const SPLIT_CHUNK_MAP = {
51
+ REACT: 'react',
52
+ ROUTER: 'router',
53
+ LODASH: 'lib-lodash',
54
+ ANTD: 'lib-antd',
55
+ ARCO: 'lib-arco',
56
+ SEMI: 'lib-semi',
57
+ AXIOS: 'lib-axios'
58
+ };
59
+ const SHARED_SPLIT_CHUNK_MAP = {
60
+ react: SPLIT_CHUNK_MAP.REACT,
61
+ 'react-dom': SPLIT_CHUNK_MAP.REACT,
62
+ 'react-router': SPLIT_CHUNK_MAP.ROUTER,
63
+ 'react-router-dom': SPLIT_CHUNK_MAP.ROUTER,
64
+ '@remix-run/router': SPLIT_CHUNK_MAP.ROUTER,
65
+ lodash: SPLIT_CHUNK_MAP.LODASH,
66
+ 'lodash-es': SPLIT_CHUNK_MAP.LODASH,
67
+ antd: SPLIT_CHUNK_MAP.ANTD,
68
+ '@arco-design/web-react': SPLIT_CHUNK_MAP.ARCO,
69
+ '@douyinfe/semi-ui': SPLIT_CHUNK_MAP.SEMI,
70
+ axios: SPLIT_CHUNK_MAP.AXIOS
71
+ };
72
+ function autoDeleteSplitChunkCacheGroups(mfConfig, splitChunks) {
73
+ if (!mfConfig.shared) {
74
+ return;
75
+ }
76
+ if (!splitChunks || !splitChunks?.cacheGroups) {
77
+ return;
78
+ }
79
+ const arrayShared = Array.isArray(mfConfig.shared) ? mfConfig.shared : Object.keys(mfConfig.shared);
80
+ for (const shared of arrayShared){
81
+ const splitChunkKey = SHARED_SPLIT_CHUNK_MAP[shared];
82
+ if (!splitChunkKey) {
83
+ continue;
84
+ }
85
+ if (splitChunks.cacheGroups[splitChunkKey]) {
86
+ delete splitChunks.cacheGroups[splitChunkKey];
87
+ }
88
+ }
89
+ return splitChunks;
90
+ }
91
+
92
+ __webpack_require__.d(__webpack_exports__, {
93
+ autoDeleteSplitChunkCacheGroups: () => (autoDeleteSplitChunkCacheGroups)
94
+ });
95
+
96
+ exports.autoDeleteSplitChunkCacheGroups = __webpack_exports__.autoDeleteSplitChunkCacheGroups;
97
+ for(var __rspack_i in __webpack_exports__) {
98
+ if(["autoDeleteSplitChunkCacheGroups"].indexOf(__rspack_i) === -1) {
99
+ exports[__rspack_i] = __webpack_exports__[__rspack_i];
100
+ }
101
+ }
102
+ Object.defineProperty(exports, '__esModule', { value: true });
@@ -0,0 +1,51 @@
1
+ // lib-polyfill.js: include core-js,@babel/runtime,@swc/helpers,tslib.
2
+ // lib-react.js: include react,react-dom.
3
+ // lib-router.js: include react-router,react-router-dom,history,@remix-run/router.
4
+ // lib-lodash.js: include lodash,lodash-es.
5
+ // lib-antd.js: include antd.
6
+ // lib-arco.js: include @arco-design/web-react.
7
+ // lib-semi.js: include @douyinfe/semi-ui.
8
+ // lib-axios.js: include axios.
9
+ const SPLIT_CHUNK_MAP = {
10
+ REACT: 'react',
11
+ ROUTER: 'router',
12
+ LODASH: 'lib-lodash',
13
+ ANTD: 'lib-antd',
14
+ ARCO: 'lib-arco',
15
+ SEMI: 'lib-semi',
16
+ AXIOS: 'lib-axios'
17
+ };
18
+ const SHARED_SPLIT_CHUNK_MAP = {
19
+ react: SPLIT_CHUNK_MAP.REACT,
20
+ 'react-dom': SPLIT_CHUNK_MAP.REACT,
21
+ 'react-router': SPLIT_CHUNK_MAP.ROUTER,
22
+ 'react-router-dom': SPLIT_CHUNK_MAP.ROUTER,
23
+ '@remix-run/router': SPLIT_CHUNK_MAP.ROUTER,
24
+ lodash: SPLIT_CHUNK_MAP.LODASH,
25
+ 'lodash-es': SPLIT_CHUNK_MAP.LODASH,
26
+ antd: SPLIT_CHUNK_MAP.ANTD,
27
+ '@arco-design/web-react': SPLIT_CHUNK_MAP.ARCO,
28
+ '@douyinfe/semi-ui': SPLIT_CHUNK_MAP.SEMI,
29
+ axios: SPLIT_CHUNK_MAP.AXIOS
30
+ };
31
+ function autoDeleteSplitChunkCacheGroups(mfConfig, splitChunks) {
32
+ if (!mfConfig.shared) {
33
+ return;
34
+ }
35
+ if (!splitChunks || !splitChunks?.cacheGroups) {
36
+ return;
37
+ }
38
+ const arrayShared = Array.isArray(mfConfig.shared) ? mfConfig.shared : Object.keys(mfConfig.shared);
39
+ for (const shared of arrayShared){
40
+ const splitChunkKey = SHARED_SPLIT_CHUNK_MAP[shared];
41
+ if (!splitChunkKey) {
42
+ continue;
43
+ }
44
+ if (splitChunks.cacheGroups[splitChunkKey]) {
45
+ delete splitChunks.cacheGroups[splitChunkKey];
46
+ }
47
+ }
48
+ return splitChunks;
49
+ }
50
+
51
+ export { autoDeleteSplitChunkCacheGroups };
@@ -0,0 +1,111 @@
1
+ "use strict";
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;
7
+ })();
8
+ ;
9
+ // The require scope
10
+ var __webpack_require__ = {};
11
+
12
+ // webpack/runtime/compat_get_default_export
13
+ (() => {
14
+ // getDefaultExport function for compatibility with non-ESM modules
15
+ __webpack_require__.n = (module) => {
16
+ var getter = module && module.__esModule ?
17
+ () => (module['default']) :
18
+ () => (module);
19
+ __webpack_require__.d(getter, { a: getter });
20
+ return getter;
21
+ };
22
+
23
+ })();
24
+ // webpack/runtime/define_property_getters
25
+ (() => {
26
+ __webpack_require__.d = (exports, getters, values) => {
27
+ var define = (defs, kind) => {
28
+ for(var key in defs) {
29
+ if(__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) {
30
+ Object.defineProperty(exports, key, { enumerable: true, [kind]: defs[key] });
31
+ }
32
+ }
33
+ };
34
+ define(getters, "get");
35
+ define(values, "value");
36
+ };
37
+ })();
38
+ // webpack/runtime/has_own_property
39
+ (() => {
40
+ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
41
+ })();
42
+ // webpack/runtime/make_namespace_object
43
+ (() => {
44
+ // define __esModule on exports
45
+ __webpack_require__.r = (exports) => {
46
+ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
47
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
48
+ }
49
+ Object.defineProperty(exports, '__esModule', { value: true });
50
+ };
51
+ })();
52
+ var __webpack_exports__ = {};
53
+ // ESM COMPAT FLAG
54
+ __webpack_require__.r(__webpack_exports__);
55
+
56
+ // EXPORTS
57
+ __webpack_require__.d(__webpack_exports__, {
58
+ DEFAULT_ASSET_PREFIX: () => (/* reexport */ external_constant_js_namespaceObject.DEFAULT_ASSET_PREFIX),
59
+ SSR_DIR: () => (/* reexport */ external_ssr_js_namespaceObject.SSR_DIR),
60
+ SSR_ENV_NAME: () => (/* reexport */ external_ssr_js_namespaceObject.SSR_ENV_NAME),
61
+ addDataFetchExposes: () => (/* reexport */ external_addDataFetchExposes_js_namespaceObject.addDataFetchExposes),
62
+ autoDeleteSplitChunkCacheGroups: () => (/* reexport */ external_autoDeleteSplitChunkCacheGroups_js_namespaceObject.autoDeleteSplitChunkCacheGroups),
63
+ createSSRMFConfig: () => (/* reexport */ external_ssr_js_namespaceObject.createSSRMFConfig),
64
+ createSSRREnvConfig: () => (/* reexport */ external_ssr_js_namespaceObject.createSSRREnvConfig),
65
+ isRegExp: () => (/* binding */ isRegExp),
66
+ patchSSRRspackConfig: () => (/* reexport */ external_ssr_js_namespaceObject.patchSSRRspackConfig),
67
+ setSSREnv: () => (/* reexport */ external_ssr_js_namespaceObject.setSSREnv),
68
+ updateStatsAndManifest: () => (/* reexport */ external_manifest_js_namespaceObject.updateStatsAndManifest)
69
+ });
70
+
71
+ ;// CONCATENATED MODULE: external "util"
72
+ const external_util_namespaceObject = require("util");
73
+ var external_util_default = /*#__PURE__*/__webpack_require__.n(external_util_namespaceObject);
74
+ ;// CONCATENATED MODULE: external "../constant.js"
75
+ const external_constant_js_namespaceObject = require("../constant.js");
76
+ ;// CONCATENATED MODULE: external "./autoDeleteSplitChunkCacheGroups.js"
77
+ const external_autoDeleteSplitChunkCacheGroups_js_namespaceObject = require("./autoDeleteSplitChunkCacheGroups.js");
78
+ ;// CONCATENATED MODULE: external "./addDataFetchExposes.js"
79
+ const external_addDataFetchExposes_js_namespaceObject = require("./addDataFetchExposes.js");
80
+ ;// CONCATENATED MODULE: external "./manifest.js"
81
+ const external_manifest_js_namespaceObject = require("./manifest.js");
82
+ ;// CONCATENATED MODULE: external "./ssr.js"
83
+ const external_ssr_js_namespaceObject = require("./ssr.js");
84
+ ;// CONCATENATED MODULE: ./src/utils/index.ts
85
+
86
+ function isRegExp(target) {
87
+ return external_util_default().types.isRegExp(target);
88
+ }
89
+
90
+
91
+
92
+
93
+
94
+
95
+ exports.DEFAULT_ASSET_PREFIX = __webpack_exports__.DEFAULT_ASSET_PREFIX;
96
+ exports.SSR_DIR = __webpack_exports__.SSR_DIR;
97
+ exports.SSR_ENV_NAME = __webpack_exports__.SSR_ENV_NAME;
98
+ exports.addDataFetchExposes = __webpack_exports__.addDataFetchExposes;
99
+ exports.autoDeleteSplitChunkCacheGroups = __webpack_exports__.autoDeleteSplitChunkCacheGroups;
100
+ exports.createSSRMFConfig = __webpack_exports__.createSSRMFConfig;
101
+ exports.createSSRREnvConfig = __webpack_exports__.createSSRREnvConfig;
102
+ exports.isRegExp = __webpack_exports__.isRegExp;
103
+ exports.patchSSRRspackConfig = __webpack_exports__.patchSSRRspackConfig;
104
+ exports.setSSREnv = __webpack_exports__.setSSREnv;
105
+ exports.updateStatsAndManifest = __webpack_exports__.updateStatsAndManifest;
106
+ for(var __rspack_i in __webpack_exports__) {
107
+ if(["DEFAULT_ASSET_PREFIX","SSR_DIR","SSR_ENV_NAME","addDataFetchExposes","autoDeleteSplitChunkCacheGroups","createSSRMFConfig","createSSRREnvConfig","isRegExp","patchSSRRspackConfig","setSSREnv","updateStatsAndManifest"].indexOf(__rspack_i) === -1) {
108
+ exports[__rspack_i] = __webpack_exports__[__rspack_i];
109
+ }
110
+ }
111
+ Object.defineProperty(exports, '__esModule', { value: true });
@@ -0,0 +1,24 @@
1
+ import util from "util";
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+ function isRegExp(target) {
11
+ return util.types.isRegExp(target);
12
+ }
13
+
14
+
15
+
16
+
17
+
18
+
19
+ export { isRegExp };
20
+ export { DEFAULT_ASSET_PREFIX } from "../constant.mjs";
21
+ export { autoDeleteSplitChunkCacheGroups } from "./autoDeleteSplitChunkCacheGroups.mjs";
22
+ export { addDataFetchExposes } from "./addDataFetchExposes.mjs";
23
+ export { updateStatsAndManifest } from "./manifest.mjs";
24
+ export { SSR_DIR, SSR_ENV_NAME, createSSRMFConfig, createSSRREnvConfig, patchSSRRspackConfig, setSSREnv } from "./ssr.mjs";
@@ -0,0 +1,115 @@
1
+ "use strict";
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;
7
+ })();
8
+ ;
9
+ // The require scope
10
+ var __webpack_require__ = {};
11
+
12
+ // webpack/runtime/compat_get_default_export
13
+ (() => {
14
+ // getDefaultExport function for compatibility with non-ESM modules
15
+ __webpack_require__.n = (module) => {
16
+ var getter = module && module.__esModule ?
17
+ () => (module['default']) :
18
+ () => (module);
19
+ __webpack_require__.d(getter, { a: getter });
20
+ return getter;
21
+ };
22
+
23
+ })();
24
+ // webpack/runtime/define_property_getters
25
+ (() => {
26
+ __webpack_require__.d = (exports, getters, values) => {
27
+ var define = (defs, kind) => {
28
+ for(var key in defs) {
29
+ if(__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) {
30
+ Object.defineProperty(exports, key, { enumerable: true, [kind]: defs[key] });
31
+ }
32
+ }
33
+ };
34
+ define(getters, "get");
35
+ define(values, "value");
36
+ };
37
+ })();
38
+ // webpack/runtime/has_own_property
39
+ (() => {
40
+ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
41
+ })();
42
+ // webpack/runtime/make_namespace_object
43
+ (() => {
44
+ // define __esModule on exports
45
+ __webpack_require__.r = (exports) => {
46
+ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
47
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
48
+ }
49
+ Object.defineProperty(exports, '__esModule', { value: true });
50
+ };
51
+ })();
52
+ var __webpack_exports__ = {};
53
+ // ESM COMPAT FLAG
54
+ __webpack_require__.r(__webpack_exports__);
55
+
56
+ // EXPORTS
57
+ __webpack_require__.d(__webpack_exports__, {
58
+ updateStatsAndManifest: () => (/* binding */ updateStatsAndManifest)
59
+ });
60
+
61
+ ;// CONCATENATED MODULE: external "path"
62
+ const external_path_namespaceObject = require("path");
63
+ var external_path_default = /*#__PURE__*/__webpack_require__.n(external_path_namespaceObject);
64
+ ;// CONCATENATED MODULE: external "fs"
65
+ const external_fs_namespaceObject = require("fs");
66
+ var external_fs_default = /*#__PURE__*/__webpack_require__.n(external_fs_namespaceObject);
67
+ ;// CONCATENATED MODULE: ./src/utils/manifest.ts
68
+
69
+
70
+ function mergeStats(browserStats, nodeStats) {
71
+ const ssrRemoteEntry = nodeStats.metaData.remoteEntry;
72
+ browserStats.metaData.ssrRemoteEntry = ssrRemoteEntry;
73
+ if ('publicPath' in browserStats.metaData) {
74
+ // @ts-ignore nodeStats has the same structure with browserStats
75
+ browserStats.metaData.ssrPublicPath = nodeStats.metaData.publicPath;
76
+ }
77
+ return browserStats;
78
+ }
79
+ function mergeManifest(browserManifest, nodeManifest) {
80
+ const ssrRemoteEntry = nodeManifest.metaData.remoteEntry;
81
+ browserManifest.metaData.ssrRemoteEntry = ssrRemoteEntry;
82
+ if ('publicPath' in browserManifest.metaData) {
83
+ // @ts-ignore nodeStats has the same structure with browserStats
84
+ browserManifest.metaData.ssrPublicPath = nodeManifest.metaData.publicPath;
85
+ }
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) {
92
+ throw new Error('Failed to read stats or manifest assets for merge');
93
+ }
94
+ const mergedStats = mergeStats(browserStats.data, nodeStats.data);
95
+ const mergedManifest = mergeManifest(browserManifest.data, nodeManifest.data);
96
+ return {
97
+ mergedStats: mergedStats,
98
+ mergedStatsFilePath: browserStats.filename,
99
+ mergedManifest: mergedManifest,
100
+ mergedManifestFilePath: browserManifest.filename
101
+ };
102
+ }
103
+ function updateStatsAndManifest(nodeAssets, browserAssets, outputDir) {
104
+ const { mergedStats, mergedStatsFilePath, mergedManifest, mergedManifestFilePath } = mergeStatsAndManifest(nodeAssets, browserAssets);
105
+ external_fs_default().writeFileSync(external_path_default().resolve(outputDir, mergedStatsFilePath), JSON.stringify(mergedStats, null, 2));
106
+ external_fs_default().writeFileSync(external_path_default().resolve(outputDir, mergedManifestFilePath), JSON.stringify(mergedManifest, null, 2));
107
+ }
108
+
109
+ exports.updateStatsAndManifest = __webpack_exports__.updateStatsAndManifest;
110
+ for(var __rspack_i in __webpack_exports__) {
111
+ if(["updateStatsAndManifest"].indexOf(__rspack_i) === -1) {
112
+ exports[__rspack_i] = __webpack_exports__[__rspack_i];
113
+ }
114
+ }
115
+ Object.defineProperty(exports, '__esModule', { value: true });
@@ -0,0 +1,47 @@
1
+ import path from "path";
2
+ import fs from "fs";
3
+
4
+
5
+
6
+
7
+
8
+ function mergeStats(browserStats, nodeStats) {
9
+ const ssrRemoteEntry = nodeStats.metaData.remoteEntry;
10
+ browserStats.metaData.ssrRemoteEntry = ssrRemoteEntry;
11
+ if ('publicPath' in browserStats.metaData) {
12
+ // @ts-ignore nodeStats has the same structure with browserStats
13
+ browserStats.metaData.ssrPublicPath = nodeStats.metaData.publicPath;
14
+ }
15
+ return browserStats;
16
+ }
17
+ function mergeManifest(browserManifest, nodeManifest) {
18
+ const ssrRemoteEntry = nodeManifest.metaData.remoteEntry;
19
+ browserManifest.metaData.ssrRemoteEntry = ssrRemoteEntry;
20
+ if ('publicPath' in browserManifest.metaData) {
21
+ // @ts-ignore nodeStats has the same structure with browserStats
22
+ browserManifest.metaData.ssrPublicPath = nodeManifest.metaData.publicPath;
23
+ }
24
+ return browserManifest;
25
+ }
26
+ function mergeStatsAndManifest(nodeAssets, browserAssets) {
27
+ const { stats: browserStats, manifest: browserManifest } = browserAssets;
28
+ const { stats: nodeStats, manifest: nodeManifest } = nodeAssets;
29
+ if (!browserStats || !nodeStats || !browserManifest || !nodeManifest) {
30
+ throw new Error('Failed to read stats or manifest assets for merge');
31
+ }
32
+ const mergedStats = mergeStats(browserStats.data, nodeStats.data);
33
+ const mergedManifest = mergeManifest(browserManifest.data, nodeManifest.data);
34
+ return {
35
+ mergedStats: mergedStats,
36
+ mergedStatsFilePath: browserStats.filename,
37
+ mergedManifest: mergedManifest,
38
+ mergedManifestFilePath: browserManifest.filename
39
+ };
40
+ }
41
+ function updateStatsAndManifest(nodeAssets, browserAssets, outputDir) {
42
+ const { mergedStats, mergedStatsFilePath, mergedManifest, mergedManifestFilePath } = mergeStatsAndManifest(nodeAssets, browserAssets);
43
+ fs.writeFileSync(path.resolve(outputDir, mergedStatsFilePath), JSON.stringify(mergedStats, null, 2));
44
+ fs.writeFileSync(path.resolve(outputDir, mergedManifestFilePath), JSON.stringify(mergedManifest, null, 2));
45
+ }
46
+
47
+ export { updateStatsAndManifest };
@@ -1,24 +1,20 @@
1
- import type { EnvironmentConfig, RsbuildConfig, Rspack } from '@rsbuild/core';
1
+ import type { EnvironmentConfig, RsbuildConfig, Rspack, EnvironmentContext } from '@rsbuild/core';
2
2
  import type { moduleFederationPlugin } from '@module-federation/sdk';
3
3
  export declare const SSR_DIR = "ssr";
4
4
  export declare const SSR_ENV_NAME = "mf-ssr";
5
+ export declare const ENV_NAME = "mf";
5
6
  export declare function setSSREnv(): void;
7
+ export declare function patchNodeConfig(config: Rspack.Configuration, mfConfig: moduleFederationPlugin.ModuleFederationPluginOptions): void;
6
8
  export declare function patchSSRRspackConfig(config: Rspack.Configuration, mfConfig: moduleFederationPlugin.ModuleFederationPluginOptions, ssrDir: string, callerName?: string, resetEntry?: boolean, modifyPublicPath?: boolean): Rspack.RspackOptions;
9
+ export declare function patchToolsTspack(envConfig: EnvironmentConfig, fn: (config: Rspack.RspackOptions, { environment }: {
10
+ environment: EnvironmentContext;
11
+ }) => void): void;
7
12
  export declare function createSSRREnvConfig(envConfig: EnvironmentConfig, mfConfig: moduleFederationPlugin.ModuleFederationPluginOptions, ssrDir: string, rsbuildConfig: RsbuildConfig, callerName?: string): EnvironmentConfig;
13
+ export declare function patchNodeMFConfig(mfConfig: moduleFederationPlugin.ModuleFederationPluginOptions): void;
8
14
  export declare function createSSRMFConfig(mfConfig: moduleFederationPlugin.ModuleFederationPluginOptions): {
9
- exposes: {};
10
- library: {
11
- name: string | undefined;
12
- type: string;
13
- amdContainer?: moduleFederationPlugin.AmdContainer;
14
- auxiliaryComment?: moduleFederationPlugin.AuxiliaryComment;
15
- export?: moduleFederationPlugin.LibraryExport;
16
- umdNamedDefine?: moduleFederationPlugin.UmdNamedDefine;
17
- };
18
- dts: boolean;
19
- dev: boolean;
20
- runtimePlugins: (string | [string, Record<string, unknown>])[];
15
+ exposes?: moduleFederationPlugin.Exposes;
21
16
  filename?: string;
17
+ library?: moduleFederationPlugin.LibraryOptions;
22
18
  name?: string;
23
19
  remoteType?: moduleFederationPlugin.ExternalsType;
24
20
  remotes?: moduleFederationPlugin.Remotes;
@@ -26,10 +22,12 @@ export declare function createSSRMFConfig(mfConfig: moduleFederationPlugin.Modul
26
22
  shareScope?: string | string[];
27
23
  shareStrategy?: moduleFederationPlugin.SharedStrategy;
28
24
  shared?: moduleFederationPlugin.Shared;
25
+ runtimePlugins?: (string | [string, Record<string, unknown>])[];
29
26
  getPublicPath?: string;
30
27
  implementation?: string;
31
28
  manifest?: boolean | moduleFederationPlugin.PluginManifestOptions;
32
- dataPrefetch?: moduleFederationPlugin.DataPrefetch;
29
+ dev?: boolean | moduleFederationPlugin.PluginDevOptions;
30
+ dts?: boolean | moduleFederationPlugin.PluginDtsOptions;
33
31
  virtualRuntimeEntry?: boolean;
34
32
  experiments?: {
35
33
  externalRuntime?: boolean;
@@ -37,7 +35,9 @@ export declare function createSSRMFConfig(mfConfig: moduleFederationPlugin.Modul
37
35
  asyncStartup?: boolean;
38
36
  optimization?: {
39
37
  disableSnapshot?: boolean;
40
- target?: "web" | "node";
38
+ disableRemote?: boolean;
39
+ disableShared?: boolean;
40
+ target?: 'web' | 'node';
41
41
  };
42
42
  };
43
43
  bridge?: {
@@ -45,4 +45,8 @@ export declare function createSSRMFConfig(mfConfig: moduleFederationPlugin.Modul
45
45
  disableAlias?: boolean;
46
46
  };
47
47
  async?: boolean | moduleFederationPlugin.AsyncBoundaryOptions;
48
+ treeShakingDir?: string;
49
+ injectTreeShakingUsedExports?: boolean;
50
+ treeShakingSharedExcludePlugins?: string[];
51
+ treeShakingSharedPlugins?: string[];
48
52
  };