@module-federation/rsbuild-plugin 0.0.0-next-20241112074706 → 0.0.0-next-20241112091020
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/index.cjs.js +119 -113
- package/dist/index.esm.js +119 -114
- package/dist/src/cli/index.d.ts +1 -0
- package/package.json +3 -3
package/dist/index.cjs.js
CHANGED
|
@@ -278,134 +278,139 @@ function _ts_generator(thisArg, body) {
|
|
|
278
278
|
}
|
|
279
279
|
}
|
|
280
280
|
var PLUGIN_MODULE_FEDERATION_NAME = 'rsbuild:module-federation-enhanced';
|
|
281
|
-
var
|
|
282
|
-
return {
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
var
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
(_config_dev = config.dev).client || (_config_dev.client = {});
|
|
312
|
-
config.dev.client.port = config.server.port;
|
|
313
|
-
}
|
|
314
|
-
// Change the default assetPrefix to `true` for remote modules.
|
|
315
|
-
// This ensures that the remote module's assets can be requested by consumer apps with the correct URL.
|
|
316
|
-
var originalConfig = api.getRsbuildConfig('original');
|
|
317
|
-
if (((_originalConfig_dev = originalConfig.dev) === null || _originalConfig_dev === void 0 ? void 0 : _originalConfig_dev.assetPrefix) === undefined && config.dev.assetPrefix === ((_config_server1 = config.server) === null || _config_server1 === void 0 ? void 0 : _config_server1.base)) {
|
|
318
|
-
config.dev.assetPrefix = true;
|
|
319
|
-
}
|
|
281
|
+
var setupRsbuildConfig = function(moduleFederationOptions) {
|
|
282
|
+
return function(api) {
|
|
283
|
+
var sharedOptions = enhanced.parseOptions(moduleFederationOptions.shared || [], function(item, key) {
|
|
284
|
+
if (typeof item !== 'string') throw new Error('Unexpected array in shared');
|
|
285
|
+
var config = item === key || !sdk.isRequiredVersion(item) ? {
|
|
286
|
+
import: item
|
|
287
|
+
} : {
|
|
288
|
+
import: key,
|
|
289
|
+
requiredVersion: item
|
|
290
|
+
};
|
|
291
|
+
return config;
|
|
292
|
+
}, function(item) {
|
|
293
|
+
return item;
|
|
294
|
+
});
|
|
295
|
+
// shared[0] is the shared name
|
|
296
|
+
var shared = sharedOptions.map(function(shared) {
|
|
297
|
+
return shared[0].endsWith('/') ? shared[0].slice(0, -1) : shared[0];
|
|
298
|
+
});
|
|
299
|
+
api.modifyRsbuildConfig(function(config) {
|
|
300
|
+
// Change some default configs for remote modules
|
|
301
|
+
if (moduleFederationOptions.exposes) {
|
|
302
|
+
var _config_server, _config_dev_client, _originalConfig_dev, _config_server1;
|
|
303
|
+
var _config;
|
|
304
|
+
(_config = config).dev || (_config.dev = {});
|
|
305
|
+
// For remote modules, Rsbuild should send the ws request to the provider's dev server.
|
|
306
|
+
// This allows the provider to do HMR when the provider module is loaded in the consumer's page.
|
|
307
|
+
if (((_config_server = config.server) === null || _config_server === void 0 ? void 0 : _config_server.port) && !((_config_dev_client = config.dev.client) === null || _config_dev_client === void 0 ? void 0 : _config_dev_client.port)) {
|
|
308
|
+
var _config_dev;
|
|
309
|
+
(_config_dev = config.dev).client || (_config_dev.client = {});
|
|
310
|
+
config.dev.client.port = config.server.port;
|
|
320
311
|
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
var
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
* Currently, splitChunks will take precedence over module federation shared modules.
|
|
327
|
-
* So we need to disable the default split chunks rules to make shared modules to work properly.
|
|
328
|
-
* @see https://github.com/module-federation/module-federation-examples/issues/3161
|
|
329
|
-
*/ if (((_config_performance = config.performance) === null || _config_performance === void 0 ? void 0 : (_config_performance_chunkSplit = _config_performance.chunkSplit) === null || _config_performance_chunkSplit === void 0 ? void 0 : _config_performance_chunkSplit.strategy) === 'split-by-experience') {
|
|
330
|
-
config.performance.chunkSplit = _object_spread_props(_object_spread({}, config.performance.chunkSplit), {
|
|
331
|
-
strategy: 'custom'
|
|
332
|
-
});
|
|
312
|
+
// Change the default assetPrefix to `true` for remote modules.
|
|
313
|
+
// This ensures that the remote module's assets can be requested by consumer apps with the correct URL.
|
|
314
|
+
var originalConfig = api.getRsbuildConfig('original');
|
|
315
|
+
if (((_originalConfig_dev = originalConfig.dev) === null || _originalConfig_dev === void 0 ? void 0 : _originalConfig_dev.assetPrefix) === undefined && config.dev.assetPrefix === ((_config_server1 = config.server) === null || _config_server1 === void 0 ? void 0 : _config_server1.base)) {
|
|
316
|
+
config.dev.assetPrefix = true;
|
|
333
317
|
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
api.modifyEnvironmentConfig(function(config, param) {
|
|
321
|
+
var mergeEnvironmentConfig = param.mergeEnvironmentConfig;
|
|
322
|
+
var _config_performance_chunkSplit, _config_performance;
|
|
323
|
+
/**
|
|
324
|
+
* Currently, splitChunks will take precedence over module federation shared modules.
|
|
325
|
+
* So we need to disable the default split chunks rules to make shared modules to work properly.
|
|
326
|
+
* @see https://github.com/module-federation/module-federation-examples/issues/3161
|
|
327
|
+
*/ if (((_config_performance = config.performance) === null || _config_performance === void 0 ? void 0 : (_config_performance_chunkSplit = _config_performance.chunkSplit) === null || _config_performance_chunkSplit === void 0 ? void 0 : _config_performance_chunkSplit.strategy) === 'split-by-experience') {
|
|
328
|
+
config.performance.chunkSplit = _object_spread_props(_object_spread({}, config.performance.chunkSplit), {
|
|
329
|
+
strategy: 'custom'
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
// Module Federation runtime uses ES6+ syntax,
|
|
333
|
+
// adding to include and let SWC transform it
|
|
334
|
+
config.source.include = _to_consumable_array(config.source.include || []).concat([
|
|
335
|
+
/@module-federation[\\/]sdk/,
|
|
336
|
+
/@module-federation[\\/]runtime/
|
|
337
|
+
]);
|
|
338
|
+
// filter external with shared config,
|
|
339
|
+
var externals = config.output.externals;
|
|
340
|
+
if (Array.isArray(externals)) {
|
|
341
|
+
var sharedModules = new Set();
|
|
342
|
+
config.output.externals = externals.filter(function(ext) {
|
|
343
|
+
var sharedModule;
|
|
344
|
+
if (isRegExp(ext)) {
|
|
345
|
+
var match = shared.some(function(dep) {
|
|
346
|
+
if (ext.test(dep) || ext.test(pkgJson.name)) {
|
|
347
|
+
sharedModule = dep;
|
|
348
|
+
return true;
|
|
360
349
|
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
350
|
+
return false;
|
|
351
|
+
});
|
|
352
|
+
match && sharedModule && sharedModules.add(sharedModule);
|
|
353
|
+
return !match;
|
|
354
|
+
}
|
|
355
|
+
if (typeof ext === 'string') {
|
|
356
|
+
if (ext === pkgJson.name) {
|
|
357
|
+
return false;
|
|
358
|
+
}
|
|
359
|
+
var match1 = shared.some(function(dep) {
|
|
360
|
+
if (dep === ext) {
|
|
361
|
+
sharedModule = dep;
|
|
370
362
|
}
|
|
371
|
-
return
|
|
363
|
+
return dep === ext;
|
|
364
|
+
});
|
|
365
|
+
if (match1) {
|
|
366
|
+
sharedModule && sharedModules.add(sharedModule);
|
|
367
|
+
return false;
|
|
372
368
|
}
|
|
373
369
|
return true;
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
|
|
370
|
+
}
|
|
371
|
+
return true;
|
|
372
|
+
});
|
|
373
|
+
if (sharedModules.size > 0) {
|
|
374
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
375
|
+
try {
|
|
376
|
+
for(var _iterator = sharedModules[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
377
|
+
var sharedModule = _step.value;
|
|
378
|
+
logger.log("".concat(sharedModule, " is removed from externals because it is a shared module."));
|
|
379
|
+
}
|
|
380
|
+
} catch (err) {
|
|
381
|
+
_didIteratorError = true;
|
|
382
|
+
_iteratorError = err;
|
|
383
|
+
} finally{
|
|
377
384
|
try {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
logger.log("".concat(sharedModule, " is removed from externals because it is a shared module."));
|
|
385
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
386
|
+
_iterator.return();
|
|
381
387
|
}
|
|
382
|
-
} catch (err) {
|
|
383
|
-
_didIteratorError = true;
|
|
384
|
-
_iteratorError = err;
|
|
385
388
|
} finally{
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
_iterator.return();
|
|
389
|
-
}
|
|
390
|
-
} finally{
|
|
391
|
-
if (_didIteratorError) {
|
|
392
|
-
throw _iteratorError;
|
|
393
|
-
}
|
|
389
|
+
if (_didIteratorError) {
|
|
390
|
+
throw _iteratorError;
|
|
394
391
|
}
|
|
395
392
|
}
|
|
396
393
|
}
|
|
397
394
|
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
395
|
+
}
|
|
396
|
+
var mfConfig = {
|
|
397
|
+
tools: {
|
|
398
|
+
rspack: {
|
|
399
|
+
output: {
|
|
400
|
+
chunkLoading: 'jsonp'
|
|
404
401
|
}
|
|
405
402
|
}
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
return mergeEnvironmentConfig(config, mfConfig);
|
|
406
|
+
});
|
|
407
|
+
};
|
|
408
|
+
};
|
|
409
|
+
var pluginModuleFederation = function(moduleFederationOptions) {
|
|
410
|
+
return {
|
|
411
|
+
name: PLUGIN_MODULE_FEDERATION_NAME,
|
|
412
|
+
setup: function(api) {
|
|
413
|
+
setupRsbuildConfig(moduleFederationOptions)(api);
|
|
409
414
|
api.modifyBundlerChain(/*#__PURE__*/ function() {
|
|
410
415
|
var _ref = _async_to_generator(function(chain) {
|
|
411
416
|
return _ts_generator(this, function(_state) {
|
|
@@ -430,3 +435,4 @@ var pluginModuleFederation = function(moduleFederationOptions) {
|
|
|
430
435
|
};
|
|
431
436
|
|
|
432
437
|
exports.pluginModuleFederation = pluginModuleFederation;
|
|
438
|
+
exports.setupRsbuildConfig = setupRsbuildConfig;
|
package/dist/index.esm.js
CHANGED
|
@@ -276,134 +276,139 @@ function _ts_generator(thisArg, body) {
|
|
|
276
276
|
}
|
|
277
277
|
}
|
|
278
278
|
var PLUGIN_MODULE_FEDERATION_NAME = 'rsbuild:module-federation-enhanced';
|
|
279
|
-
var
|
|
280
|
-
return {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
var
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
(_config_dev = config.dev).client || (_config_dev.client = {});
|
|
310
|
-
config.dev.client.port = config.server.port;
|
|
311
|
-
}
|
|
312
|
-
// Change the default assetPrefix to `true` for remote modules.
|
|
313
|
-
// This ensures that the remote module's assets can be requested by consumer apps with the correct URL.
|
|
314
|
-
var originalConfig = api.getRsbuildConfig('original');
|
|
315
|
-
if (((_originalConfig_dev = originalConfig.dev) === null || _originalConfig_dev === void 0 ? void 0 : _originalConfig_dev.assetPrefix) === undefined && config.dev.assetPrefix === ((_config_server1 = config.server) === null || _config_server1 === void 0 ? void 0 : _config_server1.base)) {
|
|
316
|
-
config.dev.assetPrefix = true;
|
|
317
|
-
}
|
|
279
|
+
var setupRsbuildConfig = function(moduleFederationOptions) {
|
|
280
|
+
return function(api) {
|
|
281
|
+
var sharedOptions = parseOptions(moduleFederationOptions.shared || [], function(item, key) {
|
|
282
|
+
if (typeof item !== 'string') throw new Error('Unexpected array in shared');
|
|
283
|
+
var config = item === key || !isRequiredVersion(item) ? {
|
|
284
|
+
import: item
|
|
285
|
+
} : {
|
|
286
|
+
import: key,
|
|
287
|
+
requiredVersion: item
|
|
288
|
+
};
|
|
289
|
+
return config;
|
|
290
|
+
}, function(item) {
|
|
291
|
+
return item;
|
|
292
|
+
});
|
|
293
|
+
// shared[0] is the shared name
|
|
294
|
+
var shared = sharedOptions.map(function(shared) {
|
|
295
|
+
return shared[0].endsWith('/') ? shared[0].slice(0, -1) : shared[0];
|
|
296
|
+
});
|
|
297
|
+
api.modifyRsbuildConfig(function(config) {
|
|
298
|
+
// Change some default configs for remote modules
|
|
299
|
+
if (moduleFederationOptions.exposes) {
|
|
300
|
+
var _config_server, _config_dev_client, _originalConfig_dev, _config_server1;
|
|
301
|
+
var _config;
|
|
302
|
+
(_config = config).dev || (_config.dev = {});
|
|
303
|
+
// For remote modules, Rsbuild should send the ws request to the provider's dev server.
|
|
304
|
+
// This allows the provider to do HMR when the provider module is loaded in the consumer's page.
|
|
305
|
+
if (((_config_server = config.server) === null || _config_server === void 0 ? void 0 : _config_server.port) && !((_config_dev_client = config.dev.client) === null || _config_dev_client === void 0 ? void 0 : _config_dev_client.port)) {
|
|
306
|
+
var _config_dev;
|
|
307
|
+
(_config_dev = config.dev).client || (_config_dev.client = {});
|
|
308
|
+
config.dev.client.port = config.server.port;
|
|
318
309
|
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
var
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
* Currently, splitChunks will take precedence over module federation shared modules.
|
|
325
|
-
* So we need to disable the default split chunks rules to make shared modules to work properly.
|
|
326
|
-
* @see https://github.com/module-federation/module-federation-examples/issues/3161
|
|
327
|
-
*/ if (((_config_performance = config.performance) === null || _config_performance === void 0 ? void 0 : (_config_performance_chunkSplit = _config_performance.chunkSplit) === null || _config_performance_chunkSplit === void 0 ? void 0 : _config_performance_chunkSplit.strategy) === 'split-by-experience') {
|
|
328
|
-
config.performance.chunkSplit = _object_spread_props(_object_spread({}, config.performance.chunkSplit), {
|
|
329
|
-
strategy: 'custom'
|
|
330
|
-
});
|
|
310
|
+
// Change the default assetPrefix to `true` for remote modules.
|
|
311
|
+
// This ensures that the remote module's assets can be requested by consumer apps with the correct URL.
|
|
312
|
+
var originalConfig = api.getRsbuildConfig('original');
|
|
313
|
+
if (((_originalConfig_dev = originalConfig.dev) === null || _originalConfig_dev === void 0 ? void 0 : _originalConfig_dev.assetPrefix) === undefined && config.dev.assetPrefix === ((_config_server1 = config.server) === null || _config_server1 === void 0 ? void 0 : _config_server1.base)) {
|
|
314
|
+
config.dev.assetPrefix = true;
|
|
331
315
|
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
api.modifyEnvironmentConfig(function(config, param) {
|
|
319
|
+
var mergeEnvironmentConfig = param.mergeEnvironmentConfig;
|
|
320
|
+
var _config_performance_chunkSplit, _config_performance;
|
|
321
|
+
/**
|
|
322
|
+
* Currently, splitChunks will take precedence over module federation shared modules.
|
|
323
|
+
* So we need to disable the default split chunks rules to make shared modules to work properly.
|
|
324
|
+
* @see https://github.com/module-federation/module-federation-examples/issues/3161
|
|
325
|
+
*/ if (((_config_performance = config.performance) === null || _config_performance === void 0 ? void 0 : (_config_performance_chunkSplit = _config_performance.chunkSplit) === null || _config_performance_chunkSplit === void 0 ? void 0 : _config_performance_chunkSplit.strategy) === 'split-by-experience') {
|
|
326
|
+
config.performance.chunkSplit = _object_spread_props(_object_spread({}, config.performance.chunkSplit), {
|
|
327
|
+
strategy: 'custom'
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
// Module Federation runtime uses ES6+ syntax,
|
|
331
|
+
// adding to include and let SWC transform it
|
|
332
|
+
config.source.include = _to_consumable_array(config.source.include || []).concat([
|
|
333
|
+
/@module-federation[\\/]sdk/,
|
|
334
|
+
/@module-federation[\\/]runtime/
|
|
335
|
+
]);
|
|
336
|
+
// filter external with shared config,
|
|
337
|
+
var externals = config.output.externals;
|
|
338
|
+
if (Array.isArray(externals)) {
|
|
339
|
+
var sharedModules = new Set();
|
|
340
|
+
config.output.externals = externals.filter(function(ext) {
|
|
341
|
+
var sharedModule;
|
|
342
|
+
if (isRegExp(ext)) {
|
|
343
|
+
var match = shared.some(function(dep) {
|
|
344
|
+
if (ext.test(dep) || ext.test(pkgJson.name)) {
|
|
345
|
+
sharedModule = dep;
|
|
346
|
+
return true;
|
|
358
347
|
}
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
348
|
+
return false;
|
|
349
|
+
});
|
|
350
|
+
match && sharedModule && sharedModules.add(sharedModule);
|
|
351
|
+
return !match;
|
|
352
|
+
}
|
|
353
|
+
if (typeof ext === 'string') {
|
|
354
|
+
if (ext === pkgJson.name) {
|
|
355
|
+
return false;
|
|
356
|
+
}
|
|
357
|
+
var match1 = shared.some(function(dep) {
|
|
358
|
+
if (dep === ext) {
|
|
359
|
+
sharedModule = dep;
|
|
368
360
|
}
|
|
369
|
-
return
|
|
361
|
+
return dep === ext;
|
|
362
|
+
});
|
|
363
|
+
if (match1) {
|
|
364
|
+
sharedModule && sharedModules.add(sharedModule);
|
|
365
|
+
return false;
|
|
370
366
|
}
|
|
371
367
|
return true;
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
|
|
368
|
+
}
|
|
369
|
+
return true;
|
|
370
|
+
});
|
|
371
|
+
if (sharedModules.size > 0) {
|
|
372
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
373
|
+
try {
|
|
374
|
+
for(var _iterator = sharedModules[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
375
|
+
var sharedModule = _step.value;
|
|
376
|
+
logger.log("".concat(sharedModule, " is removed from externals because it is a shared module."));
|
|
377
|
+
}
|
|
378
|
+
} catch (err) {
|
|
379
|
+
_didIteratorError = true;
|
|
380
|
+
_iteratorError = err;
|
|
381
|
+
} finally{
|
|
375
382
|
try {
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
logger.log("".concat(sharedModule, " is removed from externals because it is a shared module."));
|
|
383
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
384
|
+
_iterator.return();
|
|
379
385
|
}
|
|
380
|
-
} catch (err) {
|
|
381
|
-
_didIteratorError = true;
|
|
382
|
-
_iteratorError = err;
|
|
383
386
|
} finally{
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
_iterator.return();
|
|
387
|
-
}
|
|
388
|
-
} finally{
|
|
389
|
-
if (_didIteratorError) {
|
|
390
|
-
throw _iteratorError;
|
|
391
|
-
}
|
|
387
|
+
if (_didIteratorError) {
|
|
388
|
+
throw _iteratorError;
|
|
392
389
|
}
|
|
393
390
|
}
|
|
394
391
|
}
|
|
395
392
|
}
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
393
|
+
}
|
|
394
|
+
var mfConfig = {
|
|
395
|
+
tools: {
|
|
396
|
+
rspack: {
|
|
397
|
+
output: {
|
|
398
|
+
chunkLoading: 'jsonp'
|
|
402
399
|
}
|
|
403
400
|
}
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
|
|
401
|
+
}
|
|
402
|
+
};
|
|
403
|
+
return mergeEnvironmentConfig(config, mfConfig);
|
|
404
|
+
});
|
|
405
|
+
};
|
|
406
|
+
};
|
|
407
|
+
var pluginModuleFederation = function(moduleFederationOptions) {
|
|
408
|
+
return {
|
|
409
|
+
name: PLUGIN_MODULE_FEDERATION_NAME,
|
|
410
|
+
setup: function(api) {
|
|
411
|
+
setupRsbuildConfig(moduleFederationOptions)(api);
|
|
407
412
|
api.modifyBundlerChain(/*#__PURE__*/ function() {
|
|
408
413
|
var _ref = _async_to_generator(function(chain) {
|
|
409
414
|
return _ts_generator(this, function(_state) {
|
|
@@ -427,4 +432,4 @@ var pluginModuleFederation = function(moduleFederationOptions) {
|
|
|
427
432
|
};
|
|
428
433
|
};
|
|
429
434
|
|
|
430
|
-
export { pluginModuleFederation };
|
|
435
|
+
export { pluginModuleFederation, setupRsbuildConfig };
|
package/dist/src/cli/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { moduleFederationPlugin } from '@module-federation/sdk';
|
|
2
2
|
import type { RsbuildPlugin } from '@rsbuild/core';
|
|
3
3
|
type ModuleFederationOptions = moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
4
|
+
export declare const setupRsbuildConfig: (moduleFederationOptions: ModuleFederationOptions) => RsbuildPlugin['setup'];
|
|
4
5
|
export declare const pluginModuleFederation: (moduleFederationOptions: ModuleFederationOptions) => RsbuildPlugin;
|
|
5
6
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/rsbuild-plugin",
|
|
3
|
-
"version": "0.0.0-next-
|
|
3
|
+
"version": "0.0.0-next-20241112091020",
|
|
4
4
|
"description": "Module Federation plugin for Rsbuild",
|
|
5
5
|
"homepage": "https://module-federation.io",
|
|
6
6
|
"bugs": {
|
|
@@ -32,14 +32,14 @@
|
|
|
32
32
|
"dist"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@module-federation/sdk": "0.0.0-next-
|
|
35
|
+
"@module-federation/sdk": "0.0.0-next-20241112091020"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@rsbuild/core": "^1.0.19"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
41
|
"@rsbuild/core": "1.x",
|
|
42
|
-
"@module-federation/enhanced": "0.0.0-next-
|
|
42
|
+
"@module-federation/enhanced": "0.0.0-next-20241112091020"
|
|
43
43
|
},
|
|
44
44
|
"engines": {
|
|
45
45
|
"node": ">=16.0.0"
|