@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.
- package/dist/cli/index.js +33 -39
- package/dist/cli/index.mjs +18 -34
- package/dist/constant.js +24 -20
- package/dist/constant.mjs +0 -2
- package/dist/index.js +19 -18
- package/dist/index.mjs +1 -2
- package/dist/logger.js +14 -12
- package/dist/logger.mjs +2 -4
- package/dist/utils/addDataFetchExposes.js +13 -11
- package/dist/utils/addDataFetchExposes.mjs +0 -5
- package/dist/utils/autoDeleteSplitChunkCacheGroups.js +18 -15
- package/dist/utils/autoDeleteSplitChunkCacheGroups.mjs +1 -3
- package/dist/utils/index.js +19 -17
- package/dist/utils/index.mjs +6 -13
- package/dist/utils/manifest.js +13 -11
- package/dist/utils/manifest.mjs +0 -3
- package/dist/utils/ssr.d.ts +3 -1
- package/dist/utils/ssr.js +52 -45
- package/dist/utils/ssr.mjs +32 -32
- package/dist/utils.js +19 -18
- package/dist/utils.mjs +1 -2
- package/package.json +9 -8
package/dist/utils/ssr.mjs
CHANGED
|
@@ -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
|
|
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 ||
|
|
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
|
-
|
|
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 (
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
rspackArr.push(
|
|
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 (
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
rspackArr.push(
|
|
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
|
-
...
|
|
138
|
-
root: path.join(
|
|
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:
|
|
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"
|
|
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,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
-
/*
|
|
83
|
-
/*
|
|
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
|
-
/*
|
|
86
|
-
/*
|
|
87
|
-
/*
|
|
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
|
|
93
|
-
exports[
|
|
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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/rsbuild-plugin",
|
|
3
|
-
"version": "2.
|
|
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.
|
|
53
|
-
"@module-federation/enhanced": "2.
|
|
54
|
-
"@module-federation/node": "2.7.
|
|
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.
|
|
58
|
-
"@rsbuild/core": "2.
|
|
59
|
-
"
|
|
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
|
|
80
|
+
"test": "pnpm exec rstest --passWithNoTests",
|
|
80
81
|
"pre-release": "pnpm run test && pnpm run build"
|
|
81
82
|
}
|
|
82
83
|
}
|