@module-federation/rsbuild-plugin 0.9.0 → 0.10.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/index.cjs.js
CHANGED
|
@@ -7,7 +7,7 @@ var utils = require('./utils.cjs.js');
|
|
|
7
7
|
require('util');
|
|
8
8
|
|
|
9
9
|
var name = "@module-federation/rsbuild-plugin";
|
|
10
|
-
var version = "0.
|
|
10
|
+
var version = "0.10.0";
|
|
11
11
|
var description = "Module Federation plugin for Rsbuild";
|
|
12
12
|
var homepage = "https://module-federation.io";
|
|
13
13
|
var bugs = {
|
|
@@ -124,14 +124,14 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
124
124
|
var RSBUILD_PLUGIN_MODULE_FEDERATION_NAME = 'rsbuild:module-federation-enhanced';
|
|
125
125
|
var RSPACK_PLUGIN_MODULE_FEDERATION_NAME = 'module-federation';
|
|
126
126
|
var LIB_FORMAT = [
|
|
127
|
-
'commonjs',
|
|
128
127
|
'umd',
|
|
129
128
|
'modern-module'
|
|
130
129
|
];
|
|
131
130
|
function isMFFormat(bundlerConfig) {
|
|
132
131
|
var _bundlerConfig_output;
|
|
133
132
|
var library = (_bundlerConfig_output = bundlerConfig.output) === null || _bundlerConfig_output === void 0 ? void 0 : _bundlerConfig_output.library;
|
|
134
|
-
return !((typeof library === "undefined" ? "undefined" : _type_of(library)) === 'object' && !Array.isArray(library) && 'type' in library &&
|
|
133
|
+
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
|
|
134
|
+
(LIB_FORMAT.includes(library.type) || /commonjs/.test(library.type)));
|
|
135
135
|
}
|
|
136
136
|
var pluginModuleFederation = function(moduleFederationOptions) {
|
|
137
137
|
return {
|
|
@@ -162,9 +162,9 @@ var pluginModuleFederation = function(moduleFederationOptions) {
|
|
|
162
162
|
if (!isMFFormat(bundlerConfig)) {
|
|
163
163
|
return;
|
|
164
164
|
} else {
|
|
165
|
-
var _bundlerConfig_output, _bundlerConfig_output1;
|
|
165
|
+
var _bundlerConfig_optimization, _bundlerConfig_output, _bundlerConfig_output1;
|
|
166
166
|
// mf
|
|
167
|
-
utils.autoDeleteSplitChunkCacheGroups(moduleFederationOptions, bundlerConfig);
|
|
167
|
+
utils.autoDeleteSplitChunkCacheGroups(moduleFederationOptions, bundlerConfig === null || bundlerConfig === void 0 ? void 0 : (_bundlerConfig_optimization = bundlerConfig.optimization) === null || _bundlerConfig_optimization === void 0 ? void 0 : _bundlerConfig_optimization.splitChunks);
|
|
168
168
|
var externals = bundlerConfig.externals;
|
|
169
169
|
if (Array.isArray(externals)) {
|
|
170
170
|
var sharedModules = new Set();
|
|
@@ -263,8 +263,7 @@ var pluginModuleFederation = function(moduleFederationOptions) {
|
|
|
263
263
|
// Module Federation runtime uses ES6+ syntax,
|
|
264
264
|
// adding to include and let SWC transform it
|
|
265
265
|
config.source.include = _to_consumable_array(config.source.include || []).concat([
|
|
266
|
-
/@module-federation[\\/]
|
|
267
|
-
/@module-federation[\\/]runtime/
|
|
266
|
+
/@module-federation[\\/]/
|
|
268
267
|
]);
|
|
269
268
|
return config;
|
|
270
269
|
});
|
package/dist/index.esm.js
CHANGED
|
@@ -6,7 +6,7 @@ import { autoDeleteSplitChunkCacheGroups, isRegExp } from './utils.esm.js';
|
|
|
6
6
|
import 'util';
|
|
7
7
|
|
|
8
8
|
var name = "@module-federation/rsbuild-plugin";
|
|
9
|
-
var version = "0.
|
|
9
|
+
var version = "0.10.0";
|
|
10
10
|
var description = "Module Federation plugin for Rsbuild";
|
|
11
11
|
var homepage = "https://module-federation.io";
|
|
12
12
|
var bugs = {
|
|
@@ -123,14 +123,14 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
123
123
|
var RSBUILD_PLUGIN_MODULE_FEDERATION_NAME = 'rsbuild:module-federation-enhanced';
|
|
124
124
|
var RSPACK_PLUGIN_MODULE_FEDERATION_NAME = 'module-federation';
|
|
125
125
|
var LIB_FORMAT = [
|
|
126
|
-
'commonjs',
|
|
127
126
|
'umd',
|
|
128
127
|
'modern-module'
|
|
129
128
|
];
|
|
130
129
|
function isMFFormat(bundlerConfig) {
|
|
131
130
|
var _bundlerConfig_output;
|
|
132
131
|
var library = (_bundlerConfig_output = bundlerConfig.output) === null || _bundlerConfig_output === void 0 ? void 0 : _bundlerConfig_output.library;
|
|
133
|
-
return !((typeof library === "undefined" ? "undefined" : _type_of(library)) === 'object' && !Array.isArray(library) && 'type' in library &&
|
|
132
|
+
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
|
|
133
|
+
(LIB_FORMAT.includes(library.type) || /commonjs/.test(library.type)));
|
|
134
134
|
}
|
|
135
135
|
var pluginModuleFederation = function(moduleFederationOptions) {
|
|
136
136
|
return {
|
|
@@ -161,9 +161,9 @@ var pluginModuleFederation = function(moduleFederationOptions) {
|
|
|
161
161
|
if (!isMFFormat(bundlerConfig)) {
|
|
162
162
|
return;
|
|
163
163
|
} else {
|
|
164
|
-
var _bundlerConfig_output, _bundlerConfig_output1;
|
|
164
|
+
var _bundlerConfig_optimization, _bundlerConfig_output, _bundlerConfig_output1;
|
|
165
165
|
// mf
|
|
166
|
-
autoDeleteSplitChunkCacheGroups(moduleFederationOptions, bundlerConfig);
|
|
166
|
+
autoDeleteSplitChunkCacheGroups(moduleFederationOptions, bundlerConfig === null || bundlerConfig === void 0 ? void 0 : (_bundlerConfig_optimization = bundlerConfig.optimization) === null || _bundlerConfig_optimization === void 0 ? void 0 : _bundlerConfig_optimization.splitChunks);
|
|
167
167
|
var externals = bundlerConfig.externals;
|
|
168
168
|
if (Array.isArray(externals)) {
|
|
169
169
|
var sharedModules = new Set();
|
|
@@ -262,8 +262,7 @@ var pluginModuleFederation = function(moduleFederationOptions) {
|
|
|
262
262
|
// Module Federation runtime uses ES6+ syntax,
|
|
263
263
|
// adding to include and let SWC transform it
|
|
264
264
|
config.source.include = _to_consumable_array(config.source.include || []).concat([
|
|
265
|
-
/@module-federation[\\/]
|
|
266
|
-
/@module-federation[\\/]runtime/
|
|
265
|
+
/@module-federation[\\/]/
|
|
267
266
|
]);
|
|
268
267
|
return config;
|
|
269
268
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,3 +1,49 @@
|
|
|
1
1
|
import type { moduleFederationPlugin } from '@module-federation/sdk';
|
|
2
2
|
import type { Rspack } from '@rsbuild/core';
|
|
3
|
-
|
|
3
|
+
type OptimizationConfig = Rspack.Configuration['optimization'];
|
|
4
|
+
type SplitChunksConfig = NonNullable<OptimizationConfig>['splitChunks'];
|
|
5
|
+
export declare function autoDeleteSplitChunkCacheGroups(mfConfig: moduleFederationPlugin.ModuleFederationPluginOptions, splitChunks: SplitChunksConfig): {
|
|
6
|
+
name?: string | false | ((args_0: Rspack.Module | undefined, ...args: unknown[]) => unknown) | undefined;
|
|
7
|
+
chunks?: RegExp | "all" | "initial" | "async" | ((args_0: Rspack.Chunk, ...args: unknown[]) => boolean) | undefined;
|
|
8
|
+
usedExports?: boolean | undefined;
|
|
9
|
+
maxSize?: number | Record<string, number> | undefined;
|
|
10
|
+
defaultSizeTypes?: string[] | undefined;
|
|
11
|
+
minChunks?: number | undefined;
|
|
12
|
+
minSize?: number | Record<string, number> | undefined;
|
|
13
|
+
maxAsyncSize?: number | Record<string, number> | undefined;
|
|
14
|
+
maxInitialSize?: number | Record<string, number> | undefined;
|
|
15
|
+
maxAsyncRequests?: number | undefined;
|
|
16
|
+
maxInitialRequests?: number | undefined;
|
|
17
|
+
automaticNameDelimiter?: string | undefined;
|
|
18
|
+
cacheGroups?: Record<string, false | {
|
|
19
|
+
type?: string | RegExp | undefined;
|
|
20
|
+
filename?: string | undefined;
|
|
21
|
+
name?: string | false | ((args_0: Rspack.Module | undefined, ...args: unknown[]) => unknown) | undefined;
|
|
22
|
+
priority?: number | undefined;
|
|
23
|
+
chunks?: RegExp | "all" | "initial" | "async" | ((args_0: Rspack.Chunk, ...args: unknown[]) => boolean) | undefined;
|
|
24
|
+
usedExports?: boolean | undefined;
|
|
25
|
+
test?: string | RegExp | ((args_0: Rspack.Module, ...args: unknown[]) => unknown) | undefined;
|
|
26
|
+
enforce?: boolean | undefined;
|
|
27
|
+
maxSize?: number | Record<string, number> | undefined;
|
|
28
|
+
reuseExistingChunk?: boolean | undefined;
|
|
29
|
+
idHint?: string | undefined;
|
|
30
|
+
defaultSizeTypes?: string[] | undefined;
|
|
31
|
+
minChunks?: number | undefined;
|
|
32
|
+
minSize?: number | Record<string, number> | undefined;
|
|
33
|
+
maxAsyncSize?: number | Record<string, number> | undefined;
|
|
34
|
+
maxInitialSize?: number | Record<string, number> | undefined;
|
|
35
|
+
maxAsyncRequests?: number | undefined;
|
|
36
|
+
maxInitialRequests?: number | undefined;
|
|
37
|
+
automaticNameDelimiter?: string | undefined;
|
|
38
|
+
}> | undefined;
|
|
39
|
+
fallbackCacheGroup?: {
|
|
40
|
+
chunks?: RegExp | "all" | "initial" | "async" | ((args_0: Rspack.Chunk, ...args: unknown[]) => boolean) | undefined;
|
|
41
|
+
maxSize?: number | undefined;
|
|
42
|
+
minSize?: number | undefined;
|
|
43
|
+
maxAsyncSize?: number | undefined;
|
|
44
|
+
maxInitialSize?: number | undefined;
|
|
45
|
+
automaticNameDelimiter?: string | undefined;
|
|
46
|
+
} | undefined;
|
|
47
|
+
hidePathInfo?: boolean | undefined;
|
|
48
|
+
} | undefined;
|
|
49
|
+
export {};
|
package/dist/utils.cjs.js
CHANGED
|
@@ -34,12 +34,11 @@ var SHARED_SPLIT_CHUNK_MAP = {
|
|
|
34
34
|
'@douyinfe/semi-ui': SPLIT_CHUNK_MAP.SEMI,
|
|
35
35
|
axios: SPLIT_CHUNK_MAP.AXIOS
|
|
36
36
|
};
|
|
37
|
-
function autoDeleteSplitChunkCacheGroups(mfConfig,
|
|
38
|
-
var _bundlerConfig_optimization;
|
|
37
|
+
function autoDeleteSplitChunkCacheGroups(mfConfig, splitChunks) {
|
|
39
38
|
if (!mfConfig.shared) {
|
|
40
39
|
return;
|
|
41
40
|
}
|
|
42
|
-
if (!
|
|
41
|
+
if (!splitChunks || !(splitChunks === null || splitChunks === void 0 ? void 0 : splitChunks.cacheGroups)) {
|
|
43
42
|
return;
|
|
44
43
|
}
|
|
45
44
|
var arrayShared = Array.isArray(mfConfig.shared) ? mfConfig.shared : Object.keys(mfConfig.shared);
|
|
@@ -51,8 +50,8 @@ function autoDeleteSplitChunkCacheGroups(mfConfig, bundlerConfig) {
|
|
|
51
50
|
if (!splitChunkKey) {
|
|
52
51
|
continue;
|
|
53
52
|
}
|
|
54
|
-
if (
|
|
55
|
-
delete
|
|
53
|
+
if (splitChunks.cacheGroups[splitChunkKey]) {
|
|
54
|
+
delete splitChunks.cacheGroups[splitChunkKey];
|
|
56
55
|
}
|
|
57
56
|
}
|
|
58
57
|
} catch (err) {
|
|
@@ -69,6 +68,7 @@ function autoDeleteSplitChunkCacheGroups(mfConfig, bundlerConfig) {
|
|
|
69
68
|
}
|
|
70
69
|
}
|
|
71
70
|
}
|
|
71
|
+
return splitChunks;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
function isRegExp(target) {
|
package/dist/utils.esm.js
CHANGED
|
@@ -32,12 +32,11 @@ var SHARED_SPLIT_CHUNK_MAP = {
|
|
|
32
32
|
'@douyinfe/semi-ui': SPLIT_CHUNK_MAP.SEMI,
|
|
33
33
|
axios: SPLIT_CHUNK_MAP.AXIOS
|
|
34
34
|
};
|
|
35
|
-
function autoDeleteSplitChunkCacheGroups(mfConfig,
|
|
36
|
-
var _bundlerConfig_optimization;
|
|
35
|
+
function autoDeleteSplitChunkCacheGroups(mfConfig, splitChunks) {
|
|
37
36
|
if (!mfConfig.shared) {
|
|
38
37
|
return;
|
|
39
38
|
}
|
|
40
|
-
if (!
|
|
39
|
+
if (!splitChunks || !(splitChunks === null || splitChunks === void 0 ? void 0 : splitChunks.cacheGroups)) {
|
|
41
40
|
return;
|
|
42
41
|
}
|
|
43
42
|
var arrayShared = Array.isArray(mfConfig.shared) ? mfConfig.shared : Object.keys(mfConfig.shared);
|
|
@@ -49,8 +48,8 @@ function autoDeleteSplitChunkCacheGroups(mfConfig, bundlerConfig) {
|
|
|
49
48
|
if (!splitChunkKey) {
|
|
50
49
|
continue;
|
|
51
50
|
}
|
|
52
|
-
if (
|
|
53
|
-
delete
|
|
51
|
+
if (splitChunks.cacheGroups[splitChunkKey]) {
|
|
52
|
+
delete splitChunks.cacheGroups[splitChunkKey];
|
|
54
53
|
}
|
|
55
54
|
}
|
|
56
55
|
} catch (err) {
|
|
@@ -67,6 +66,7 @@ function autoDeleteSplitChunkCacheGroups(mfConfig, bundlerConfig) {
|
|
|
67
66
|
}
|
|
68
67
|
}
|
|
69
68
|
}
|
|
69
|
+
return splitChunks;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
function isRegExp(target) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/rsbuild-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Module Federation plugin for Rsbuild",
|
|
5
5
|
"homepage": "https://module-federation.io",
|
|
6
6
|
"bugs": {
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"dist"
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@module-federation/sdk": "0.
|
|
44
|
-
"@module-federation/enhanced": "0.
|
|
43
|
+
"@module-federation/sdk": "0.10.0",
|
|
44
|
+
"@module-federation/enhanced": "0.10.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@rsbuild/core": "^1.0.19"
|