@module-federation/rsbuild-plugin 2.5.1 → 2.7.0

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.
@@ -9,7 +9,6 @@ const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
9
9
  // The require scope
10
10
  var __webpack_require__ = {};
11
11
 
12
- /************************************************************************/
13
12
  // webpack/runtime/compat_get_default_export
14
13
  (() => {
15
14
  // getDefaultExport function for compatibility with non-ESM modules
@@ -24,12 +23,16 @@ __webpack_require__.n = (module) => {
24
23
  })();
25
24
  // webpack/runtime/define_property_getters
26
25
  (() => {
27
- __webpack_require__.d = (exports, definition) => {
28
- for(var key in definition) {
29
- if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
30
- Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
31
- }
32
- }
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");
33
36
  };
34
37
  })();
35
38
  // webpack/runtime/has_own_property
@@ -46,7 +49,6 @@ __webpack_require__.r = (exports) => {
46
49
  Object.defineProperty(exports, '__esModule', { value: true });
47
50
  };
48
51
  })();
49
- /************************************************************************/
50
52
  var __webpack_exports__ = {};
51
53
  // ESM COMPAT FLAG
52
54
  __webpack_require__.r(__webpack_exports__);
@@ -120,9 +122,9 @@ function addDataFetchExposes(exposes, isServer) {
120
122
  }
121
123
 
122
124
  exports.addDataFetchExposes = __webpack_exports__.addDataFetchExposes;
123
- for(var __webpack_i__ in __webpack_exports__) {
124
- if(["addDataFetchExposes"].indexOf(__webpack_i__) === -1) {
125
- exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
125
+ for(var __rspack_i in __webpack_exports__) {
126
+ if(["addDataFetchExposes"].indexOf(__rspack_i) === -1) {
127
+ exports[__rspack_i] = __webpack_exports__[__rspack_i];
126
128
  }
127
129
  }
128
130
  Object.defineProperty(exports, '__esModule', { value: true });
@@ -3,15 +3,10 @@ import path from "path";
3
3
  import { TEMP_DIR } from "@module-federation/sdk";
4
4
  import { DATA_FETCH_CLIENT_SUFFIX, DATA_FETCH_IDENTIFIER } from "../constant.mjs";
5
5
 
6
- ;// CONCATENATED MODULE: external "fs"
7
6
 
8
- ;// CONCATENATED MODULE: external "path"
9
7
 
10
- ;// CONCATENATED MODULE: external "@module-federation/sdk"
11
8
 
12
- ;// CONCATENATED MODULE: external "../constant.mjs"
13
9
 
14
- ;// CONCATENATED MODULE: ./src/utils/addDataFetchExposes.ts
15
10
 
16
11
 
17
12
 
@@ -9,15 +9,18 @@ const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
9
9
  // The require scope
10
10
  var __webpack_require__ = {};
11
11
 
12
- /************************************************************************/
13
12
  // webpack/runtime/define_property_getters
14
13
  (() => {
15
- __webpack_require__.d = (exports, definition) => {
16
- for(var key in definition) {
17
- if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
18
- Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
19
- }
20
- }
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");
21
24
  };
22
25
  })();
23
26
  // webpack/runtime/has_own_property
@@ -34,12 +37,8 @@ __webpack_require__.r = (exports) => {
34
37
  Object.defineProperty(exports, '__esModule', { value: true });
35
38
  };
36
39
  })();
37
- /************************************************************************/
38
40
  var __webpack_exports__ = {};
39
41
  __webpack_require__.r(__webpack_exports__);
40
- __webpack_require__.d(__webpack_exports__, {
41
- autoDeleteSplitChunkCacheGroups: () => (autoDeleteSplitChunkCacheGroups)
42
- });
43
42
  // lib-polyfill.js: include core-js,@babel/runtime,@swc/helpers,tslib.
44
43
  // lib-react.js: include react,react-dom.
45
44
  // lib-router.js: include react-router,react-router-dom,history,@remix-run/router.
@@ -74,7 +73,7 @@ function autoDeleteSplitChunkCacheGroups(mfConfig, splitChunks) {
74
73
  if (!mfConfig.shared) {
75
74
  return;
76
75
  }
77
- if (!splitChunks || !(splitChunks === null || splitChunks === void 0 ? void 0 : splitChunks.cacheGroups)) {
76
+ if (!splitChunks || !splitChunks?.cacheGroups) {
78
77
  return;
79
78
  }
80
79
  const arrayShared = Array.isArray(mfConfig.shared) ? mfConfig.shared : Object.keys(mfConfig.shared);
@@ -90,10 +89,14 @@ function autoDeleteSplitChunkCacheGroups(mfConfig, splitChunks) {
90
89
  return splitChunks;
91
90
  }
92
91
 
92
+ __webpack_require__.d(__webpack_exports__, {
93
+ autoDeleteSplitChunkCacheGroups: () => (autoDeleteSplitChunkCacheGroups)
94
+ });
95
+
93
96
  exports.autoDeleteSplitChunkCacheGroups = __webpack_exports__.autoDeleteSplitChunkCacheGroups;
94
- for(var __webpack_i__ in __webpack_exports__) {
95
- if(["autoDeleteSplitChunkCacheGroups"].indexOf(__webpack_i__) === -1) {
96
- exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
97
+ for(var __rspack_i in __webpack_exports__) {
98
+ if(["autoDeleteSplitChunkCacheGroups"].indexOf(__rspack_i) === -1) {
99
+ exports[__rspack_i] = __webpack_exports__[__rspack_i];
97
100
  }
98
101
  }
99
102
  Object.defineProperty(exports, '__esModule', { value: true });
@@ -1,5 +1,3 @@
1
-
2
- ;// CONCATENATED MODULE: ./src/utils/autoDeleteSplitChunkCacheGroups.ts
3
1
  // lib-polyfill.js: include core-js,@babel/runtime,@swc/helpers,tslib.
4
2
  // lib-react.js: include react,react-dom.
5
3
  // lib-router.js: include react-router,react-router-dom,history,@remix-run/router.
@@ -34,7 +32,7 @@ function autoDeleteSplitChunkCacheGroups(mfConfig, splitChunks) {
34
32
  if (!mfConfig.shared) {
35
33
  return;
36
34
  }
37
- if (!splitChunks || !(splitChunks === null || splitChunks === void 0 ? void 0 : splitChunks.cacheGroups)) {
35
+ if (!splitChunks || !splitChunks?.cacheGroups) {
38
36
  return;
39
37
  }
40
38
  const arrayShared = Array.isArray(mfConfig.shared) ? mfConfig.shared : Object.keys(mfConfig.shared);
@@ -9,7 +9,6 @@ const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
9
9
  // The require scope
10
10
  var __webpack_require__ = {};
11
11
 
12
- /************************************************************************/
13
12
  // webpack/runtime/compat_get_default_export
14
13
  (() => {
15
14
  // getDefaultExport function for compatibility with non-ESM modules
@@ -24,12 +23,16 @@ __webpack_require__.n = (module) => {
24
23
  })();
25
24
  // webpack/runtime/define_property_getters
26
25
  (() => {
27
- __webpack_require__.d = (exports, definition) => {
28
- for(var key in definition) {
29
- if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
30
- Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
31
- }
32
- }
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");
33
36
  };
34
37
  })();
35
38
  // webpack/runtime/has_own_property
@@ -46,24 +49,23 @@ __webpack_require__.r = (exports) => {
46
49
  Object.defineProperty(exports, '__esModule', { value: true });
47
50
  };
48
51
  })();
49
- /************************************************************************/
50
52
  var __webpack_exports__ = {};
51
53
  // ESM COMPAT FLAG
52
54
  __webpack_require__.r(__webpack_exports__);
53
55
 
54
56
  // EXPORTS
55
57
  __webpack_require__.d(__webpack_exports__, {
56
- createSSRREnvConfig: () => (/* reexport */ external_ssr_js_namespaceObject.createSSRREnvConfig),
57
58
  DEFAULT_ASSET_PREFIX: () => (/* reexport */ external_constant_js_namespaceObject.DEFAULT_ASSET_PREFIX),
59
+ SSR_DIR: () => (/* reexport */ external_ssr_js_namespaceObject.SSR_DIR),
58
60
  SSR_ENV_NAME: () => (/* reexport */ external_ssr_js_namespaceObject.SSR_ENV_NAME),
61
+ addDataFetchExposes: () => (/* reexport */ external_addDataFetchExposes_js_namespaceObject.addDataFetchExposes),
59
62
  autoDeleteSplitChunkCacheGroups: () => (/* reexport */ external_autoDeleteSplitChunkCacheGroups_js_namespaceObject.autoDeleteSplitChunkCacheGroups),
60
- setSSREnv: () => (/* reexport */ external_ssr_js_namespaceObject.setSSREnv),
61
- updateStatsAndManifest: () => (/* reexport */ external_manifest_js_namespaceObject.updateStatsAndManifest),
63
+ createSSRMFConfig: () => (/* reexport */ external_ssr_js_namespaceObject.createSSRMFConfig),
64
+ createSSRREnvConfig: () => (/* reexport */ external_ssr_js_namespaceObject.createSSRREnvConfig),
62
65
  isRegExp: () => (/* binding */ isRegExp),
63
66
  patchSSRRspackConfig: () => (/* reexport */ external_ssr_js_namespaceObject.patchSSRRspackConfig),
64
- SSR_DIR: () => (/* reexport */ external_ssr_js_namespaceObject.SSR_DIR),
65
- createSSRMFConfig: () => (/* reexport */ external_ssr_js_namespaceObject.createSSRMFConfig),
66
- addDataFetchExposes: () => (/* reexport */ external_addDataFetchExposes_js_namespaceObject.addDataFetchExposes)
67
+ setSSREnv: () => (/* reexport */ external_ssr_js_namespaceObject.setSSREnv),
68
+ updateStatsAndManifest: () => (/* reexport */ external_manifest_js_namespaceObject.updateStatsAndManifest)
67
69
  });
68
70
 
69
71
  ;// CONCATENATED MODULE: external "util"
@@ -101,9 +103,9 @@ exports.isRegExp = __webpack_exports__.isRegExp;
101
103
  exports.patchSSRRspackConfig = __webpack_exports__.patchSSRRspackConfig;
102
104
  exports.setSSREnv = __webpack_exports__.setSSREnv;
103
105
  exports.updateStatsAndManifest = __webpack_exports__.updateStatsAndManifest;
104
- for(var __webpack_i__ in __webpack_exports__) {
105
- if(["DEFAULT_ASSET_PREFIX","SSR_DIR","SSR_ENV_NAME","addDataFetchExposes","autoDeleteSplitChunkCacheGroups","createSSRMFConfig","createSSRREnvConfig","isRegExp","patchSSRRspackConfig","setSSREnv","updateStatsAndManifest"].indexOf(__webpack_i__) === -1) {
106
- exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
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];
107
109
  }
108
110
  }
109
111
  Object.defineProperty(exports, '__esModule', { value: true });
@@ -1,23 +1,11 @@
1
1
  import util from "util";
2
- import { DEFAULT_ASSET_PREFIX } from "../constant.mjs";
3
- import { autoDeleteSplitChunkCacheGroups } from "./autoDeleteSplitChunkCacheGroups.mjs";
4
- import { addDataFetchExposes } from "./addDataFetchExposes.mjs";
5
- import { updateStatsAndManifest } from "./manifest.mjs";
6
- import { SSR_DIR, SSR_ENV_NAME, createSSRMFConfig, createSSRREnvConfig, patchSSRRspackConfig, setSSREnv } from "./ssr.mjs";
7
2
 
8
- ;// CONCATENATED MODULE: external "util"
9
3
 
10
- ;// CONCATENATED MODULE: external "../constant.mjs"
11
4
 
12
- ;// CONCATENATED MODULE: external "./autoDeleteSplitChunkCacheGroups.mjs"
13
5
 
14
- ;// CONCATENATED MODULE: external "./addDataFetchExposes.mjs"
15
6
 
16
- ;// CONCATENATED MODULE: external "./manifest.mjs"
17
7
 
18
- ;// CONCATENATED MODULE: external "./ssr.mjs"
19
8
 
20
- ;// CONCATENATED MODULE: ./src/utils/index.ts
21
9
 
22
10
  function isRegExp(target) {
23
11
  return util.types.isRegExp(target);
@@ -28,4 +16,9 @@ function isRegExp(target) {
28
16
 
29
17
 
30
18
 
31
- export { DEFAULT_ASSET_PREFIX, SSR_DIR, SSR_ENV_NAME, addDataFetchExposes, autoDeleteSplitChunkCacheGroups, createSSRMFConfig, createSSRREnvConfig, isRegExp, patchSSRRspackConfig, setSSREnv, updateStatsAndManifest };
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";
@@ -9,7 +9,6 @@ const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
9
9
  // The require scope
10
10
  var __webpack_require__ = {};
11
11
 
12
- /************************************************************************/
13
12
  // webpack/runtime/compat_get_default_export
14
13
  (() => {
15
14
  // getDefaultExport function for compatibility with non-ESM modules
@@ -24,12 +23,16 @@ __webpack_require__.n = (module) => {
24
23
  })();
25
24
  // webpack/runtime/define_property_getters
26
25
  (() => {
27
- __webpack_require__.d = (exports, definition) => {
28
- for(var key in definition) {
29
- if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
30
- Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
31
- }
32
- }
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");
33
36
  };
34
37
  })();
35
38
  // webpack/runtime/has_own_property
@@ -46,7 +49,6 @@ __webpack_require__.r = (exports) => {
46
49
  Object.defineProperty(exports, '__esModule', { value: true });
47
50
  };
48
51
  })();
49
- /************************************************************************/
50
52
  var __webpack_exports__ = {};
51
53
  // ESM COMPAT FLAG
52
54
  __webpack_require__.r(__webpack_exports__);
@@ -105,9 +107,9 @@ function updateStatsAndManifest(nodeAssets, browserAssets, outputDir) {
105
107
  }
106
108
 
107
109
  exports.updateStatsAndManifest = __webpack_exports__.updateStatsAndManifest;
108
- for(var __webpack_i__ in __webpack_exports__) {
109
- if(["updateStatsAndManifest"].indexOf(__webpack_i__) === -1) {
110
- exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
110
+ for(var __rspack_i in __webpack_exports__) {
111
+ if(["updateStatsAndManifest"].indexOf(__rspack_i) === -1) {
112
+ exports[__rspack_i] = __webpack_exports__[__rspack_i];
111
113
  }
112
114
  }
113
115
  Object.defineProperty(exports, '__esModule', { value: true });
@@ -1,11 +1,8 @@
1
1
  import path from "path";
2
2
  import fs from "fs";
3
3
 
4
- ;// CONCATENATED MODULE: external "path"
5
4
 
6
- ;// CONCATENATED MODULE: external "fs"
7
5
 
8
- ;// CONCATENATED MODULE: ./src/utils/manifest.ts
9
6
 
10
7
 
11
8
  function mergeStats(browserStats, nodeStats) {
package/dist/utils/ssr.js CHANGED
@@ -9,7 +9,6 @@ const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
9
9
  // The require scope
10
10
  var __webpack_require__ = {};
11
11
 
12
- /************************************************************************/
13
12
  // webpack/runtime/compat_get_default_export
14
13
  (() => {
15
14
  // getDefaultExport function for compatibility with non-ESM modules
@@ -24,12 +23,16 @@ __webpack_require__.n = (module) => {
24
23
  })();
25
24
  // webpack/runtime/define_property_getters
26
25
  (() => {
27
- __webpack_require__.d = (exports, definition) => {
28
- for(var key in definition) {
29
- if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
30
- Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
31
- }
32
- }
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");
33
36
  };
34
37
  })();
35
38
  // webpack/runtime/has_own_property
@@ -46,23 +49,22 @@ __webpack_require__.r = (exports) => {
46
49
  Object.defineProperty(exports, '__esModule', { value: true });
47
50
  };
48
51
  })();
49
- /************************************************************************/
50
52
  var __webpack_exports__ = {};
51
53
  // ESM COMPAT FLAG
52
54
  __webpack_require__.r(__webpack_exports__);
53
55
 
54
56
  // EXPORTS
55
57
  __webpack_require__.d(__webpack_exports__, {
56
- patchNodeConfig: () => (/* binding */ patchNodeConfig),
58
+ ENV_NAME: () => (/* binding */ ENV_NAME),
59
+ SSR_DIR: () => (/* binding */ SSR_DIR),
60
+ SSR_ENV_NAME: () => (/* binding */ SSR_ENV_NAME),
61
+ createSSRMFConfig: () => (/* binding */ createSSRMFConfig),
57
62
  createSSRREnvConfig: () => (/* binding */ createSSRREnvConfig),
58
- setSSREnv: () => (/* binding */ setSSREnv),
63
+ patchNodeConfig: () => (/* binding */ patchNodeConfig),
59
64
  patchNodeMFConfig: () => (/* binding */ patchNodeMFConfig),
60
- SSR_ENV_NAME: () => (/* binding */ SSR_ENV_NAME),
61
- patchToolsTspack: () => (/* binding */ patchToolsTspack),
62
65
  patchSSRRspackConfig: () => (/* binding */ patchSSRRspackConfig),
63
- SSR_DIR: () => (/* binding */ SSR_DIR),
64
- ENV_NAME: () => (/* binding */ ENV_NAME),
65
- createSSRMFConfig: () => (/* binding */ createSSRMFConfig)
66
+ patchToolsTspack: () => (/* binding */ patchToolsTspack),
67
+ setSSREnv: () => (/* binding */ setSSREnv)
66
68
  });
67
69
 
68
70
  ;// CONCATENATED MODULE: external "path"
@@ -105,7 +107,6 @@ const isDev = ()=>{
105
107
  return process.env['NODE_ENV'] === 'development';
106
108
  };
107
109
  function patchNodeConfig(config, mfConfig) {
108
- var _config_output;
109
110
  config.output ||= {};
110
111
  if (config.output.publicPath === 'auto') {
111
112
  config.output.publicPath = '';
@@ -118,12 +119,12 @@ function patchNodeConfig(config, mfConfig) {
118
119
  config.output.chunkLoading = 'async-node';
119
120
  delete config.output.chunkLoadingGlobal;
120
121
  const UniverseEntryChunkTrackerPluginModule = safeRequire('@module-federation/node/universe-entry-chunk-tracker-plugin');
121
- const UniverseEntryChunkTrackerPlugin = UniverseEntryChunkTrackerPluginModule === null || UniverseEntryChunkTrackerPluginModule === void 0 ? void 0 : UniverseEntryChunkTrackerPluginModule.default;
122
+ const UniverseEntryChunkTrackerPlugin = UniverseEntryChunkTrackerPluginModule?.default;
122
123
  config.plugins ||= [];
123
124
  if (isDev() && UniverseEntryChunkTrackerPlugin) {
124
125
  config.plugins.push(new UniverseEntryChunkTrackerPlugin());
125
126
  }
126
- const uniqueName = mfConfig.name || ((_config_output = config.output) === null || _config_output === void 0 ? void 0 : _config_output.uniqueName);
127
+ const uniqueName = mfConfig.name || config.output?.uniqueName;
127
128
  const chunkFileName = config.output.chunkFilename;
128
129
  if (typeof chunkFileName === 'string' && uniqueName && !chunkFileName.includes(uniqueName)) {
129
130
  const encodedName = (0,sdk_namespaceObject.encodeName)(uniqueName);
@@ -133,8 +134,7 @@ function patchNodeConfig(config, mfConfig) {
133
134
  function patchSSRRspackConfig(config, mfConfig, ssrDir, callerName, resetEntry = true, modifyPublicPath = true) {
134
135
  config.output ||= {};
135
136
  if (modifyPublicPath) {
136
- var _config_output;
137
- if (typeof ((_config_output = config.output) === null || _config_output === void 0 ? void 0 : _config_output.publicPath) !== 'string') {
137
+ if (typeof config.output?.publicPath !== 'string') {
138
138
  throw new Error('publicPath must be string!');
139
139
  }
140
140
  const publicPath = config.output.publicPath;
@@ -151,16 +151,12 @@ function patchSSRRspackConfig(config, mfConfig, ssrDir, callerName, resetEntry =
151
151
  return config;
152
152
  }
153
153
  function patchToolsTspack(envConfig, fn) {
154
- var _envConfig_tools;
155
154
  const rspackArr = [];
156
- if ((_envConfig_tools = envConfig.tools) === null || _envConfig_tools === void 0 ? void 0 : _envConfig_tools.rspack) {
157
- var _envConfig_tools1, _envConfig_tools2;
158
- if (Array.isArray((_envConfig_tools1 = envConfig.tools) === null || _envConfig_tools1 === void 0 ? void 0 : _envConfig_tools1.rspack)) {
159
- var _envConfig_tools3;
160
- rspackArr.push(...(_envConfig_tools3 = envConfig.tools) === null || _envConfig_tools3 === void 0 ? void 0 : _envConfig_tools3.rspack);
161
- } else if (typeof ((_envConfig_tools2 = envConfig.tools) === null || _envConfig_tools2 === void 0 ? void 0 : _envConfig_tools2.rspack) === 'function') {
162
- var _envConfig_tools4;
163
- rspackArr.push((_envConfig_tools4 = envConfig.tools) === null || _envConfig_tools4 === void 0 ? void 0 : _envConfig_tools4.rspack);
155
+ if (envConfig.tools?.rspack) {
156
+ if (Array.isArray(envConfig.tools?.rspack)) {
157
+ rspackArr.push(...envConfig.tools?.rspack);
158
+ } else if (typeof envConfig.tools?.rspack === 'function') {
159
+ rspackArr.push(envConfig.tools?.rspack);
164
160
  }
165
161
  }
166
162
  envConfig.tools ||= {};
@@ -170,16 +166,12 @@ function patchToolsTspack(envConfig, fn) {
170
166
  ];
171
167
  }
172
168
  function createSSRREnvConfig(envConfig, mfConfig, ssrDir, rsbuildConfig, callerName) {
173
- var _envConfig_tools, _ssrEnvConfig_output, _ssrEnvConfig_output_distPath, _ssrEnvConfig_output1, _rsbuildConfig_output_distPath, _rsbuildConfig_output;
174
169
  const rspackArr = [];
175
- if ((_envConfig_tools = envConfig.tools) === null || _envConfig_tools === void 0 ? void 0 : _envConfig_tools.rspack) {
176
- var _envConfig_tools1, _envConfig_tools2;
177
- if (Array.isArray((_envConfig_tools1 = envConfig.tools) === null || _envConfig_tools1 === void 0 ? void 0 : _envConfig_tools1.rspack)) {
178
- var _envConfig_tools3;
179
- rspackArr.push(...(_envConfig_tools3 = envConfig.tools) === null || _envConfig_tools3 === void 0 ? void 0 : _envConfig_tools3.rspack);
180
- } else if (typeof ((_envConfig_tools2 = envConfig.tools) === null || _envConfig_tools2 === void 0 ? void 0 : _envConfig_tools2.rspack) === 'function') {
181
- var _envConfig_tools4;
182
- rspackArr.push((_envConfig_tools4 = envConfig.tools) === null || _envConfig_tools4 === void 0 ? void 0 : _envConfig_tools4.rspack);
170
+ if (envConfig.tools?.rspack) {
171
+ if (Array.isArray(envConfig.tools?.rspack)) {
172
+ rspackArr.push(...envConfig.tools?.rspack);
173
+ } else if (typeof envConfig.tools?.rspack === 'function') {
174
+ rspackArr.push(envConfig.tools?.rspack);
183
175
  }
184
176
  }
185
177
  const ssrEnvConfig = {
@@ -197,15 +189,14 @@ function createSSRREnvConfig(envConfig, mfConfig, ssrDir, rsbuildConfig, callerN
197
189
  // Rsbuild not support all rspack targets, so modify to async-node in modifyRspackConfig
198
190
  target: 'node',
199
191
  distPath: {
200
- ...(_ssrEnvConfig_output = ssrEnvConfig.output) === null || _ssrEnvConfig_output === void 0 ? void 0 : _ssrEnvConfig_output.distPath,
201
- root: external_path_default().join(((_ssrEnvConfig_output1 = ssrEnvConfig.output) === null || _ssrEnvConfig_output1 === void 0 ? void 0 : (_ssrEnvConfig_output_distPath = _ssrEnvConfig_output1.distPath) === null || _ssrEnvConfig_output_distPath === void 0 ? void 0 : _ssrEnvConfig_output_distPath.root) || ((_rsbuildConfig_output = rsbuildConfig.output) === null || _rsbuildConfig_output === void 0 ? void 0 : (_rsbuildConfig_output_distPath = _rsbuildConfig_output.distPath) === null || _rsbuildConfig_output_distPath === void 0 ? void 0 : _rsbuildConfig_output_distPath.root) || '', ssrDir)
192
+ ...ssrEnvConfig.output?.distPath,
193
+ root: external_path_default().join(ssrEnvConfig.output?.distPath?.root || rsbuildConfig.output?.distPath?.root || '', ssrDir)
202
194
  },
203
195
  emitAssets: true
204
196
  };
205
197
  return ssrEnvConfig;
206
198
  }
207
199
  function patchNodeMFConfig(mfConfig) {
208
- var _mfConfig_library;
209
200
  if (mfConfig.remotes) {
210
201
  mfConfig.remoteType = 'script';
211
202
  }
@@ -215,7 +206,7 @@ function patchNodeMFConfig(mfConfig) {
215
206
  mfConfig.library = {
216
207
  ...mfConfig.library,
217
208
  name: mfConfig.name,
218
- type: ((_mfConfig_library = mfConfig.library) === null || _mfConfig_library === void 0 ? void 0 : _mfConfig_library.type) ?? 'commonjs-module'
209
+ type: mfConfig.library?.type ?? 'commonjs-module'
219
210
  };
220
211
  mfConfig.runtimePlugins = [
221
212
  ...mfConfig.runtimePlugins || []
@@ -245,9 +236,9 @@ exports.patchNodeMFConfig = __webpack_exports__.patchNodeMFConfig;
245
236
  exports.patchSSRRspackConfig = __webpack_exports__.patchSSRRspackConfig;
246
237
  exports.patchToolsTspack = __webpack_exports__.patchToolsTspack;
247
238
  exports.setSSREnv = __webpack_exports__.setSSREnv;
248
- for(var __webpack_i__ in __webpack_exports__) {
249
- if(["ENV_NAME","SSR_DIR","SSR_ENV_NAME","createSSRMFConfig","createSSRREnvConfig","patchNodeConfig","patchNodeMFConfig","patchSSRRspackConfig","patchToolsTspack","setSSREnv"].indexOf(__webpack_i__) === -1) {
250
- exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
239
+ for(var __rspack_i in __webpack_exports__) {
240
+ if(["ENV_NAME","SSR_DIR","SSR_ENV_NAME","createSSRMFConfig","createSSRREnvConfig","patchNodeConfig","patchNodeMFConfig","patchSSRRspackConfig","patchToolsTspack","setSSREnv"].indexOf(__rspack_i) === -1) {
241
+ exports[__rspack_i] = __webpack_exports__[__rspack_i];
251
242
  }
252
243
  }
253
244
  Object.defineProperty(exports, '__esModule', { value: true });
@@ -3,15 +3,10 @@ import { createRequire } from "node:module";
3
3
  import { encodeName } from "@module-federation/sdk";
4
4
  import { CALL_NAME_MAP } from "../constant.mjs";
5
5
 
6
- ;// CONCATENATED MODULE: external "path"
7
6
 
8
- ;// CONCATENATED MODULE: external "node:module"
9
7
 
10
- ;// CONCATENATED MODULE: external "@module-federation/sdk"
11
8
 
12
- ;// CONCATENATED MODULE: external "../constant.mjs"
13
9
 
14
- ;// CONCATENATED MODULE: ./src/utils/ssr.ts
15
10
 
16
11
 
17
12
 
@@ -42,7 +37,6 @@ const isDev = ()=>{
42
37
  return process.env['NODE_ENV'] === 'development';
43
38
  };
44
39
  function patchNodeConfig(config, mfConfig) {
45
- var _config_output;
46
40
  config.output ||= {};
47
41
  if (config.output.publicPath === 'auto') {
48
42
  config.output.publicPath = '';
@@ -55,12 +49,12 @@ function patchNodeConfig(config, mfConfig) {
55
49
  config.output.chunkLoading = 'async-node';
56
50
  delete config.output.chunkLoadingGlobal;
57
51
  const UniverseEntryChunkTrackerPluginModule = safeRequire('@module-federation/node/universe-entry-chunk-tracker-plugin');
58
- const UniverseEntryChunkTrackerPlugin = UniverseEntryChunkTrackerPluginModule === null || UniverseEntryChunkTrackerPluginModule === void 0 ? void 0 : UniverseEntryChunkTrackerPluginModule.default;
52
+ const UniverseEntryChunkTrackerPlugin = UniverseEntryChunkTrackerPluginModule?.default;
59
53
  config.plugins ||= [];
60
54
  if (isDev() && UniverseEntryChunkTrackerPlugin) {
61
55
  config.plugins.push(new UniverseEntryChunkTrackerPlugin());
62
56
  }
63
- const uniqueName = mfConfig.name || ((_config_output = config.output) === null || _config_output === void 0 ? void 0 : _config_output.uniqueName);
57
+ const uniqueName = mfConfig.name || config.output?.uniqueName;
64
58
  const chunkFileName = config.output.chunkFilename;
65
59
  if (typeof chunkFileName === 'string' && uniqueName && !chunkFileName.includes(uniqueName)) {
66
60
  const encodedName = encodeName(uniqueName);
@@ -70,8 +64,7 @@ function patchNodeConfig(config, mfConfig) {
70
64
  function patchSSRRspackConfig(config, mfConfig, ssrDir, callerName, resetEntry = true, modifyPublicPath = true) {
71
65
  config.output ||= {};
72
66
  if (modifyPublicPath) {
73
- var _config_output;
74
- if (typeof ((_config_output = config.output) === null || _config_output === void 0 ? void 0 : _config_output.publicPath) !== 'string') {
67
+ if (typeof config.output?.publicPath !== 'string') {
75
68
  throw new Error('publicPath must be string!');
76
69
  }
77
70
  const publicPath = config.output.publicPath;
@@ -88,16 +81,12 @@ function patchSSRRspackConfig(config, mfConfig, ssrDir, callerName, resetEntry =
88
81
  return config;
89
82
  }
90
83
  function patchToolsTspack(envConfig, fn) {
91
- var _envConfig_tools;
92
84
  const rspackArr = [];
93
- if ((_envConfig_tools = envConfig.tools) === null || _envConfig_tools === void 0 ? void 0 : _envConfig_tools.rspack) {
94
- var _envConfig_tools1, _envConfig_tools2;
95
- if (Array.isArray((_envConfig_tools1 = envConfig.tools) === null || _envConfig_tools1 === void 0 ? void 0 : _envConfig_tools1.rspack)) {
96
- var _envConfig_tools3;
97
- rspackArr.push(...(_envConfig_tools3 = envConfig.tools) === null || _envConfig_tools3 === void 0 ? void 0 : _envConfig_tools3.rspack);
98
- } else if (typeof ((_envConfig_tools2 = envConfig.tools) === null || _envConfig_tools2 === void 0 ? void 0 : _envConfig_tools2.rspack) === 'function') {
99
- var _envConfig_tools4;
100
- rspackArr.push((_envConfig_tools4 = envConfig.tools) === null || _envConfig_tools4 === void 0 ? void 0 : _envConfig_tools4.rspack);
85
+ if (envConfig.tools?.rspack) {
86
+ if (Array.isArray(envConfig.tools?.rspack)) {
87
+ rspackArr.push(...envConfig.tools?.rspack);
88
+ } else if (typeof envConfig.tools?.rspack === 'function') {
89
+ rspackArr.push(envConfig.tools?.rspack);
101
90
  }
102
91
  }
103
92
  envConfig.tools ||= {};
@@ -107,16 +96,12 @@ function patchToolsTspack(envConfig, fn) {
107
96
  ];
108
97
  }
109
98
  function createSSRREnvConfig(envConfig, mfConfig, ssrDir, rsbuildConfig, callerName) {
110
- var _envConfig_tools, _ssrEnvConfig_output, _ssrEnvConfig_output_distPath, _ssrEnvConfig_output1, _rsbuildConfig_output_distPath, _rsbuildConfig_output;
111
99
  const rspackArr = [];
112
- if ((_envConfig_tools = envConfig.tools) === null || _envConfig_tools === void 0 ? void 0 : _envConfig_tools.rspack) {
113
- var _envConfig_tools1, _envConfig_tools2;
114
- if (Array.isArray((_envConfig_tools1 = envConfig.tools) === null || _envConfig_tools1 === void 0 ? void 0 : _envConfig_tools1.rspack)) {
115
- var _envConfig_tools3;
116
- rspackArr.push(...(_envConfig_tools3 = envConfig.tools) === null || _envConfig_tools3 === void 0 ? void 0 : _envConfig_tools3.rspack);
117
- } else if (typeof ((_envConfig_tools2 = envConfig.tools) === null || _envConfig_tools2 === void 0 ? void 0 : _envConfig_tools2.rspack) === 'function') {
118
- var _envConfig_tools4;
119
- rspackArr.push((_envConfig_tools4 = envConfig.tools) === null || _envConfig_tools4 === void 0 ? void 0 : _envConfig_tools4.rspack);
100
+ if (envConfig.tools?.rspack) {
101
+ if (Array.isArray(envConfig.tools?.rspack)) {
102
+ rspackArr.push(...envConfig.tools?.rspack);
103
+ } else if (typeof envConfig.tools?.rspack === 'function') {
104
+ rspackArr.push(envConfig.tools?.rspack);
120
105
  }
121
106
  }
122
107
  const ssrEnvConfig = {
@@ -134,15 +119,14 @@ function createSSRREnvConfig(envConfig, mfConfig, ssrDir, rsbuildConfig, callerN
134
119
  // Rsbuild not support all rspack targets, so modify to async-node in modifyRspackConfig
135
120
  target: 'node',
136
121
  distPath: {
137
- ...(_ssrEnvConfig_output = ssrEnvConfig.output) === null || _ssrEnvConfig_output === void 0 ? void 0 : _ssrEnvConfig_output.distPath,
138
- root: path.join(((_ssrEnvConfig_output1 = ssrEnvConfig.output) === null || _ssrEnvConfig_output1 === void 0 ? void 0 : (_ssrEnvConfig_output_distPath = _ssrEnvConfig_output1.distPath) === null || _ssrEnvConfig_output_distPath === void 0 ? void 0 : _ssrEnvConfig_output_distPath.root) || ((_rsbuildConfig_output = rsbuildConfig.output) === null || _rsbuildConfig_output === void 0 ? void 0 : (_rsbuildConfig_output_distPath = _rsbuildConfig_output.distPath) === null || _rsbuildConfig_output_distPath === void 0 ? void 0 : _rsbuildConfig_output_distPath.root) || '', ssrDir)
122
+ ...ssrEnvConfig.output?.distPath,
123
+ root: path.join(ssrEnvConfig.output?.distPath?.root || rsbuildConfig.output?.distPath?.root || '', ssrDir)
139
124
  },
140
125
  emitAssets: true
141
126
  };
142
127
  return ssrEnvConfig;
143
128
  }
144
129
  function patchNodeMFConfig(mfConfig) {
145
- var _mfConfig_library;
146
130
  if (mfConfig.remotes) {
147
131
  mfConfig.remoteType = 'script';
148
132
  }
@@ -152,7 +136,7 @@ function patchNodeMFConfig(mfConfig) {
152
136
  mfConfig.library = {
153
137
  ...mfConfig.library,
154
138
  name: mfConfig.name,
155
- type: ((_mfConfig_library = mfConfig.library) === null || _mfConfig_library === void 0 ? void 0 : _mfConfig_library.type) ?? 'commonjs-module'
139
+ type: mfConfig.library?.type ?? 'commonjs-module'
156
140
  };
157
141
  mfConfig.runtimePlugins = [
158
142
  ...mfConfig.runtimePlugins || []