@module-federation/rsbuild-plugin 0.8.4 → 0.8.6

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 CHANGED
@@ -3,14 +3,11 @@
3
3
  var enhanced = require('@module-federation/enhanced');
4
4
  var rspack = require('@module-federation/enhanced/rspack');
5
5
  var sdk = require('@module-federation/sdk');
6
- var util = require('util');
7
-
8
- function isRegExp(target) {
9
- return util.types.isRegExp(target);
10
- }
6
+ var utils = require('./utils.cjs.js');
7
+ require('util');
11
8
 
12
9
  var name = "@module-federation/rsbuild-plugin";
13
- var version = "0.8.4";
10
+ var version = "0.8.6";
14
11
  var description = "Module Federation plugin for Rsbuild";
15
12
  var homepage = "https://module-federation.io";
16
13
  var bugs = {
@@ -24,9 +21,14 @@ var repository = {
24
21
  var license = "MIT";
25
22
  var exports$1 = {
26
23
  ".": {
24
+ types: "./dist/index.cjs.d.ts",
27
25
  "import": "./dist/index.esm.js",
28
- require: "./dist/index.cjs.js",
29
- types: "./dist/index.cjs.d.ts"
26
+ require: "./dist/index.cjs.js"
27
+ },
28
+ "./utils": {
29
+ types: "./dist/utils.cjs.d.ts",
30
+ "import": "./dist/utils.esm.js",
31
+ require: "./dist/utils.cjs.js"
30
32
  }
31
33
  };
32
34
  var main = "./dist/index.cjs.js";
@@ -35,6 +37,9 @@ var typesVersions = {
35
37
  "*": {
36
38
  ".": [
37
39
  "./dist/index.cjs.d.ts"
40
+ ],
41
+ utils: [
42
+ "./dist/utils.cjs.d.ts"
38
43
  ]
39
44
  }
40
45
  };
@@ -51,6 +56,14 @@ var peerDependencies = {
51
56
  "@module-federation/enhanced": "workspace:*",
52
57
  "@rsbuild/core": "1.x"
53
58
  };
59
+ var peerDependenciesMeta = {
60
+ "@rsbuild/core": {
61
+ optional: true
62
+ },
63
+ "@module-federation/enhanced": {
64
+ optional: true
65
+ }
66
+ };
54
67
  var engines = {
55
68
  node: ">=16.0.0"
56
69
  };
@@ -75,6 +88,7 @@ var pkgJson = {
75
88
  dependencies: dependencies,
76
89
  devDependencies: devDependencies,
77
90
  peerDependencies: peerDependencies,
91
+ peerDependenciesMeta: peerDependenciesMeta,
78
92
  engines: engines,
79
93
  publishConfig: publishConfig
80
94
  };
@@ -89,91 +103,19 @@ function _array_like_to_array(arr, len) {
89
103
  function _array_without_holes(arr) {
90
104
  if (Array.isArray(arr)) return _array_like_to_array(arr);
91
105
  }
92
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
93
- try {
94
- var info = gen[key](arg);
95
- var value = info.value;
96
- } catch (error) {
97
- reject(error);
98
- return;
99
- }
100
- if (info.done) {
101
- resolve(value);
102
- } else {
103
- Promise.resolve(value).then(_next, _throw);
104
- }
105
- }
106
- function _async_to_generator(fn) {
107
- return function() {
108
- var self = this, args = arguments;
109
- return new Promise(function(resolve, reject) {
110
- var gen = fn.apply(self, args);
111
- function _next(value) {
112
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
113
- }
114
- function _throw(err) {
115
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
116
- }
117
- _next(undefined);
118
- });
119
- };
120
- }
121
- function _define_property(obj, key, value) {
122
- if (key in obj) {
123
- Object.defineProperty(obj, key, {
124
- value: value,
125
- enumerable: true,
126
- configurable: true,
127
- writable: true
128
- });
129
- } else {
130
- obj[key] = value;
131
- }
132
- return obj;
133
- }
134
106
  function _iterable_to_array(iter) {
135
107
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
136
108
  }
137
109
  function _non_iterable_spread() {
138
110
  throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
139
111
  }
140
- function _object_spread(target) {
141
- for(var i = 1; i < arguments.length; i++){
142
- var source = arguments[i] != null ? arguments[i] : {};
143
- var ownKeys = Object.keys(source);
144
- if (typeof Object.getOwnPropertySymbols === "function") {
145
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
146
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
147
- }));
148
- }
149
- ownKeys.forEach(function(key) {
150
- _define_property(target, key, source[key]);
151
- });
152
- }
153
- return target;
154
- }
155
- function ownKeys(object, enumerableOnly) {
156
- var keys = Object.keys(object);
157
- if (Object.getOwnPropertySymbols) {
158
- var symbols = Object.getOwnPropertySymbols(object);
159
- keys.push.apply(keys, symbols);
160
- }
161
- return keys;
162
- }
163
- function _object_spread_props(target, source) {
164
- source = source != null ? source : {};
165
- if (Object.getOwnPropertyDescriptors) {
166
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
167
- } else {
168
- ownKeys(Object(source)).forEach(function(key) {
169
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
170
- });
171
- }
172
- return target;
173
- }
174
112
  function _to_consumable_array(arr) {
175
113
  return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
176
114
  }
115
+ function _type_of(obj) {
116
+ "@swc/helpers - typeof";
117
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
118
+ }
177
119
  function _unsupported_iterable_to_array(o, minLen) {
178
120
  if (!o) return;
179
121
  if (typeof o === "string") return _array_like_to_array(o, minLen);
@@ -182,105 +124,21 @@ function _unsupported_iterable_to_array(o, minLen) {
182
124
  if (n === "Map" || n === "Set") return Array.from(n);
183
125
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
184
126
  }
185
- function _ts_generator(thisArg, body) {
186
- var f, y, t, g, _ = {
187
- label: 0,
188
- sent: function() {
189
- if (t[0] & 1) throw t[1];
190
- return t[1];
191
- },
192
- trys: [],
193
- ops: []
194
- };
195
- return g = {
196
- next: verb(0),
197
- "throw": verb(1),
198
- "return": verb(2)
199
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
200
- return this;
201
- }), g;
202
- function verb(n) {
203
- return function(v) {
204
- return step([
205
- n,
206
- v
207
- ]);
208
- };
209
- }
210
- function step(op) {
211
- if (f) throw new TypeError("Generator is already executing.");
212
- while(_)try {
213
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
214
- if (y = 0, t) op = [
215
- op[0] & 2,
216
- t.value
217
- ];
218
- switch(op[0]){
219
- case 0:
220
- case 1:
221
- t = op;
222
- break;
223
- case 4:
224
- _.label++;
225
- return {
226
- value: op[1],
227
- done: false
228
- };
229
- case 5:
230
- _.label++;
231
- y = op[1];
232
- op = [
233
- 0
234
- ];
235
- continue;
236
- case 7:
237
- op = _.ops.pop();
238
- _.trys.pop();
239
- continue;
240
- default:
241
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
242
- _ = 0;
243
- continue;
244
- }
245
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
246
- _.label = op[1];
247
- break;
248
- }
249
- if (op[0] === 6 && _.label < t[1]) {
250
- _.label = t[1];
251
- t = op;
252
- break;
253
- }
254
- if (t && _.label < t[2]) {
255
- _.label = t[2];
256
- _.ops.push(op);
257
- break;
258
- }
259
- if (t[2]) _.ops.pop();
260
- _.trys.pop();
261
- continue;
262
- }
263
- op = body.call(thisArg, _);
264
- } catch (e) {
265
- op = [
266
- 6,
267
- e
268
- ];
269
- y = 0;
270
- } finally{
271
- f = t = 0;
272
- }
273
- if (op[0] & 5) throw op[1];
274
- return {
275
- value: op[0] ? op[1] : void 0,
276
- done: true
277
- };
278
- }
127
+ var RSBUILD_PLUGIN_MODULE_FEDERATION_NAME = 'rsbuild:module-federation-enhanced';
128
+ var RSPACK_PLUGIN_MODULE_FEDERATION_NAME = 'module-federation';
129
+ var LIB_FORMAT = [
130
+ 'commonjs',
131
+ 'umd',
132
+ 'modern-module'
133
+ ];
134
+ function isMFFormat(bundlerConfig) {
135
+ var _bundlerConfig_output;
136
+ var library = (_bundlerConfig_output = bundlerConfig.output) === null || _bundlerConfig_output === void 0 ? void 0 : _bundlerConfig_output.library;
137
+ return !((typeof library === "undefined" ? "undefined" : _type_of(library)) === 'object' && !Array.isArray(library) && 'type' in library && LIB_FORMAT.includes(library.type));
279
138
  }
280
- var PLUGIN_MODULE_FEDERATION_NAME = 'rsbuild:module-federation-enhanced';
281
139
  var pluginModuleFederation = function(moduleFederationOptions) {
282
140
  return {
283
- name: PLUGIN_MODULE_FEDERATION_NAME,
141
+ name: RSBUILD_PLUGIN_MODULE_FEDERATION_NAME,
284
142
  setup: function(api) {
285
143
  var sharedOptions = enhanced.parseOptions(moduleFederationOptions.shared || [], function(item, key) {
286
144
  if (typeof item !== 'string') throw new Error('Unexpected array in shared');
@@ -298,6 +156,91 @@ var pluginModuleFederation = function(moduleFederationOptions) {
298
156
  var shared = sharedOptions.map(function(shared) {
299
157
  return shared[0].endsWith('/') ? shared[0].slice(0, -1) : shared[0];
300
158
  });
159
+ api.onBeforeCreateCompiler(function(param) {
160
+ var bundlerConfigs = param.bundlerConfigs;
161
+ if (!bundlerConfigs) {
162
+ throw new Error('Can not get bundlerConfigs!');
163
+ }
164
+ bundlerConfigs.forEach(function(bundlerConfig) {
165
+ if (!isMFFormat(bundlerConfig)) {
166
+ return;
167
+ } else {
168
+ var _bundlerConfig_output, _bundlerConfig_output1;
169
+ // mf
170
+ utils.autoDeleteSplitChunkCacheGroups(moduleFederationOptions, bundlerConfig);
171
+ var externals = bundlerConfig.externals;
172
+ if (Array.isArray(externals)) {
173
+ var sharedModules = new Set();
174
+ bundlerConfig.externals = externals.filter(function(ext) {
175
+ var sharedModule;
176
+ if (utils.isRegExp(ext)) {
177
+ var match = shared.some(function(dep) {
178
+ if (ext.test(dep) || ext.test(pkgJson.name)) {
179
+ sharedModule = dep;
180
+ return true;
181
+ }
182
+ return false;
183
+ });
184
+ match && sharedModule && sharedModules.add(sharedModule);
185
+ return !match;
186
+ }
187
+ if (typeof ext === 'string') {
188
+ if (ext === pkgJson.name) {
189
+ return false;
190
+ }
191
+ var match1 = shared.some(function(dep) {
192
+ if (dep === ext) {
193
+ sharedModule = dep;
194
+ }
195
+ return dep === ext;
196
+ });
197
+ if (match1) {
198
+ sharedModule && sharedModules.add(sharedModule);
199
+ return false;
200
+ }
201
+ return true;
202
+ }
203
+ return true;
204
+ });
205
+ if (sharedModules.size > 0) {
206
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
207
+ try {
208
+ for(var _iterator = sharedModules[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
209
+ var sharedModule = _step.value;
210
+ logger.log("".concat(sharedModule, " is removed from externals because it is a shared module."));
211
+ }
212
+ } catch (err) {
213
+ _didIteratorError = true;
214
+ _iteratorError = err;
215
+ } finally{
216
+ try {
217
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
218
+ _iterator.return();
219
+ }
220
+ } finally{
221
+ if (_didIteratorError) {
222
+ throw _iteratorError;
223
+ }
224
+ }
225
+ }
226
+ }
227
+ }
228
+ if (!((_bundlerConfig_output = bundlerConfig.output) === null || _bundlerConfig_output === void 0 ? void 0 : _bundlerConfig_output.chunkLoadingGlobal)) {
229
+ bundlerConfig.output.chunkLoading = 'jsonp';
230
+ }
231
+ // `uniqueName` is required for react refresh to work
232
+ if (!((_bundlerConfig_output1 = bundlerConfig.output) === null || _bundlerConfig_output1 === void 0 ? void 0 : _bundlerConfig_output1.uniqueName)) {
233
+ bundlerConfig.output.uniqueName = moduleFederationOptions.name;
234
+ }
235
+ if (!bundlerConfig.plugins.find(function(p) {
236
+ return p && p.name === rspack.PLUGIN_NAME;
237
+ })) {
238
+ bundlerConfig.plugins.push(new rspack.ModuleFederationPlugin(moduleFederationOptions));
239
+ }
240
+ }
241
+ });
242
+ });
243
+ // dev config only works on format: 'mf'
301
244
  api.modifyRsbuildConfig(function(config) {
302
245
  // Change some default configs for remote modules
303
246
  if (moduleFederationOptions.exposes) {
@@ -319,114 +262,24 @@ var pluginModuleFederation = function(moduleFederationOptions) {
319
262
  }
320
263
  }
321
264
  });
322
- api.modifyEnvironmentConfig(function(config, param) {
323
- var mergeEnvironmentConfig = param.mergeEnvironmentConfig;
324
- var _config_performance_chunkSplit, _config_performance;
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
- });
333
- }
265
+ api.modifyEnvironmentConfig(function(config) {
334
266
  // Module Federation runtime uses ES6+ syntax,
335
267
  // adding to include and let SWC transform it
336
268
  config.source.include = _to_consumable_array(config.source.include || []).concat([
337
269
  /@module-federation[\\/]sdk/,
338
270
  /@module-federation[\\/]runtime/
339
271
  ]);
340
- // filter external with shared config,
341
- var externals = config.output.externals;
342
- if (Array.isArray(externals)) {
343
- var sharedModules = new Set();
344
- config.output.externals = externals.filter(function(ext) {
345
- var sharedModule;
346
- if (isRegExp(ext)) {
347
- var match = shared.some(function(dep) {
348
- if (ext.test(dep) || ext.test(pkgJson.name)) {
349
- sharedModule = dep;
350
- return true;
351
- }
352
- return false;
353
- });
354
- match && sharedModule && sharedModules.add(sharedModule);
355
- return !match;
356
- }
357
- if (typeof ext === 'string') {
358
- if (ext === pkgJson.name) {
359
- return false;
360
- }
361
- var match1 = shared.some(function(dep) {
362
- if (dep === ext) {
363
- sharedModule = dep;
364
- }
365
- return dep === ext;
366
- });
367
- if (match1) {
368
- sharedModule && sharedModules.add(sharedModule);
369
- return false;
370
- }
371
- return true;
372
- }
373
- return true;
374
- });
375
- if (sharedModules.size > 0) {
376
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
377
- try {
378
- for(var _iterator = sharedModules[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
379
- var sharedModule = _step.value;
380
- logger.log("".concat(sharedModule, " is removed from externals because it is a shared module."));
381
- }
382
- } catch (err) {
383
- _didIteratorError = true;
384
- _iteratorError = err;
385
- } finally{
386
- try {
387
- if (!_iteratorNormalCompletion && _iterator.return != null) {
388
- _iterator.return();
389
- }
390
- } finally{
391
- if (_didIteratorError) {
392
- throw _iteratorError;
393
- }
394
- }
395
- }
396
- }
397
- }
398
- var mfConfig = {
399
- tools: {
400
- rspack: {
401
- output: {
402
- chunkLoading: 'jsonp'
403
- }
404
- }
405
- }
406
- };
407
- return mergeEnvironmentConfig(config, mfConfig);
272
+ return config;
408
273
  });
409
- api.modifyBundlerChain(/*#__PURE__*/ function() {
410
- var _ref = _async_to_generator(function(chain) {
411
- return _ts_generator(this, function(_state) {
412
- chain.plugin('module-federation').use(rspack.ModuleFederationPlugin, [
413
- moduleFederationOptions
414
- ]);
415
- // `uniqueName` is required for react refresh to work
416
- if (!chain.output.get('uniqueName')) {
417
- chain.output.set('uniqueName', moduleFederationOptions.name);
418
- }
419
- return [
420
- 2
421
- ];
422
- });
423
- });
424
- return function(chain) {
425
- return _ref.apply(this, arguments);
426
- };
427
- }());
428
274
  }
429
275
  };
430
276
  };
431
277
 
278
+ Object.defineProperty(exports, "PLUGIN_NAME", {
279
+ enumerable: true,
280
+ get: function () { return rspack.PLUGIN_NAME; }
281
+ });
282
+ exports.RSBUILD_PLUGIN_MODULE_FEDERATION_NAME = RSBUILD_PLUGIN_MODULE_FEDERATION_NAME;
283
+ exports.RSPACK_PLUGIN_MODULE_FEDERATION_NAME = RSPACK_PLUGIN_MODULE_FEDERATION_NAME;
284
+ exports.isMFFormat = isMFFormat;
432
285
  exports.pluginModuleFederation = pluginModuleFederation;
package/dist/index.esm.js CHANGED
@@ -1,14 +1,12 @@
1
1
  import { parseOptions } from '@module-federation/enhanced';
2
- import { ModuleFederationPlugin } from '@module-federation/enhanced/rspack';
2
+ import { PLUGIN_NAME, ModuleFederationPlugin } from '@module-federation/enhanced/rspack';
3
+ export { PLUGIN_NAME } from '@module-federation/enhanced/rspack';
3
4
  import { createLogger, isRequiredVersion } from '@module-federation/sdk';
4
- import util from 'util';
5
-
6
- function isRegExp(target) {
7
- return util.types.isRegExp(target);
8
- }
5
+ import { autoDeleteSplitChunkCacheGroups, isRegExp } from './utils.esm.js';
6
+ import 'util';
9
7
 
10
8
  var name = "@module-federation/rsbuild-plugin";
11
- var version = "0.8.4";
9
+ var version = "0.8.6";
12
10
  var description = "Module Federation plugin for Rsbuild";
13
11
  var homepage = "https://module-federation.io";
14
12
  var bugs = {
@@ -22,9 +20,14 @@ var repository = {
22
20
  var license = "MIT";
23
21
  var exports = {
24
22
  ".": {
23
+ types: "./dist/index.cjs.d.ts",
25
24
  "import": "./dist/index.esm.js",
26
- require: "./dist/index.cjs.js",
27
- types: "./dist/index.cjs.d.ts"
25
+ require: "./dist/index.cjs.js"
26
+ },
27
+ "./utils": {
28
+ types: "./dist/utils.cjs.d.ts",
29
+ "import": "./dist/utils.esm.js",
30
+ require: "./dist/utils.cjs.js"
28
31
  }
29
32
  };
30
33
  var main = "./dist/index.cjs.js";
@@ -33,6 +36,9 @@ var typesVersions = {
33
36
  "*": {
34
37
  ".": [
35
38
  "./dist/index.cjs.d.ts"
39
+ ],
40
+ utils: [
41
+ "./dist/utils.cjs.d.ts"
36
42
  ]
37
43
  }
38
44
  };
@@ -49,6 +55,14 @@ var peerDependencies = {
49
55
  "@module-federation/enhanced": "workspace:*",
50
56
  "@rsbuild/core": "1.x"
51
57
  };
58
+ var peerDependenciesMeta = {
59
+ "@rsbuild/core": {
60
+ optional: true
61
+ },
62
+ "@module-federation/enhanced": {
63
+ optional: true
64
+ }
65
+ };
52
66
  var engines = {
53
67
  node: ">=16.0.0"
54
68
  };
@@ -73,6 +87,7 @@ var pkgJson = {
73
87
  dependencies: dependencies,
74
88
  devDependencies: devDependencies,
75
89
  peerDependencies: peerDependencies,
90
+ peerDependenciesMeta: peerDependenciesMeta,
76
91
  engines: engines,
77
92
  publishConfig: publishConfig
78
93
  };
@@ -87,91 +102,19 @@ function _array_like_to_array(arr, len) {
87
102
  function _array_without_holes(arr) {
88
103
  if (Array.isArray(arr)) return _array_like_to_array(arr);
89
104
  }
90
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
91
- try {
92
- var info = gen[key](arg);
93
- var value = info.value;
94
- } catch (error) {
95
- reject(error);
96
- return;
97
- }
98
- if (info.done) {
99
- resolve(value);
100
- } else {
101
- Promise.resolve(value).then(_next, _throw);
102
- }
103
- }
104
- function _async_to_generator(fn) {
105
- return function() {
106
- var self = this, args = arguments;
107
- return new Promise(function(resolve, reject) {
108
- var gen = fn.apply(self, args);
109
- function _next(value) {
110
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
111
- }
112
- function _throw(err) {
113
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
114
- }
115
- _next(undefined);
116
- });
117
- };
118
- }
119
- function _define_property(obj, key, value) {
120
- if (key in obj) {
121
- Object.defineProperty(obj, key, {
122
- value: value,
123
- enumerable: true,
124
- configurable: true,
125
- writable: true
126
- });
127
- } else {
128
- obj[key] = value;
129
- }
130
- return obj;
131
- }
132
105
  function _iterable_to_array(iter) {
133
106
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
134
107
  }
135
108
  function _non_iterable_spread() {
136
109
  throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
137
110
  }
138
- function _object_spread(target) {
139
- for(var i = 1; i < arguments.length; i++){
140
- var source = arguments[i] != null ? arguments[i] : {};
141
- var ownKeys = Object.keys(source);
142
- if (typeof Object.getOwnPropertySymbols === "function") {
143
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
144
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
145
- }));
146
- }
147
- ownKeys.forEach(function(key) {
148
- _define_property(target, key, source[key]);
149
- });
150
- }
151
- return target;
152
- }
153
- function ownKeys(object, enumerableOnly) {
154
- var keys = Object.keys(object);
155
- if (Object.getOwnPropertySymbols) {
156
- var symbols = Object.getOwnPropertySymbols(object);
157
- keys.push.apply(keys, symbols);
158
- }
159
- return keys;
160
- }
161
- function _object_spread_props(target, source) {
162
- source = source != null ? source : {};
163
- if (Object.getOwnPropertyDescriptors) {
164
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
165
- } else {
166
- ownKeys(Object(source)).forEach(function(key) {
167
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
168
- });
169
- }
170
- return target;
171
- }
172
111
  function _to_consumable_array(arr) {
173
112
  return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
174
113
  }
114
+ function _type_of(obj) {
115
+ "@swc/helpers - typeof";
116
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
117
+ }
175
118
  function _unsupported_iterable_to_array(o, minLen) {
176
119
  if (!o) return;
177
120
  if (typeof o === "string") return _array_like_to_array(o, minLen);
@@ -180,105 +123,21 @@ function _unsupported_iterable_to_array(o, minLen) {
180
123
  if (n === "Map" || n === "Set") return Array.from(n);
181
124
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
182
125
  }
183
- function _ts_generator(thisArg, body) {
184
- var f, y, t, g, _ = {
185
- label: 0,
186
- sent: function() {
187
- if (t[0] & 1) throw t[1];
188
- return t[1];
189
- },
190
- trys: [],
191
- ops: []
192
- };
193
- return g = {
194
- next: verb(0),
195
- "throw": verb(1),
196
- "return": verb(2)
197
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
198
- return this;
199
- }), g;
200
- function verb(n) {
201
- return function(v) {
202
- return step([
203
- n,
204
- v
205
- ]);
206
- };
207
- }
208
- function step(op) {
209
- if (f) throw new TypeError("Generator is already executing.");
210
- while(_)try {
211
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
212
- if (y = 0, t) op = [
213
- op[0] & 2,
214
- t.value
215
- ];
216
- switch(op[0]){
217
- case 0:
218
- case 1:
219
- t = op;
220
- break;
221
- case 4:
222
- _.label++;
223
- return {
224
- value: op[1],
225
- done: false
226
- };
227
- case 5:
228
- _.label++;
229
- y = op[1];
230
- op = [
231
- 0
232
- ];
233
- continue;
234
- case 7:
235
- op = _.ops.pop();
236
- _.trys.pop();
237
- continue;
238
- default:
239
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
240
- _ = 0;
241
- continue;
242
- }
243
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
244
- _.label = op[1];
245
- break;
246
- }
247
- if (op[0] === 6 && _.label < t[1]) {
248
- _.label = t[1];
249
- t = op;
250
- break;
251
- }
252
- if (t && _.label < t[2]) {
253
- _.label = t[2];
254
- _.ops.push(op);
255
- break;
256
- }
257
- if (t[2]) _.ops.pop();
258
- _.trys.pop();
259
- continue;
260
- }
261
- op = body.call(thisArg, _);
262
- } catch (e) {
263
- op = [
264
- 6,
265
- e
266
- ];
267
- y = 0;
268
- } finally{
269
- f = t = 0;
270
- }
271
- if (op[0] & 5) throw op[1];
272
- return {
273
- value: op[0] ? op[1] : void 0,
274
- done: true
275
- };
276
- }
126
+ var RSBUILD_PLUGIN_MODULE_FEDERATION_NAME = 'rsbuild:module-federation-enhanced';
127
+ var RSPACK_PLUGIN_MODULE_FEDERATION_NAME = 'module-federation';
128
+ var LIB_FORMAT = [
129
+ 'commonjs',
130
+ 'umd',
131
+ 'modern-module'
132
+ ];
133
+ function isMFFormat(bundlerConfig) {
134
+ var _bundlerConfig_output;
135
+ var library = (_bundlerConfig_output = bundlerConfig.output) === null || _bundlerConfig_output === void 0 ? void 0 : _bundlerConfig_output.library;
136
+ return !((typeof library === "undefined" ? "undefined" : _type_of(library)) === 'object' && !Array.isArray(library) && 'type' in library && LIB_FORMAT.includes(library.type));
277
137
  }
278
- var PLUGIN_MODULE_FEDERATION_NAME = 'rsbuild:module-federation-enhanced';
279
138
  var pluginModuleFederation = function(moduleFederationOptions) {
280
139
  return {
281
- name: PLUGIN_MODULE_FEDERATION_NAME,
140
+ name: RSBUILD_PLUGIN_MODULE_FEDERATION_NAME,
282
141
  setup: function(api) {
283
142
  var sharedOptions = parseOptions(moduleFederationOptions.shared || [], function(item, key) {
284
143
  if (typeof item !== 'string') throw new Error('Unexpected array in shared');
@@ -296,6 +155,91 @@ var pluginModuleFederation = function(moduleFederationOptions) {
296
155
  var shared = sharedOptions.map(function(shared) {
297
156
  return shared[0].endsWith('/') ? shared[0].slice(0, -1) : shared[0];
298
157
  });
158
+ api.onBeforeCreateCompiler(function(param) {
159
+ var bundlerConfigs = param.bundlerConfigs;
160
+ if (!bundlerConfigs) {
161
+ throw new Error('Can not get bundlerConfigs!');
162
+ }
163
+ bundlerConfigs.forEach(function(bundlerConfig) {
164
+ if (!isMFFormat(bundlerConfig)) {
165
+ return;
166
+ } else {
167
+ var _bundlerConfig_output, _bundlerConfig_output1;
168
+ // mf
169
+ autoDeleteSplitChunkCacheGroups(moduleFederationOptions, bundlerConfig);
170
+ var externals = bundlerConfig.externals;
171
+ if (Array.isArray(externals)) {
172
+ var sharedModules = new Set();
173
+ bundlerConfig.externals = externals.filter(function(ext) {
174
+ var sharedModule;
175
+ if (isRegExp(ext)) {
176
+ var match = shared.some(function(dep) {
177
+ if (ext.test(dep) || ext.test(pkgJson.name)) {
178
+ sharedModule = dep;
179
+ return true;
180
+ }
181
+ return false;
182
+ });
183
+ match && sharedModule && sharedModules.add(sharedModule);
184
+ return !match;
185
+ }
186
+ if (typeof ext === 'string') {
187
+ if (ext === pkgJson.name) {
188
+ return false;
189
+ }
190
+ var match1 = shared.some(function(dep) {
191
+ if (dep === ext) {
192
+ sharedModule = dep;
193
+ }
194
+ return dep === ext;
195
+ });
196
+ if (match1) {
197
+ sharedModule && sharedModules.add(sharedModule);
198
+ return false;
199
+ }
200
+ return true;
201
+ }
202
+ return true;
203
+ });
204
+ if (sharedModules.size > 0) {
205
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
206
+ try {
207
+ for(var _iterator = sharedModules[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
208
+ var sharedModule = _step.value;
209
+ logger.log("".concat(sharedModule, " is removed from externals because it is a shared module."));
210
+ }
211
+ } catch (err) {
212
+ _didIteratorError = true;
213
+ _iteratorError = err;
214
+ } finally{
215
+ try {
216
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
217
+ _iterator.return();
218
+ }
219
+ } finally{
220
+ if (_didIteratorError) {
221
+ throw _iteratorError;
222
+ }
223
+ }
224
+ }
225
+ }
226
+ }
227
+ if (!((_bundlerConfig_output = bundlerConfig.output) === null || _bundlerConfig_output === void 0 ? void 0 : _bundlerConfig_output.chunkLoadingGlobal)) {
228
+ bundlerConfig.output.chunkLoading = 'jsonp';
229
+ }
230
+ // `uniqueName` is required for react refresh to work
231
+ if (!((_bundlerConfig_output1 = bundlerConfig.output) === null || _bundlerConfig_output1 === void 0 ? void 0 : _bundlerConfig_output1.uniqueName)) {
232
+ bundlerConfig.output.uniqueName = moduleFederationOptions.name;
233
+ }
234
+ if (!bundlerConfig.plugins.find(function(p) {
235
+ return p && p.name === PLUGIN_NAME;
236
+ })) {
237
+ bundlerConfig.plugins.push(new ModuleFederationPlugin(moduleFederationOptions));
238
+ }
239
+ }
240
+ });
241
+ });
242
+ // dev config only works on format: 'mf'
299
243
  api.modifyRsbuildConfig(function(config) {
300
244
  // Change some default configs for remote modules
301
245
  if (moduleFederationOptions.exposes) {
@@ -317,114 +261,17 @@ var pluginModuleFederation = function(moduleFederationOptions) {
317
261
  }
318
262
  }
319
263
  });
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
- }
264
+ api.modifyEnvironmentConfig(function(config) {
332
265
  // Module Federation runtime uses ES6+ syntax,
333
266
  // adding to include and let SWC transform it
334
267
  config.source.include = _to_consumable_array(config.source.include || []).concat([
335
268
  /@module-federation[\\/]sdk/,
336
269
  /@module-federation[\\/]runtime/
337
270
  ]);
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;
349
- }
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;
362
- }
363
- return dep === ext;
364
- });
365
- if (match1) {
366
- sharedModule && sharedModules.add(sharedModule);
367
- return false;
368
- }
369
- return true;
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{
384
- try {
385
- if (!_iteratorNormalCompletion && _iterator.return != null) {
386
- _iterator.return();
387
- }
388
- } finally{
389
- if (_didIteratorError) {
390
- throw _iteratorError;
391
- }
392
- }
393
- }
394
- }
395
- }
396
- var mfConfig = {
397
- tools: {
398
- rspack: {
399
- output: {
400
- chunkLoading: 'jsonp'
401
- }
402
- }
403
- }
404
- };
405
- return mergeEnvironmentConfig(config, mfConfig);
271
+ return config;
406
272
  });
407
- api.modifyBundlerChain(/*#__PURE__*/ function() {
408
- var _ref = _async_to_generator(function(chain) {
409
- return _ts_generator(this, function(_state) {
410
- chain.plugin('module-federation').use(ModuleFederationPlugin, [
411
- moduleFederationOptions
412
- ]);
413
- // `uniqueName` is required for react refresh to work
414
- if (!chain.output.get('uniqueName')) {
415
- chain.output.set('uniqueName', moduleFederationOptions.name);
416
- }
417
- return [
418
- 2
419
- ];
420
- });
421
- });
422
- return function(chain) {
423
- return _ref.apply(this, arguments);
424
- };
425
- }());
426
273
  }
427
274
  };
428
275
  };
429
276
 
430
- export { pluginModuleFederation };
277
+ export { RSBUILD_PLUGIN_MODULE_FEDERATION_NAME, RSPACK_PLUGIN_MODULE_FEDERATION_NAME, isMFFormat, pluginModuleFederation };
@@ -1,5 +1,9 @@
1
+ import { PLUGIN_NAME } from '@module-federation/enhanced/rspack';
1
2
  import type { moduleFederationPlugin } from '@module-federation/sdk';
2
- import type { RsbuildPlugin } from '@rsbuild/core';
3
+ import type { RsbuildPlugin, Rspack } from '@rsbuild/core';
3
4
  type ModuleFederationOptions = moduleFederationPlugin.ModuleFederationPluginOptions;
5
+ declare const RSBUILD_PLUGIN_MODULE_FEDERATION_NAME = "rsbuild:module-federation-enhanced";
6
+ declare const RSPACK_PLUGIN_MODULE_FEDERATION_NAME = "module-federation";
7
+ export { RSBUILD_PLUGIN_MODULE_FEDERATION_NAME, RSPACK_PLUGIN_MODULE_FEDERATION_NAME, PLUGIN_NAME, };
8
+ export declare function isMFFormat(bundlerConfig: Rspack.Configuration): boolean;
4
9
  export declare const pluginModuleFederation: (moduleFederationOptions: ModuleFederationOptions) => RsbuildPlugin;
5
- export {};
@@ -0,0 +1,3 @@
1
+ import type { moduleFederationPlugin } from '@module-federation/sdk';
2
+ import type { Rspack } from '@rsbuild/core';
3
+ export declare function autoDeleteSplitChunkCacheGroups(mfConfig: moduleFederationPlugin.ModuleFederationPluginOptions, bundlerConfig: Rspack.Configuration): void;
@@ -1,2 +1,3 @@
1
1
  export declare function isRegExp(target: any): target is RegExp;
2
2
  export * from './constant';
3
+ export * from './autoDeleteSplitChunkCacheGroups';
@@ -0,0 +1 @@
1
+ export * from "./src/utils/index";
@@ -0,0 +1,80 @@
1
+ 'use strict';
2
+
3
+ var util = require('util');
4
+
5
+ var DEFAULT_ASSET_PREFIX = '/';
6
+
7
+ // lib-polyfill.js: include core-js,@babel/runtime,@swc/helpers,tslib.
8
+ // lib-react.js: include react,react-dom.
9
+ // lib-router.js: include react-router,react-router-dom,history,@remix-run/router.
10
+ // lib-lodash.js: include lodash,lodash-es.
11
+ // lib-antd.js: include antd.
12
+ // lib-arco.js: include @arco-design/web-react.
13
+ // lib-semi.js: include @douyinfe/semi-ui.
14
+ // lib-axios.js: include axios.
15
+ var SPLIT_CHUNK_MAP = {
16
+ REACT: 'react',
17
+ ROUTER: 'router',
18
+ LODASH: 'lib-lodash',
19
+ ANTD: 'lib-antd',
20
+ ARCO: 'lib-arco',
21
+ SEMI: 'lib-semi',
22
+ AXIOS: 'lib-axios'
23
+ };
24
+ var SHARED_SPLIT_CHUNK_MAP = {
25
+ react: SPLIT_CHUNK_MAP.REACT,
26
+ 'react-dom': SPLIT_CHUNK_MAP.REACT,
27
+ 'react-router': SPLIT_CHUNK_MAP.ROUTER,
28
+ 'react-router-dom': SPLIT_CHUNK_MAP.ROUTER,
29
+ '@remix-run/router': SPLIT_CHUNK_MAP.ROUTER,
30
+ lodash: SPLIT_CHUNK_MAP.LODASH,
31
+ 'lodash-es': SPLIT_CHUNK_MAP.LODASH,
32
+ antd: SPLIT_CHUNK_MAP.ANTD,
33
+ '@arco-design/web-react': SPLIT_CHUNK_MAP.ARCO,
34
+ '@douyinfe/semi-ui': SPLIT_CHUNK_MAP.SEMI,
35
+ axios: SPLIT_CHUNK_MAP.AXIOS
36
+ };
37
+ function autoDeleteSplitChunkCacheGroups(mfConfig, bundlerConfig) {
38
+ var _bundlerConfig_optimization;
39
+ if (!mfConfig.shared) {
40
+ return;
41
+ }
42
+ if (!((_bundlerConfig_optimization = bundlerConfig.optimization) === null || _bundlerConfig_optimization === void 0 ? void 0 : _bundlerConfig_optimization.splitChunks) || !bundlerConfig.optimization.splitChunks.cacheGroups) {
43
+ return;
44
+ }
45
+ var arrayShared = Array.isArray(mfConfig.shared) ? mfConfig.shared : Object.keys(mfConfig.shared);
46
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
47
+ try {
48
+ for(var _iterator = arrayShared[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
49
+ var shared = _step.value;
50
+ var splitChunkKey = SHARED_SPLIT_CHUNK_MAP[shared];
51
+ if (!splitChunkKey) {
52
+ continue;
53
+ }
54
+ if (bundlerConfig.optimization.splitChunks.cacheGroups[splitChunkKey]) {
55
+ delete bundlerConfig.optimization.splitChunks.cacheGroups[splitChunkKey];
56
+ }
57
+ }
58
+ } catch (err) {
59
+ _didIteratorError = true;
60
+ _iteratorError = err;
61
+ } finally{
62
+ try {
63
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
64
+ _iterator.return();
65
+ }
66
+ } finally{
67
+ if (_didIteratorError) {
68
+ throw _iteratorError;
69
+ }
70
+ }
71
+ }
72
+ }
73
+
74
+ function isRegExp(target) {
75
+ return util.types.isRegExp(target);
76
+ }
77
+
78
+ exports.DEFAULT_ASSET_PREFIX = DEFAULT_ASSET_PREFIX;
79
+ exports.autoDeleteSplitChunkCacheGroups = autoDeleteSplitChunkCacheGroups;
80
+ exports.isRegExp = isRegExp;
@@ -0,0 +1 @@
1
+ export * from "./src/utils/index";
@@ -0,0 +1,76 @@
1
+ import util from 'util';
2
+
3
+ var DEFAULT_ASSET_PREFIX = '/';
4
+
5
+ // lib-polyfill.js: include core-js,@babel/runtime,@swc/helpers,tslib.
6
+ // lib-react.js: include react,react-dom.
7
+ // lib-router.js: include react-router,react-router-dom,history,@remix-run/router.
8
+ // lib-lodash.js: include lodash,lodash-es.
9
+ // lib-antd.js: include antd.
10
+ // lib-arco.js: include @arco-design/web-react.
11
+ // lib-semi.js: include @douyinfe/semi-ui.
12
+ // lib-axios.js: include axios.
13
+ var SPLIT_CHUNK_MAP = {
14
+ REACT: 'react',
15
+ ROUTER: 'router',
16
+ LODASH: 'lib-lodash',
17
+ ANTD: 'lib-antd',
18
+ ARCO: 'lib-arco',
19
+ SEMI: 'lib-semi',
20
+ AXIOS: 'lib-axios'
21
+ };
22
+ var SHARED_SPLIT_CHUNK_MAP = {
23
+ react: SPLIT_CHUNK_MAP.REACT,
24
+ 'react-dom': SPLIT_CHUNK_MAP.REACT,
25
+ 'react-router': SPLIT_CHUNK_MAP.ROUTER,
26
+ 'react-router-dom': SPLIT_CHUNK_MAP.ROUTER,
27
+ '@remix-run/router': SPLIT_CHUNK_MAP.ROUTER,
28
+ lodash: SPLIT_CHUNK_MAP.LODASH,
29
+ 'lodash-es': SPLIT_CHUNK_MAP.LODASH,
30
+ antd: SPLIT_CHUNK_MAP.ANTD,
31
+ '@arco-design/web-react': SPLIT_CHUNK_MAP.ARCO,
32
+ '@douyinfe/semi-ui': SPLIT_CHUNK_MAP.SEMI,
33
+ axios: SPLIT_CHUNK_MAP.AXIOS
34
+ };
35
+ function autoDeleteSplitChunkCacheGroups(mfConfig, bundlerConfig) {
36
+ var _bundlerConfig_optimization;
37
+ if (!mfConfig.shared) {
38
+ return;
39
+ }
40
+ if (!((_bundlerConfig_optimization = bundlerConfig.optimization) === null || _bundlerConfig_optimization === void 0 ? void 0 : _bundlerConfig_optimization.splitChunks) || !bundlerConfig.optimization.splitChunks.cacheGroups) {
41
+ return;
42
+ }
43
+ var arrayShared = Array.isArray(mfConfig.shared) ? mfConfig.shared : Object.keys(mfConfig.shared);
44
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
45
+ try {
46
+ for(var _iterator = arrayShared[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
47
+ var shared = _step.value;
48
+ var splitChunkKey = SHARED_SPLIT_CHUNK_MAP[shared];
49
+ if (!splitChunkKey) {
50
+ continue;
51
+ }
52
+ if (bundlerConfig.optimization.splitChunks.cacheGroups[splitChunkKey]) {
53
+ delete bundlerConfig.optimization.splitChunks.cacheGroups[splitChunkKey];
54
+ }
55
+ }
56
+ } catch (err) {
57
+ _didIteratorError = true;
58
+ _iteratorError = err;
59
+ } finally{
60
+ try {
61
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
62
+ _iterator.return();
63
+ }
64
+ } finally{
65
+ if (_didIteratorError) {
66
+ throw _iteratorError;
67
+ }
68
+ }
69
+ }
70
+ }
71
+
72
+ function isRegExp(target) {
73
+ return util.types.isRegExp(target);
74
+ }
75
+
76
+ export { DEFAULT_ASSET_PREFIX, autoDeleteSplitChunkCacheGroups, isRegExp };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/rsbuild-plugin",
3
- "version": "0.8.4",
3
+ "version": "0.8.6",
4
4
  "description": "Module Federation plugin for Rsbuild",
5
5
  "homepage": "https://module-federation.io",
6
6
  "bugs": {
@@ -14,9 +14,14 @@
14
14
  "license": "MIT",
15
15
  "exports": {
16
16
  ".": {
17
+ "types": "./dist/index.cjs.d.ts",
17
18
  "import": "./dist/index.esm.js",
18
- "require": "./dist/index.cjs.js",
19
- "types": "./dist/index.cjs.d.ts"
19
+ "require": "./dist/index.cjs.js"
20
+ },
21
+ "./utils": {
22
+ "types": "./dist/utils.cjs.d.ts",
23
+ "import": "./dist/utils.esm.js",
24
+ "require": "./dist/utils.cjs.js"
20
25
  }
21
26
  },
22
27
  "main": "./dist/index.cjs.js",
@@ -25,6 +30,9 @@
25
30
  "*": {
26
31
  ".": [
27
32
  "./dist/index.cjs.d.ts"
33
+ ],
34
+ "utils": [
35
+ "./dist/utils.cjs.d.ts"
28
36
  ]
29
37
  }
30
38
  },
@@ -32,14 +40,22 @@
32
40
  "dist"
33
41
  ],
34
42
  "dependencies": {
35
- "@module-federation/sdk": "0.8.4"
43
+ "@module-federation/sdk": "0.8.6"
36
44
  },
37
45
  "devDependencies": {
38
46
  "@rsbuild/core": "^1.0.19"
39
47
  },
40
48
  "peerDependencies": {
41
49
  "@rsbuild/core": "1.x",
42
- "@module-federation/enhanced": "0.8.4"
50
+ "@module-federation/enhanced": "0.8.6"
51
+ },
52
+ "peerDependenciesMeta": {
53
+ "@rsbuild/core": {
54
+ "optional": true
55
+ },
56
+ "@module-federation/enhanced": {
57
+ "optional": true
58
+ }
43
59
  },
44
60
  "engines": {
45
61
  "node": ">=16.0.0"