@module-federation/rsbuild-plugin 0.15.0 → 0.17.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/constant.cjs.d.ts +1 -1
- package/dist/constant.cjs.js +9 -0
- package/dist/constant.esm.d.ts +1 -1
- package/dist/constant.esm.mjs +11 -0
- package/dist/index.cjs.js +61 -116
- package/dist/{index.esm.js → index.esm.mjs} +52 -107
- package/dist/src/cli/index.d.ts +8 -3
- package/dist/src/constant.d.ts +9 -0
- package/dist/src/utils/index.d.ts +3 -1
- package/dist/src/{cli → utils}/ssr.d.ts +4 -4
- package/dist/utils.cjs.js +209 -0
- package/dist/utils.esm.mjs +330 -0
- package/package.json +8 -16
- package/dist/constant.esm.js +0 -5
- package/dist/manifest.cjs.d.ts +0 -1
- package/dist/manifest.cjs.js +0 -45
- package/dist/manifest.esm.d.ts +0 -1
- package/dist/manifest.esm.js +0 -43
- package/dist/src/utils/constant.d.ts +0 -3
- package/dist/utils.esm.js +0 -129
- /package/dist/src/{cli → utils}/manifest.d.ts +0 -0
- /package/dist/src/{cli → utils}/ssr.spec.d.ts +0 -0
package/dist/constant.cjs.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./src/
|
|
1
|
+
export * from "./src/constant";
|
package/dist/constant.cjs.js
CHANGED
|
@@ -3,7 +3,16 @@
|
|
|
3
3
|
var DEFAULT_ASSET_PREFIX = '/';
|
|
4
4
|
var DATA_FETCH_IDENTIFIER = 'data';
|
|
5
5
|
var DATA_FETCH_CLIENT_SUFFIX = '.client';
|
|
6
|
+
var CALL_NAME_MAP = {
|
|
7
|
+
RSPRESS: 'rspress',
|
|
8
|
+
RSLIB: 'rslib'
|
|
9
|
+
};
|
|
10
|
+
var RSPRESS_BUNDLER_CONFIG_NAME = 'node';
|
|
11
|
+
var RSPRESS_SSR_DIR = 'ssr';
|
|
6
12
|
|
|
13
|
+
exports.CALL_NAME_MAP = CALL_NAME_MAP;
|
|
7
14
|
exports.DATA_FETCH_CLIENT_SUFFIX = DATA_FETCH_CLIENT_SUFFIX;
|
|
8
15
|
exports.DATA_FETCH_IDENTIFIER = DATA_FETCH_IDENTIFIER;
|
|
9
16
|
exports.DEFAULT_ASSET_PREFIX = DEFAULT_ASSET_PREFIX;
|
|
17
|
+
exports.RSPRESS_BUNDLER_CONFIG_NAME = RSPRESS_BUNDLER_CONFIG_NAME;
|
|
18
|
+
exports.RSPRESS_SSR_DIR = RSPRESS_SSR_DIR;
|
package/dist/constant.esm.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from "./src/
|
|
1
|
+
export * from "./src/constant";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
var DEFAULT_ASSET_PREFIX = '/';
|
|
2
|
+
var DATA_FETCH_IDENTIFIER = 'data';
|
|
3
|
+
var DATA_FETCH_CLIENT_SUFFIX = '.client';
|
|
4
|
+
var CALL_NAME_MAP = {
|
|
5
|
+
RSPRESS: 'rspress',
|
|
6
|
+
RSLIB: 'rslib'
|
|
7
|
+
};
|
|
8
|
+
var RSPRESS_BUNDLER_CONFIG_NAME = 'node';
|
|
9
|
+
var RSPRESS_SSR_DIR = 'ssr';
|
|
10
|
+
|
|
11
|
+
export { CALL_NAME_MAP, DATA_FETCH_CLIENT_SUFFIX, DATA_FETCH_IDENTIFIER, DEFAULT_ASSET_PREFIX, RSPRESS_BUNDLER_CONFIG_NAME, RSPRESS_SSR_DIR };
|
package/dist/index.cjs.js
CHANGED
|
@@ -4,11 +4,11 @@ var enhanced = require('@module-federation/enhanced');
|
|
|
4
4
|
var rspack = require('@module-federation/enhanced/rspack');
|
|
5
5
|
var sdk = require('@module-federation/sdk');
|
|
6
6
|
var utils = require('./utils.cjs.js');
|
|
7
|
-
var
|
|
8
|
-
var manifest = require('./manifest.cjs.js');
|
|
7
|
+
var constant = require('./constant.cjs.js');
|
|
9
8
|
require('util');
|
|
10
|
-
require('./constant.cjs.js');
|
|
11
9
|
require('fs-extra');
|
|
10
|
+
require('path');
|
|
11
|
+
require('node:module');
|
|
12
12
|
|
|
13
13
|
var name = "@module-federation/rsbuild-plugin";
|
|
14
14
|
var pkgJson = {
|
|
@@ -16,6 +16,14 @@ var pkgJson = {
|
|
|
16
16
|
|
|
17
17
|
var logger = sdk.createLogger('[ Module Federation Rsbuild Plugin ]');
|
|
18
18
|
|
|
19
|
+
function _array_like_to_array(arr, len) {
|
|
20
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
21
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
22
|
+
return arr2;
|
|
23
|
+
}
|
|
24
|
+
function _array_without_holes(arr) {
|
|
25
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
26
|
+
}
|
|
19
27
|
function _define_property(obj, key, value) {
|
|
20
28
|
if (key in obj) {
|
|
21
29
|
Object.defineProperty(obj, key, {
|
|
@@ -29,6 +37,12 @@ function _define_property(obj, key, value) {
|
|
|
29
37
|
}
|
|
30
38
|
return obj;
|
|
31
39
|
}
|
|
40
|
+
function _iterable_to_array(iter) {
|
|
41
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
42
|
+
}
|
|
43
|
+
function _non_iterable_spread() {
|
|
44
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
45
|
+
}
|
|
32
46
|
function _object_spread(target) {
|
|
33
47
|
for(var i = 1; i < arguments.length; i++){
|
|
34
48
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
@@ -63,97 +77,6 @@ function _object_spread_props(target, source) {
|
|
|
63
77
|
}
|
|
64
78
|
return target;
|
|
65
79
|
}
|
|
66
|
-
var SSR_DIR = 'ssr';
|
|
67
|
-
var SSR_ENV_NAME = 'mf-ssr';
|
|
68
|
-
function setSSREnv() {
|
|
69
|
-
process.env['MF_DISABLE_EMIT_STATS'] = 'true';
|
|
70
|
-
process.env['MF_SSR_PRJ'] = 'true';
|
|
71
|
-
}
|
|
72
|
-
var isDev = function() {
|
|
73
|
-
return process.env.NODE_ENV === 'development';
|
|
74
|
-
};
|
|
75
|
-
function patchSSRRspackConfig(config, mfConfig) {
|
|
76
|
-
var _config_output, _config_output1;
|
|
77
|
-
var _config;
|
|
78
|
-
if (typeof ((_config_output = config.output) === null || _config_output === void 0 ? void 0 : _config_output.publicPath) !== 'string') {
|
|
79
|
-
throw new Error('publicPath must be string!');
|
|
80
|
-
}
|
|
81
|
-
var publicPath = config.output.publicPath;
|
|
82
|
-
if (publicPath === 'auto') {
|
|
83
|
-
throw new Error('publicPath can not be "auto"!');
|
|
84
|
-
}
|
|
85
|
-
config.output.publicPath = "".concat(config.output.publicPath).concat(SSR_DIR, "/");
|
|
86
|
-
config.target = 'async-node';
|
|
87
|
-
// @module-federation/node/universe-entry-chunk-tracker-plugin only export cjs
|
|
88
|
-
var UniverseEntryChunkTrackerPlugin = require('@module-federation/node/universe-entry-chunk-tracker-plugin').default;
|
|
89
|
-
(_config = config).plugins || (_config.plugins = []);
|
|
90
|
-
isDev() && config.plugins.push(new UniverseEntryChunkTrackerPlugin());
|
|
91
|
-
var uniqueName = mfConfig.name || ((_config_output1 = config.output) === null || _config_output1 === void 0 ? void 0 : _config_output1.uniqueName);
|
|
92
|
-
var chunkFileName = config.output.chunkFilename;
|
|
93
|
-
if (typeof chunkFileName === 'string' && uniqueName && !chunkFileName.includes(uniqueName)) {
|
|
94
|
-
var suffix = "".concat(sdk.encodeName(uniqueName), "-[chunkhash].js");
|
|
95
|
-
config.output.chunkFilename = chunkFileName.replace('.js', suffix);
|
|
96
|
-
}
|
|
97
|
-
return config;
|
|
98
|
-
}
|
|
99
|
-
function createSSRREnvConfig(envConfig, mfConfig) {
|
|
100
|
-
var _ssrEnvConfig_output, _ssrEnvConfig_output_distPath, _ssrEnvConfig_output1;
|
|
101
|
-
var ssrEnvConfig = _object_spread_props(_object_spread({}, envConfig), {
|
|
102
|
-
tools: {
|
|
103
|
-
rspack: function(config, param) {
|
|
104
|
-
var environment = param.environment;
|
|
105
|
-
if (environment.name !== SSR_ENV_NAME) {
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
patchSSRRspackConfig(config, mfConfig);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
ssrEnvConfig.output = _object_spread_props(_object_spread({}, ssrEnvConfig.output), {
|
|
113
|
-
// https://rsbuild.rs/config/output/target#other-targets
|
|
114
|
-
// Rsbuild not support all rspack targets, so modify to async-node in modifyRspackConfig
|
|
115
|
-
target: 'node',
|
|
116
|
-
distPath: _object_spread_props(_object_spread({}, (_ssrEnvConfig_output = ssrEnvConfig.output) === null || _ssrEnvConfig_output === void 0 ? void 0 : _ssrEnvConfig_output.distPath), {
|
|
117
|
-
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) || '', SSR_DIR)
|
|
118
|
-
})
|
|
119
|
-
});
|
|
120
|
-
return ssrEnvConfig;
|
|
121
|
-
}
|
|
122
|
-
function createSSRMFConfig(mfConfig) {
|
|
123
|
-
var _mfConfig_library;
|
|
124
|
-
var _ssrMFConfig;
|
|
125
|
-
var _mfConfig_library_type;
|
|
126
|
-
var ssrMFConfig = _object_spread_props(_object_spread({}, mfConfig), {
|
|
127
|
-
exposes: _object_spread({}, mfConfig.exposes),
|
|
128
|
-
library: _object_spread_props(_object_spread({}, mfConfig.library), {
|
|
129
|
-
name: mfConfig.name,
|
|
130
|
-
type: (_mfConfig_library_type = (_mfConfig_library = mfConfig.library) === null || _mfConfig_library === void 0 ? void 0 : _mfConfig_library.type) !== null && _mfConfig_library_type !== void 0 ? _mfConfig_library_type : 'commonjs-module'
|
|
131
|
-
}),
|
|
132
|
-
dts: false,
|
|
133
|
-
dev: false
|
|
134
|
-
});
|
|
135
|
-
(_ssrMFConfig = ssrMFConfig).runtimePlugins || (_ssrMFConfig.runtimePlugins = []);
|
|
136
|
-
ssrMFConfig.runtimePlugins.push(require.resolve('@module-federation/node/runtimePlugin'));
|
|
137
|
-
if (isDev()) {
|
|
138
|
-
ssrMFConfig.runtimePlugins.push(require.resolve('@module-federation/node/record-dynamic-remote-entry-hash-plugin'));
|
|
139
|
-
}
|
|
140
|
-
return ssrMFConfig;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
function _array_like_to_array(arr, len) {
|
|
144
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
145
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
146
|
-
return arr2;
|
|
147
|
-
}
|
|
148
|
-
function _array_without_holes(arr) {
|
|
149
|
-
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
150
|
-
}
|
|
151
|
-
function _iterable_to_array(iter) {
|
|
152
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
153
|
-
}
|
|
154
|
-
function _non_iterable_spread() {
|
|
155
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
156
|
-
}
|
|
157
80
|
function _to_consumable_array(arr) {
|
|
158
81
|
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
159
82
|
}
|
|
@@ -187,38 +110,43 @@ function isStoryBook(rsbuildConfig) {
|
|
|
187
110
|
function isMFFormat(bundlerConfig) {
|
|
188
111
|
var _bundlerConfig_output;
|
|
189
112
|
var library = (_bundlerConfig_output = bundlerConfig.output) === null || _bundlerConfig_output === void 0 ? void 0 : _bundlerConfig_output.library;
|
|
190
|
-
if (bundlerConfig.name === SSR_ENV_NAME) {
|
|
113
|
+
if (bundlerConfig.name === utils.SSR_ENV_NAME) {
|
|
191
114
|
return true;
|
|
192
115
|
}
|
|
193
116
|
return !((typeof library === "undefined" ? "undefined" : _type_of(library)) === 'object' && !Array.isArray(library) && 'type' in library && // if the type is umd/modern-module or commonjs*, means this is a normal library , not mf
|
|
194
117
|
(LIB_FORMAT.includes(library.type) || /commonjs/.test(library.type)));
|
|
195
118
|
}
|
|
196
119
|
var isSSRConfig = function(bundlerConfigName) {
|
|
197
|
-
return Boolean(bundlerConfigName === SSR_ENV_NAME);
|
|
120
|
+
return Boolean(bundlerConfigName === utils.SSR_ENV_NAME);
|
|
121
|
+
};
|
|
122
|
+
var isRspressSSGConfig = function(bundlerConfigName) {
|
|
123
|
+
return bundlerConfigName === constant.RSPRESS_BUNDLER_CONFIG_NAME;
|
|
198
124
|
};
|
|
199
125
|
var pluginModuleFederation = function(moduleFederationOptions, rsbuildOptions) {
|
|
200
126
|
return {
|
|
201
127
|
name: RSBUILD_PLUGIN_MODULE_FEDERATION_NAME,
|
|
202
128
|
setup: function(api) {
|
|
129
|
+
var _ref = rsbuildOptions || {}, _ref_ssr = _ref.ssr, ssr = _ref_ssr === void 0 ? undefined : _ref_ssr, _ref_ssrDir = _ref.ssrDir, ssrDir = _ref_ssrDir === void 0 ? utils.SSR_DIR : _ref_ssrDir, _ref_environment = _ref.environment, environment = _ref_environment === void 0 ? DEFAULT_MF_ENVIRONMENT_NAME : _ref_environment;
|
|
203
130
|
var callerName = api.context.callerName;
|
|
204
131
|
var originalRsbuildConfig = api.getRsbuildConfig();
|
|
205
132
|
if (!callerName) {
|
|
206
133
|
throw new Error('`callerName` is undefined. Please ensure the @rsbuild/core version is higher than 1.3.21 .');
|
|
207
134
|
}
|
|
208
|
-
var isRslib = callerName ===
|
|
209
|
-
var
|
|
135
|
+
var isRslib = callerName === constant.CALL_NAME_MAP.RSLIB;
|
|
136
|
+
var isRspress = callerName === constant.CALL_NAME_MAP.RSPRESS;
|
|
137
|
+
var isSSR = Boolean(ssr);
|
|
210
138
|
if (isSSR && !isStoryBook(originalRsbuildConfig)) {
|
|
211
139
|
var _rsbuildConfig_environments;
|
|
212
|
-
if (!isRslib) {
|
|
140
|
+
if (!isRslib && !isRspress) {
|
|
213
141
|
throw new Error("'ssr' option is only supported in rslib.");
|
|
214
142
|
}
|
|
215
143
|
var rsbuildConfig = api.getRsbuildConfig();
|
|
216
|
-
if (!((_rsbuildConfig_environments = rsbuildConfig.environments) === null || _rsbuildConfig_environments === void 0 ? void 0 : _rsbuildConfig_environments[
|
|
217
|
-
return key.startsWith(
|
|
144
|
+
if (!((_rsbuildConfig_environments = rsbuildConfig.environments) === null || _rsbuildConfig_environments === void 0 ? void 0 : _rsbuildConfig_environments[environment]) || Object.keys(rsbuildConfig.environments).some(function(key) {
|
|
145
|
+
return key.startsWith(environment) && key !== environment;
|
|
218
146
|
})) {
|
|
219
147
|
throw new Error("Please set ".concat(RSBUILD_PLUGIN_NAME, " as global plugin in rslib.config.ts if you set 'ssr:true' ."));
|
|
220
148
|
}
|
|
221
|
-
setSSREnv();
|
|
149
|
+
utils.setSSREnv();
|
|
222
150
|
}
|
|
223
151
|
var sharedOptions = enhanced.parseOptions(moduleFederationOptions.shared || [], function(item, key) {
|
|
224
152
|
if (typeof item !== 'string') throw new Error('Unexpected array in shared');
|
|
@@ -256,7 +184,7 @@ var pluginModuleFederation = function(moduleFederationOptions, rsbuildOptions) {
|
|
|
256
184
|
'Detect that CORS options are not set, mf Rsbuild plugin will add default cors header: server.headers["Access-Control-Allow-Headers"] = "*". It is recommended to specify an allowlist of trusted origins in "server.cors" instead.',
|
|
257
185
|
'View https://module-federation.io/guide/troubleshooting/other.html#cors-warn for more details.'
|
|
258
186
|
];
|
|
259
|
-
!isRslib && logger.warn(corsWarnMsgs.join('\n'));
|
|
187
|
+
!isRslib && !isRspress && logger.warn(corsWarnMsgs.join('\n'));
|
|
260
188
|
config.server.headers['Access-Control-Allow-Origin'] = '*';
|
|
261
189
|
}
|
|
262
190
|
// For remote modules, Rsbuild should send the ws request to the provider's dev server.
|
|
@@ -275,10 +203,10 @@ var pluginModuleFederation = function(moduleFederationOptions, rsbuildOptions) {
|
|
|
275
203
|
}
|
|
276
204
|
if (isSSR) {
|
|
277
205
|
var _config_environments, _config_environments1;
|
|
278
|
-
if ((_config_environments = config.environments) === null || _config_environments === void 0 ? void 0 : _config_environments[SSR_ENV_NAME]) {
|
|
279
|
-
throw new Error("'".concat(SSR_ENV_NAME, "' environment is already defined. Please use another name."));
|
|
206
|
+
if ((_config_environments = config.environments) === null || _config_environments === void 0 ? void 0 : _config_environments[utils.SSR_ENV_NAME]) {
|
|
207
|
+
throw new Error("'".concat(utils.SSR_ENV_NAME, "' environment is already defined. Please use another name."));
|
|
280
208
|
}
|
|
281
|
-
config.environments[SSR_ENV_NAME] = createSSRREnvConfig((_config_environments1 = config.environments) === null || _config_environments1 === void 0 ? void 0 : _config_environments1[
|
|
209
|
+
config.environments[utils.SSR_ENV_NAME] = utils.createSSRREnvConfig((_config_environments1 = config.environments) === null || _config_environments1 === void 0 ? void 0 : _config_environments1[environment], moduleFederationOptions, ssrDir, config, callerName);
|
|
282
210
|
}
|
|
283
211
|
});
|
|
284
212
|
api.modifyEnvironmentConfig(function(config) {
|
|
@@ -295,7 +223,8 @@ var pluginModuleFederation = function(moduleFederationOptions, rsbuildOptions) {
|
|
|
295
223
|
browserPlugin: undefined,
|
|
296
224
|
distOutputDir: undefined
|
|
297
225
|
},
|
|
298
|
-
isSSRConfig: isSSRConfig
|
|
226
|
+
isSSRConfig: isSSRConfig,
|
|
227
|
+
isRspressSSGConfig: isRspressSSGConfig
|
|
299
228
|
};
|
|
300
229
|
api.expose(RSBUILD_PLUGIN_MODULE_FEDERATION_NAME, generateMergedStatsAndManifestOptions);
|
|
301
230
|
api.onBeforeCreateCompiler(function(param) {
|
|
@@ -304,7 +233,7 @@ var pluginModuleFederation = function(moduleFederationOptions, rsbuildOptions) {
|
|
|
304
233
|
throw new Error('Can not get bundlerConfigs!');
|
|
305
234
|
}
|
|
306
235
|
bundlerConfigs.forEach(function(bundlerConfig) {
|
|
307
|
-
if (!isMFFormat(bundlerConfig)) {
|
|
236
|
+
if (!isMFFormat(bundlerConfig) && !isRspress) {
|
|
308
237
|
return;
|
|
309
238
|
} else if (isStoryBook(originalRsbuildConfig)) {
|
|
310
239
|
bundlerConfig.output.uniqueName = "".concat(moduleFederationOptions.name, "-storybook-host");
|
|
@@ -371,7 +300,7 @@ var pluginModuleFederation = function(moduleFederationOptions, rsbuildOptions) {
|
|
|
371
300
|
}
|
|
372
301
|
}
|
|
373
302
|
}
|
|
374
|
-
if (!((_bundlerConfig_output = bundlerConfig.output) === null || _bundlerConfig_output === void 0 ? void 0 : _bundlerConfig_output.chunkLoadingGlobal) && !isSSRConfig(bundlerConfig.name)) {
|
|
303
|
+
if (!((_bundlerConfig_output = bundlerConfig.output) === null || _bundlerConfig_output === void 0 ? void 0 : _bundlerConfig_output.chunkLoadingGlobal) && !isSSRConfig(bundlerConfig.name) && !isRspressSSGConfig(bundlerConfig.name)) {
|
|
375
304
|
bundlerConfig.output.chunkLoading = 'jsonp';
|
|
376
305
|
bundlerConfig.output.chunkLoadingGlobal = "chunk_".concat(moduleFederationOptions.name);
|
|
377
306
|
}
|
|
@@ -384,9 +313,25 @@ var pluginModuleFederation = function(moduleFederationOptions, rsbuildOptions) {
|
|
|
384
313
|
})) {
|
|
385
314
|
var _bundlerConfig_output2;
|
|
386
315
|
if (isSSRConfig(bundlerConfig.name)) {
|
|
387
|
-
generateMergedStatsAndManifestOptions.options.nodePlugin = new rspack.ModuleFederationPlugin(createSSRMFConfig(moduleFederationOptions));
|
|
316
|
+
generateMergedStatsAndManifestOptions.options.nodePlugin = new rspack.ModuleFederationPlugin(utils.createSSRMFConfig(moduleFederationOptions));
|
|
388
317
|
bundlerConfig.plugins.push(generateMergedStatsAndManifestOptions.options.nodePlugin);
|
|
389
318
|
return;
|
|
319
|
+
} else if (isRspressSSGConfig(bundlerConfig.name)) {
|
|
320
|
+
var _bundlerConfig;
|
|
321
|
+
var mfConfig = _object_spread_props(_object_spread({}, utils.createSSRMFConfig(moduleFederationOptions)), {
|
|
322
|
+
// expose in mf-ssg env
|
|
323
|
+
exposes: {},
|
|
324
|
+
manifest: false,
|
|
325
|
+
library: undefined
|
|
326
|
+
});
|
|
327
|
+
utils.patchSSRRspackConfig(bundlerConfig, mfConfig, constant.RSPRESS_SSR_DIR, callerName, false, false);
|
|
328
|
+
(_bundlerConfig = bundlerConfig).output || (_bundlerConfig.output = {});
|
|
329
|
+
bundlerConfig.output.publicPath = '/';
|
|
330
|
+
// MF depend on asyncChunks
|
|
331
|
+
bundlerConfig.output.asyncChunks = undefined;
|
|
332
|
+
generateMergedStatsAndManifestOptions.options.rspressSSGPlugin = new rspack.ModuleFederationPlugin(mfConfig);
|
|
333
|
+
bundlerConfig.plugins.push(generateMergedStatsAndManifestOptions.options.rspressSSGPlugin);
|
|
334
|
+
return;
|
|
390
335
|
}
|
|
391
336
|
generateMergedStatsAndManifestOptions.options.browserPlugin = new rspack.ModuleFederationPlugin(moduleFederationOptions);
|
|
392
337
|
generateMergedStatsAndManifestOptions.options.distOutputDir = ((_bundlerConfig_output2 = bundlerConfig.output) === null || _bundlerConfig_output2 === void 0 ? void 0 : _bundlerConfig_output2.path) || '';
|
|
@@ -400,7 +345,7 @@ var pluginModuleFederation = function(moduleFederationOptions, rsbuildOptions) {
|
|
|
400
345
|
if (!nodePlugin || !browserPlugin || !distOutputDir) {
|
|
401
346
|
return;
|
|
402
347
|
}
|
|
403
|
-
|
|
348
|
+
utils.updateStatsAndManifest(nodePlugin, browserPlugin, distOutputDir);
|
|
404
349
|
};
|
|
405
350
|
api.onDevCompileDone(function() {
|
|
406
351
|
generateMergedStatsAndManifest();
|
|
@@ -412,15 +357,15 @@ var pluginModuleFederation = function(moduleFederationOptions, rsbuildOptions) {
|
|
|
412
357
|
};
|
|
413
358
|
};
|
|
414
359
|
|
|
415
|
-
Object.defineProperty(exports, "createModuleFederationConfig", {
|
|
416
|
-
enumerable: true,
|
|
417
|
-
get: function () { return enhanced.createModuleFederationConfig; }
|
|
418
|
-
});
|
|
419
360
|
Object.defineProperty(exports, "PLUGIN_NAME", {
|
|
420
361
|
enumerable: true,
|
|
421
362
|
get: function () { return rspack.PLUGIN_NAME; }
|
|
422
363
|
});
|
|
364
|
+
Object.defineProperty(exports, "createModuleFederationConfig", {
|
|
365
|
+
enumerable: true,
|
|
366
|
+
get: function () { return sdk.createModuleFederationConfig; }
|
|
367
|
+
});
|
|
368
|
+
exports.SSR_DIR = utils.SSR_DIR;
|
|
423
369
|
exports.RSBUILD_PLUGIN_MODULE_FEDERATION_NAME = RSBUILD_PLUGIN_MODULE_FEDERATION_NAME;
|
|
424
|
-
exports.SSR_DIR = SSR_DIR;
|
|
425
370
|
exports.isMFFormat = isMFFormat;
|
|
426
371
|
exports.pluginModuleFederation = pluginModuleFederation;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { parseOptions } from '@module-federation/enhanced';
|
|
2
|
-
export { createModuleFederationConfig } from '@module-federation/enhanced';
|
|
3
2
|
import { PLUGIN_NAME, ModuleFederationPlugin } from '@module-federation/enhanced/rspack';
|
|
4
3
|
export { PLUGIN_NAME } from '@module-federation/enhanced/rspack';
|
|
5
|
-
import { createLogger,
|
|
6
|
-
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
4
|
+
import { createLogger, isRequiredVersion } from '@module-federation/sdk';
|
|
5
|
+
export { createModuleFederationConfig } from '@module-federation/sdk';
|
|
6
|
+
import { SSR_ENV_NAME, setSSREnv, createSSRREnvConfig, autoDeleteSplitChunkCacheGroups, addDataFetchExposes, isRegExp, createSSRMFConfig, patchSSRRspackConfig, updateStatsAndManifest, SSR_DIR } from './utils.esm.mjs';
|
|
7
|
+
import { CALL_NAME_MAP, RSPRESS_BUNDLER_CONFIG_NAME, RSPRESS_SSR_DIR } from './constant.esm.mjs';
|
|
9
8
|
import 'util';
|
|
10
|
-
import './constant.esm.js';
|
|
11
9
|
import 'fs-extra';
|
|
10
|
+
import 'path';
|
|
11
|
+
import 'node:module';
|
|
12
12
|
|
|
13
13
|
var name = "@module-federation/rsbuild-plugin";
|
|
14
14
|
var pkgJson = {
|
|
@@ -16,6 +16,14 @@ var pkgJson = {
|
|
|
16
16
|
|
|
17
17
|
var logger = createLogger('[ Module Federation Rsbuild Plugin ]');
|
|
18
18
|
|
|
19
|
+
function _array_like_to_array(arr, len) {
|
|
20
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
21
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
22
|
+
return arr2;
|
|
23
|
+
}
|
|
24
|
+
function _array_without_holes(arr) {
|
|
25
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
26
|
+
}
|
|
19
27
|
function _define_property(obj, key, value) {
|
|
20
28
|
if (key in obj) {
|
|
21
29
|
Object.defineProperty(obj, key, {
|
|
@@ -29,6 +37,12 @@ function _define_property(obj, key, value) {
|
|
|
29
37
|
}
|
|
30
38
|
return obj;
|
|
31
39
|
}
|
|
40
|
+
function _iterable_to_array(iter) {
|
|
41
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
42
|
+
}
|
|
43
|
+
function _non_iterable_spread() {
|
|
44
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
45
|
+
}
|
|
32
46
|
function _object_spread(target) {
|
|
33
47
|
for(var i = 1; i < arguments.length; i++){
|
|
34
48
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
@@ -63,97 +77,6 @@ function _object_spread_props(target, source) {
|
|
|
63
77
|
}
|
|
64
78
|
return target;
|
|
65
79
|
}
|
|
66
|
-
var SSR_DIR = 'ssr';
|
|
67
|
-
var SSR_ENV_NAME = 'mf-ssr';
|
|
68
|
-
function setSSREnv() {
|
|
69
|
-
process.env['MF_DISABLE_EMIT_STATS'] = 'true';
|
|
70
|
-
process.env['MF_SSR_PRJ'] = 'true';
|
|
71
|
-
}
|
|
72
|
-
var isDev = function() {
|
|
73
|
-
return process.env.NODE_ENV === 'development';
|
|
74
|
-
};
|
|
75
|
-
function patchSSRRspackConfig(config, mfConfig) {
|
|
76
|
-
var _config_output, _config_output1;
|
|
77
|
-
var _config;
|
|
78
|
-
if (typeof ((_config_output = config.output) === null || _config_output === void 0 ? void 0 : _config_output.publicPath) !== 'string') {
|
|
79
|
-
throw new Error('publicPath must be string!');
|
|
80
|
-
}
|
|
81
|
-
var publicPath = config.output.publicPath;
|
|
82
|
-
if (publicPath === 'auto') {
|
|
83
|
-
throw new Error('publicPath can not be "auto"!');
|
|
84
|
-
}
|
|
85
|
-
config.output.publicPath = "".concat(config.output.publicPath).concat(SSR_DIR, "/");
|
|
86
|
-
config.target = 'async-node';
|
|
87
|
-
// @module-federation/node/universe-entry-chunk-tracker-plugin only export cjs
|
|
88
|
-
var UniverseEntryChunkTrackerPlugin = require('@module-federation/node/universe-entry-chunk-tracker-plugin').default;
|
|
89
|
-
(_config = config).plugins || (_config.plugins = []);
|
|
90
|
-
isDev() && config.plugins.push(new UniverseEntryChunkTrackerPlugin());
|
|
91
|
-
var uniqueName = mfConfig.name || ((_config_output1 = config.output) === null || _config_output1 === void 0 ? void 0 : _config_output1.uniqueName);
|
|
92
|
-
var chunkFileName = config.output.chunkFilename;
|
|
93
|
-
if (typeof chunkFileName === 'string' && uniqueName && !chunkFileName.includes(uniqueName)) {
|
|
94
|
-
var suffix = "".concat(encodeName(uniqueName), "-[chunkhash].js");
|
|
95
|
-
config.output.chunkFilename = chunkFileName.replace('.js', suffix);
|
|
96
|
-
}
|
|
97
|
-
return config;
|
|
98
|
-
}
|
|
99
|
-
function createSSRREnvConfig(envConfig, mfConfig) {
|
|
100
|
-
var _ssrEnvConfig_output, _ssrEnvConfig_output_distPath, _ssrEnvConfig_output1;
|
|
101
|
-
var ssrEnvConfig = _object_spread_props(_object_spread({}, envConfig), {
|
|
102
|
-
tools: {
|
|
103
|
-
rspack: function(config, param) {
|
|
104
|
-
var environment = param.environment;
|
|
105
|
-
if (environment.name !== SSR_ENV_NAME) {
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
patchSSRRspackConfig(config, mfConfig);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
ssrEnvConfig.output = _object_spread_props(_object_spread({}, ssrEnvConfig.output), {
|
|
113
|
-
// https://rsbuild.rs/config/output/target#other-targets
|
|
114
|
-
// Rsbuild not support all rspack targets, so modify to async-node in modifyRspackConfig
|
|
115
|
-
target: 'node',
|
|
116
|
-
distPath: _object_spread_props(_object_spread({}, (_ssrEnvConfig_output = ssrEnvConfig.output) === null || _ssrEnvConfig_output === void 0 ? void 0 : _ssrEnvConfig_output.distPath), {
|
|
117
|
-
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) || '', SSR_DIR)
|
|
118
|
-
})
|
|
119
|
-
});
|
|
120
|
-
return ssrEnvConfig;
|
|
121
|
-
}
|
|
122
|
-
function createSSRMFConfig(mfConfig) {
|
|
123
|
-
var _mfConfig_library;
|
|
124
|
-
var _ssrMFConfig;
|
|
125
|
-
var _mfConfig_library_type;
|
|
126
|
-
var ssrMFConfig = _object_spread_props(_object_spread({}, mfConfig), {
|
|
127
|
-
exposes: _object_spread({}, mfConfig.exposes),
|
|
128
|
-
library: _object_spread_props(_object_spread({}, mfConfig.library), {
|
|
129
|
-
name: mfConfig.name,
|
|
130
|
-
type: (_mfConfig_library_type = (_mfConfig_library = mfConfig.library) === null || _mfConfig_library === void 0 ? void 0 : _mfConfig_library.type) !== null && _mfConfig_library_type !== void 0 ? _mfConfig_library_type : 'commonjs-module'
|
|
131
|
-
}),
|
|
132
|
-
dts: false,
|
|
133
|
-
dev: false
|
|
134
|
-
});
|
|
135
|
-
(_ssrMFConfig = ssrMFConfig).runtimePlugins || (_ssrMFConfig.runtimePlugins = []);
|
|
136
|
-
ssrMFConfig.runtimePlugins.push(require.resolve('@module-federation/node/runtimePlugin'));
|
|
137
|
-
if (isDev()) {
|
|
138
|
-
ssrMFConfig.runtimePlugins.push(require.resolve('@module-federation/node/record-dynamic-remote-entry-hash-plugin'));
|
|
139
|
-
}
|
|
140
|
-
return ssrMFConfig;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
function _array_like_to_array(arr, len) {
|
|
144
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
145
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
146
|
-
return arr2;
|
|
147
|
-
}
|
|
148
|
-
function _array_without_holes(arr) {
|
|
149
|
-
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
150
|
-
}
|
|
151
|
-
function _iterable_to_array(iter) {
|
|
152
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
153
|
-
}
|
|
154
|
-
function _non_iterable_spread() {
|
|
155
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
156
|
-
}
|
|
157
80
|
function _to_consumable_array(arr) {
|
|
158
81
|
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
159
82
|
}
|
|
@@ -196,25 +119,30 @@ function isMFFormat(bundlerConfig) {
|
|
|
196
119
|
var isSSRConfig = function(bundlerConfigName) {
|
|
197
120
|
return Boolean(bundlerConfigName === SSR_ENV_NAME);
|
|
198
121
|
};
|
|
122
|
+
var isRspressSSGConfig = function(bundlerConfigName) {
|
|
123
|
+
return bundlerConfigName === RSPRESS_BUNDLER_CONFIG_NAME;
|
|
124
|
+
};
|
|
199
125
|
var pluginModuleFederation = function(moduleFederationOptions, rsbuildOptions) {
|
|
200
126
|
return {
|
|
201
127
|
name: RSBUILD_PLUGIN_MODULE_FEDERATION_NAME,
|
|
202
128
|
setup: function(api) {
|
|
129
|
+
var _ref = rsbuildOptions || {}, _ref_ssr = _ref.ssr, ssr = _ref_ssr === void 0 ? undefined : _ref_ssr, _ref_ssrDir = _ref.ssrDir, ssrDir = _ref_ssrDir === void 0 ? SSR_DIR : _ref_ssrDir, _ref_environment = _ref.environment, environment = _ref_environment === void 0 ? DEFAULT_MF_ENVIRONMENT_NAME : _ref_environment;
|
|
203
130
|
var callerName = api.context.callerName;
|
|
204
131
|
var originalRsbuildConfig = api.getRsbuildConfig();
|
|
205
132
|
if (!callerName) {
|
|
206
133
|
throw new Error('`callerName` is undefined. Please ensure the @rsbuild/core version is higher than 1.3.21 .');
|
|
207
134
|
}
|
|
208
|
-
var isRslib = callerName ===
|
|
209
|
-
var
|
|
135
|
+
var isRslib = callerName === CALL_NAME_MAP.RSLIB;
|
|
136
|
+
var isRspress = callerName === CALL_NAME_MAP.RSPRESS;
|
|
137
|
+
var isSSR = Boolean(ssr);
|
|
210
138
|
if (isSSR && !isStoryBook(originalRsbuildConfig)) {
|
|
211
139
|
var _rsbuildConfig_environments;
|
|
212
|
-
if (!isRslib) {
|
|
140
|
+
if (!isRslib && !isRspress) {
|
|
213
141
|
throw new Error("'ssr' option is only supported in rslib.");
|
|
214
142
|
}
|
|
215
143
|
var rsbuildConfig = api.getRsbuildConfig();
|
|
216
|
-
if (!((_rsbuildConfig_environments = rsbuildConfig.environments) === null || _rsbuildConfig_environments === void 0 ? void 0 : _rsbuildConfig_environments[
|
|
217
|
-
return key.startsWith(
|
|
144
|
+
if (!((_rsbuildConfig_environments = rsbuildConfig.environments) === null || _rsbuildConfig_environments === void 0 ? void 0 : _rsbuildConfig_environments[environment]) || Object.keys(rsbuildConfig.environments).some(function(key) {
|
|
145
|
+
return key.startsWith(environment) && key !== environment;
|
|
218
146
|
})) {
|
|
219
147
|
throw new Error("Please set ".concat(RSBUILD_PLUGIN_NAME, " as global plugin in rslib.config.ts if you set 'ssr:true' ."));
|
|
220
148
|
}
|
|
@@ -256,7 +184,7 @@ var pluginModuleFederation = function(moduleFederationOptions, rsbuildOptions) {
|
|
|
256
184
|
'Detect that CORS options are not set, mf Rsbuild plugin will add default cors header: server.headers["Access-Control-Allow-Headers"] = "*". It is recommended to specify an allowlist of trusted origins in "server.cors" instead.',
|
|
257
185
|
'View https://module-federation.io/guide/troubleshooting/other.html#cors-warn for more details.'
|
|
258
186
|
];
|
|
259
|
-
!isRslib && logger.warn(corsWarnMsgs.join('\n'));
|
|
187
|
+
!isRslib && !isRspress && logger.warn(corsWarnMsgs.join('\n'));
|
|
260
188
|
config.server.headers['Access-Control-Allow-Origin'] = '*';
|
|
261
189
|
}
|
|
262
190
|
// For remote modules, Rsbuild should send the ws request to the provider's dev server.
|
|
@@ -278,7 +206,7 @@ var pluginModuleFederation = function(moduleFederationOptions, rsbuildOptions) {
|
|
|
278
206
|
if ((_config_environments = config.environments) === null || _config_environments === void 0 ? void 0 : _config_environments[SSR_ENV_NAME]) {
|
|
279
207
|
throw new Error("'".concat(SSR_ENV_NAME, "' environment is already defined. Please use another name."));
|
|
280
208
|
}
|
|
281
|
-
config.environments[SSR_ENV_NAME] = createSSRREnvConfig((_config_environments1 = config.environments) === null || _config_environments1 === void 0 ? void 0 : _config_environments1[
|
|
209
|
+
config.environments[SSR_ENV_NAME] = createSSRREnvConfig((_config_environments1 = config.environments) === null || _config_environments1 === void 0 ? void 0 : _config_environments1[environment], moduleFederationOptions, ssrDir, config, callerName);
|
|
282
210
|
}
|
|
283
211
|
});
|
|
284
212
|
api.modifyEnvironmentConfig(function(config) {
|
|
@@ -295,7 +223,8 @@ var pluginModuleFederation = function(moduleFederationOptions, rsbuildOptions) {
|
|
|
295
223
|
browserPlugin: undefined,
|
|
296
224
|
distOutputDir: undefined
|
|
297
225
|
},
|
|
298
|
-
isSSRConfig: isSSRConfig
|
|
226
|
+
isSSRConfig: isSSRConfig,
|
|
227
|
+
isRspressSSGConfig: isRspressSSGConfig
|
|
299
228
|
};
|
|
300
229
|
api.expose(RSBUILD_PLUGIN_MODULE_FEDERATION_NAME, generateMergedStatsAndManifestOptions);
|
|
301
230
|
api.onBeforeCreateCompiler(function(param) {
|
|
@@ -304,7 +233,7 @@ var pluginModuleFederation = function(moduleFederationOptions, rsbuildOptions) {
|
|
|
304
233
|
throw new Error('Can not get bundlerConfigs!');
|
|
305
234
|
}
|
|
306
235
|
bundlerConfigs.forEach(function(bundlerConfig) {
|
|
307
|
-
if (!isMFFormat(bundlerConfig)) {
|
|
236
|
+
if (!isMFFormat(bundlerConfig) && !isRspress) {
|
|
308
237
|
return;
|
|
309
238
|
} else if (isStoryBook(originalRsbuildConfig)) {
|
|
310
239
|
bundlerConfig.output.uniqueName = "".concat(moduleFederationOptions.name, "-storybook-host");
|
|
@@ -371,7 +300,7 @@ var pluginModuleFederation = function(moduleFederationOptions, rsbuildOptions) {
|
|
|
371
300
|
}
|
|
372
301
|
}
|
|
373
302
|
}
|
|
374
|
-
if (!((_bundlerConfig_output = bundlerConfig.output) === null || _bundlerConfig_output === void 0 ? void 0 : _bundlerConfig_output.chunkLoadingGlobal) && !isSSRConfig(bundlerConfig.name)) {
|
|
303
|
+
if (!((_bundlerConfig_output = bundlerConfig.output) === null || _bundlerConfig_output === void 0 ? void 0 : _bundlerConfig_output.chunkLoadingGlobal) && !isSSRConfig(bundlerConfig.name) && !isRspressSSGConfig(bundlerConfig.name)) {
|
|
375
304
|
bundlerConfig.output.chunkLoading = 'jsonp';
|
|
376
305
|
bundlerConfig.output.chunkLoadingGlobal = "chunk_".concat(moduleFederationOptions.name);
|
|
377
306
|
}
|
|
@@ -387,6 +316,22 @@ var pluginModuleFederation = function(moduleFederationOptions, rsbuildOptions) {
|
|
|
387
316
|
generateMergedStatsAndManifestOptions.options.nodePlugin = new ModuleFederationPlugin(createSSRMFConfig(moduleFederationOptions));
|
|
388
317
|
bundlerConfig.plugins.push(generateMergedStatsAndManifestOptions.options.nodePlugin);
|
|
389
318
|
return;
|
|
319
|
+
} else if (isRspressSSGConfig(bundlerConfig.name)) {
|
|
320
|
+
var _bundlerConfig;
|
|
321
|
+
var mfConfig = _object_spread_props(_object_spread({}, createSSRMFConfig(moduleFederationOptions)), {
|
|
322
|
+
// expose in mf-ssg env
|
|
323
|
+
exposes: {},
|
|
324
|
+
manifest: false,
|
|
325
|
+
library: undefined
|
|
326
|
+
});
|
|
327
|
+
patchSSRRspackConfig(bundlerConfig, mfConfig, RSPRESS_SSR_DIR, callerName, false, false);
|
|
328
|
+
(_bundlerConfig = bundlerConfig).output || (_bundlerConfig.output = {});
|
|
329
|
+
bundlerConfig.output.publicPath = '/';
|
|
330
|
+
// MF depend on asyncChunks
|
|
331
|
+
bundlerConfig.output.asyncChunks = undefined;
|
|
332
|
+
generateMergedStatsAndManifestOptions.options.rspressSSGPlugin = new ModuleFederationPlugin(mfConfig);
|
|
333
|
+
bundlerConfig.plugins.push(generateMergedStatsAndManifestOptions.options.rspressSSGPlugin);
|
|
334
|
+
return;
|
|
390
335
|
}
|
|
391
336
|
generateMergedStatsAndManifestOptions.options.browserPlugin = new ModuleFederationPlugin(moduleFederationOptions);
|
|
392
337
|
generateMergedStatsAndManifestOptions.options.distOutputDir = ((_bundlerConfig_output2 = bundlerConfig.output) === null || _bundlerConfig_output2 === void 0 ? void 0 : _bundlerConfig_output2.path) || '';
|
package/dist/src/cli/index.d.ts
CHANGED
|
@@ -1,23 +1,28 @@
|
|
|
1
1
|
import { ModuleFederationPlugin, PLUGIN_NAME } from '@module-federation/enhanced/rspack';
|
|
2
|
-
import { SSR_DIR } from '
|
|
2
|
+
import { SSR_DIR } from '../utils';
|
|
3
3
|
import type { moduleFederationPlugin } from '@module-federation/sdk';
|
|
4
4
|
import type { RsbuildPlugin, Rspack } from '@rsbuild/core';
|
|
5
5
|
type ModuleFederationOptions = moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
6
6
|
type RSBUILD_PLUGIN_OPTIONS = {
|
|
7
7
|
ssr?: boolean;
|
|
8
|
+
ssrDir?: string;
|
|
9
|
+
environment?: string;
|
|
8
10
|
};
|
|
9
11
|
type ExposedAPIType = {
|
|
10
12
|
options: {
|
|
11
13
|
nodePlugin?: ModuleFederationPlugin;
|
|
12
14
|
browserPlugin?: ModuleFederationPlugin;
|
|
15
|
+
rspressSSGPlugin?: ModuleFederationPlugin;
|
|
13
16
|
distOutputDir?: string;
|
|
14
17
|
};
|
|
15
18
|
isSSRConfig: typeof isSSRConfig;
|
|
19
|
+
isRspressSSGConfig: typeof isRspressSSGConfig;
|
|
16
20
|
};
|
|
17
21
|
export type { ModuleFederationOptions, ExposedAPIType };
|
|
18
22
|
declare const RSBUILD_PLUGIN_MODULE_FEDERATION_NAME = "rsbuild:module-federation-enhanced";
|
|
19
23
|
export { RSBUILD_PLUGIN_MODULE_FEDERATION_NAME, PLUGIN_NAME, SSR_DIR };
|
|
20
24
|
export declare function isMFFormat(bundlerConfig: Rspack.Configuration): boolean;
|
|
21
25
|
declare const isSSRConfig: (bundlerConfigName?: string) => boolean;
|
|
22
|
-
|
|
23
|
-
export
|
|
26
|
+
declare const isRspressSSGConfig: (bundlerConfigName?: string) => bundlerConfigName is "node";
|
|
27
|
+
export declare const pluginModuleFederation: (moduleFederationOptions: ModuleFederationOptions, rsbuildOptions: RSBUILD_PLUGIN_OPTIONS) => RsbuildPlugin;
|
|
28
|
+
export { createModuleFederationConfig } from '@module-federation/sdk';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const DEFAULT_ASSET_PREFIX = "/";
|
|
2
|
+
export declare const DATA_FETCH_IDENTIFIER = "data";
|
|
3
|
+
export declare const DATA_FETCH_CLIENT_SUFFIX = ".client";
|
|
4
|
+
export declare const CALL_NAME_MAP: {
|
|
5
|
+
RSPRESS: string;
|
|
6
|
+
RSLIB: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const RSPRESS_BUNDLER_CONFIG_NAME = "node";
|
|
9
|
+
export declare const RSPRESS_SSR_DIR = "ssr";
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export declare function isRegExp(target: any): target is RegExp;
|
|
2
|
-
export { DEFAULT_ASSET_PREFIX } from '
|
|
2
|
+
export { DEFAULT_ASSET_PREFIX } from '../constant';
|
|
3
3
|
export { autoDeleteSplitChunkCacheGroups } from './autoDeleteSplitChunkCacheGroups';
|
|
4
4
|
export { addDataFetchExposes } from './addDataFetchExposes';
|
|
5
|
+
export { updateStatsAndManifest } from './manifest';
|
|
6
|
+
export { patchSSRRspackConfig, createSSRREnvConfig, createSSRMFConfig, setSSREnv, SSR_DIR, SSR_ENV_NAME, } from './ssr';
|