@module-federation/rsbuild-plugin 2.6.0 → 2.8.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.
@@ -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 = '';
@@ -53,14 +47,30 @@ function patchNodeConfig(config, mfConfig) {
53
47
  config.output.module = false;
54
48
  config.output.chunkFormat = 'commonjs';
55
49
  config.output.chunkLoading = 'async-node';
50
+ const prevLibrary = config.output.library;
51
+ if (prevLibrary && typeof prevLibrary === 'object' && !Array.isArray(prevLibrary)) {
52
+ config.output.library = {
53
+ ...prevLibrary,
54
+ type: 'commonjs-module'
55
+ };
56
+ } else if (typeof prevLibrary === 'string' || Array.isArray(prevLibrary)) {
57
+ config.output.library = {
58
+ name: prevLibrary,
59
+ type: 'commonjs-module'
60
+ };
61
+ } else {
62
+ config.output.library = {
63
+ type: 'commonjs-module'
64
+ };
65
+ }
56
66
  delete config.output.chunkLoadingGlobal;
57
67
  const UniverseEntryChunkTrackerPluginModule = safeRequire('@module-federation/node/universe-entry-chunk-tracker-plugin');
58
- const UniverseEntryChunkTrackerPlugin = UniverseEntryChunkTrackerPluginModule === null || UniverseEntryChunkTrackerPluginModule === void 0 ? void 0 : UniverseEntryChunkTrackerPluginModule.default;
68
+ const UniverseEntryChunkTrackerPlugin = UniverseEntryChunkTrackerPluginModule?.default;
59
69
  config.plugins ||= [];
60
70
  if (isDev() && UniverseEntryChunkTrackerPlugin) {
61
71
  config.plugins.push(new UniverseEntryChunkTrackerPlugin());
62
72
  }
63
- const uniqueName = mfConfig.name || ((_config_output = config.output) === null || _config_output === void 0 ? void 0 : _config_output.uniqueName);
73
+ const uniqueName = mfConfig.name || config.output?.uniqueName;
64
74
  const chunkFileName = config.output.chunkFilename;
65
75
  if (typeof chunkFileName === 'string' && uniqueName && !chunkFileName.includes(uniqueName)) {
66
76
  const encodedName = encodeName(uniqueName);
@@ -70,8 +80,7 @@ function patchNodeConfig(config, mfConfig) {
70
80
  function patchSSRRspackConfig(config, mfConfig, ssrDir, callerName, resetEntry = true, modifyPublicPath = true) {
71
81
  config.output ||= {};
72
82
  if (modifyPublicPath) {
73
- var _config_output;
74
- if (typeof ((_config_output = config.output) === null || _config_output === void 0 ? void 0 : _config_output.publicPath) !== 'string') {
83
+ if (typeof config.output?.publicPath !== 'string') {
75
84
  throw new Error('publicPath must be string!');
76
85
  }
77
86
  const publicPath = config.output.publicPath;
@@ -88,16 +97,12 @@ function patchSSRRspackConfig(config, mfConfig, ssrDir, callerName, resetEntry =
88
97
  return config;
89
98
  }
90
99
  function patchToolsTspack(envConfig, fn) {
91
- var _envConfig_tools;
92
100
  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);
101
+ if (envConfig.tools?.rspack) {
102
+ if (Array.isArray(envConfig.tools?.rspack)) {
103
+ rspackArr.push(...envConfig.tools?.rspack);
104
+ } else if (typeof envConfig.tools?.rspack === 'function') {
105
+ rspackArr.push(envConfig.tools?.rspack);
101
106
  }
102
107
  }
103
108
  envConfig.tools ||= {};
@@ -107,16 +112,12 @@ function patchToolsTspack(envConfig, fn) {
107
112
  ];
108
113
  }
109
114
  function createSSRREnvConfig(envConfig, mfConfig, ssrDir, rsbuildConfig, callerName) {
110
- var _envConfig_tools, _ssrEnvConfig_output, _ssrEnvConfig_output_distPath, _ssrEnvConfig_output1, _rsbuildConfig_output_distPath, _rsbuildConfig_output;
111
115
  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);
116
+ if (envConfig.tools?.rspack) {
117
+ if (Array.isArray(envConfig.tools?.rspack)) {
118
+ rspackArr.push(...envConfig.tools?.rspack);
119
+ } else if (typeof envConfig.tools?.rspack === 'function') {
120
+ rspackArr.push(envConfig.tools?.rspack);
120
121
  }
121
122
  }
122
123
  const ssrEnvConfig = {
@@ -134,15 +135,14 @@ function createSSRREnvConfig(envConfig, mfConfig, ssrDir, rsbuildConfig, callerN
134
135
  // Rsbuild not support all rspack targets, so modify to async-node in modifyRspackConfig
135
136
  target: 'node',
136
137
  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)
138
+ ...ssrEnvConfig.output?.distPath,
139
+ root: path.join(ssrEnvConfig.output?.distPath?.root || rsbuildConfig.output?.distPath?.root || '', ssrDir)
139
140
  },
140
141
  emitAssets: true
141
142
  };
142
143
  return ssrEnvConfig;
143
144
  }
144
145
  function patchNodeMFConfig(mfConfig) {
145
- var _mfConfig_library;
146
146
  if (mfConfig.remotes) {
147
147
  mfConfig.remoteType = 'script';
148
148
  }
@@ -152,7 +152,7 @@ function patchNodeMFConfig(mfConfig) {
152
152
  mfConfig.library = {
153
153
  ...mfConfig.library,
154
154
  name: mfConfig.name,
155
- type: ((_mfConfig_library = mfConfig.library) === null || _mfConfig_library === void 0 ? void 0 : _mfConfig_library.type) ?? 'commonjs-module'
155
+ type: mfConfig.library?.type ?? 'commonjs-module'
156
156
  };
157
157
  mfConfig.runtimePlugins = [
158
158
  ...mfConfig.runtimePlugins || []
package/dist/utils.js CHANGED
@@ -7,13 +7,12 @@ const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
7
7
  })();
8
8
  ;
9
9
  var __webpack_modules__ = ({
10
- "./utils/index": (function (module) {
10
+ "./utils/index"(module) {
11
11
  module.exports = require("./utils/index.js");
12
12
 
13
- }),
13
+ },
14
14
 
15
15
  });
16
- /************************************************************************/
17
16
  // The module cache
18
17
  var __webpack_module_cache__ = {};
19
18
 
@@ -37,7 +36,6 @@ return module.exports;
37
36
 
38
37
  }
39
38
 
40
- /************************************************************************/
41
39
  // webpack/runtime/compat_get_default_export
42
40
  (() => {
43
41
  // getDefaultExport function for compatibility with non-ESM modules
@@ -52,12 +50,16 @@ __webpack_require__.n = (module) => {
52
50
  })();
53
51
  // webpack/runtime/define_property_getters
54
52
  (() => {
55
- __webpack_require__.d = (exports, definition) => {
56
- for(var key in definition) {
57
- if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
58
- Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
59
- }
60
- }
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");
61
63
  };
62
64
  })();
63
65
  // webpack/runtime/has_own_property
@@ -74,22 +76,21 @@ __webpack_require__.r = (exports) => {
74
76
  Object.defineProperty(exports, '__esModule', { value: true });
75
77
  };
76
78
  })();
77
- /************************************************************************/
78
79
  var __webpack_exports__ = {};
79
80
  // This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
80
81
  (() => {
81
82
  __webpack_require__.r(__webpack_exports__);
82
- /* ESM import */var _utils_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./utils/index");
83
- /* ESM import */var _utils_index__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_utils_index__WEBPACK_IMPORTED_MODULE_0__);
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);
84
85
 
85
- /* ESM reexport (unknown) */ var __WEBPACK_REEXPORT_OBJECT__ = {};
86
- /* ESM reexport (unknown) */ for( var __WEBPACK_IMPORT_KEY__ in _utils_index__WEBPACK_IMPORTED_MODULE_0__) if(__WEBPACK_IMPORT_KEY__ !== "default") __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] =function(key) { return _utils_index__WEBPACK_IMPORTED_MODULE_0__[key]; }.bind(0, __WEBPACK_IMPORT_KEY__)
87
- /* ESM reexport (unknown) */ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
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);
88
89
 
89
90
 
90
91
  })();
91
92
 
92
- for(var __webpack_i__ in __webpack_exports__) {
93
- exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
93
+ for(var __rspack_i in __webpack_exports__) {
94
+ exports[__rspack_i] = __webpack_exports__[__rspack_i];
94
95
  }
95
96
  Object.defineProperty(exports, '__esModule', { value: true });
package/dist/utils.mjs CHANGED
@@ -1,5 +1,4 @@
1
1
  export * from "./utils/index.mjs";
2
2
 
3
- ;// CONCATENATED MODULE: ./src/utils.ts
4
-
5
3
 
4
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/rsbuild-plugin",
3
- "version": "2.6.0",
3
+ "version": "2.8.0",
4
4
  "description": "Module Federation plugin for Rsbuild",
5
5
  "homepage": "https://module-federation.io",
6
6
  "bugs": {
@@ -49,14 +49,15 @@
49
49
  "dist"
50
50
  ],
51
51
  "dependencies": {
52
- "@module-federation/sdk": "2.6.0",
53
- "@module-federation/enhanced": "2.6.0",
54
- "@module-federation/node": "2.7.45"
52
+ "@module-federation/sdk": "2.8.0",
53
+ "@module-federation/enhanced": "2.8.0",
54
+ "@module-federation/node": "2.7.47"
55
55
  },
56
56
  "devDependencies": {
57
- "@rslib/core": "^0.12.4",
58
- "@rsbuild/core": "2.0.0-beta.2",
59
- "vitest": "1.6.0"
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
63
  "@rsbuild/core": "^1.3.21 || ^2.0.0-0"
@@ -76,7 +77,7 @@
76
77
  "scripts": {
77
78
  "build": "rslib build",
78
79
  "lint": "ESLINT_USE_FLAT_CONFIG=false pnpm exec eslint --ignore-pattern node_modules \"**/*.ts\" \"package.json\"",
79
- "test": "pnpm exec vitest run --passWithNoTests --config vite.config.mts",
80
+ "test": "pnpm exec rstest --passWithNoTests",
80
81
  "pre-release": "pnpm run test && pnpm run build"
81
82
  }
82
83
  }