@module-federation/rspack 0.0.0-next-20250924123930 → 0.0.0-perf-devtools-20260106124142
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/RemoteEntryPlugin.cjs.js +70 -0
- package/dist/RemoteEntryPlugin.cjs.js.map +1 -0
- package/dist/RemoteEntryPlugin.esm.mjs +67 -0
- package/dist/RemoteEntryPlugin.esm.mjs.map +1 -0
- package/dist/index.cjs.js +2 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.mjs +2 -2
- package/dist/index.esm.mjs.map +1 -1
- package/dist/plugin.cjs.js +236 -266
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.esm.mjs +237 -267
- package/dist/plugin.esm.mjs.map +1 -1
- package/dist/remote-entry-plugin.cjs.js +4 -91
- package/dist/remote-entry-plugin.cjs.js.map +1 -1
- package/dist/remote-entry-plugin.esm.mjs +3 -94
- package/dist/remote-entry-plugin.esm.mjs.map +1 -1
- package/dist/src/ModuleFederationPlugin.d.ts +0 -1
- package/dist/src/logger.d.ts +2 -1
- package/package.json +8 -8
package/dist/plugin.esm.mjs
CHANGED
|
@@ -1,297 +1,267 @@
|
|
|
1
|
-
import { composeKeyWithSeparator } from '@module-federation/sdk';
|
|
1
|
+
import { composeKeyWithSeparator, bindLoggerToCompiler } from '@module-federation/sdk';
|
|
2
2
|
import { StatsPlugin } from '@module-federation/manifest';
|
|
3
3
|
import { utils, ContainerManager } from '@module-federation/managers';
|
|
4
4
|
import { DtsPlugin } from '@module-federation/dts-plugin';
|
|
5
5
|
import ReactBridgePlugin from '@module-federation/bridge-react-webpack-plugin';
|
|
6
6
|
import path from 'node:path';
|
|
7
7
|
import fs from 'node:fs';
|
|
8
|
-
import { RemoteEntryPlugin } from './
|
|
8
|
+
import { R as RemoteEntryPlugin, l as logger } from './RemoteEntryPlugin.esm.mjs';
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
const RuntimeToolsPath = require.resolve('@module-federation/runtime-tools');
|
|
11
|
+
const PLUGIN_NAME = 'RspackModuleFederationPlugin';
|
|
12
|
+
class ModuleFederationPlugin {
|
|
13
|
+
constructor(options) {
|
|
14
|
+
this.name = PLUGIN_NAME;
|
|
15
|
+
this._options = options;
|
|
13
16
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
_patchBundlerConfig(compiler) {
|
|
18
|
+
const { name, experiments } = this._options;
|
|
19
|
+
const definePluginOptions = {};
|
|
20
|
+
if (name) {
|
|
21
|
+
definePluginOptions['FEDERATION_BUILD_IDENTIFIER'] = JSON.stringify(composeKeyWithSeparator(name, utils.getBuildVersion()));
|
|
22
|
+
}
|
|
23
|
+
// Add FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN
|
|
24
|
+
const disableSnapshot = experiments?.optimization?.disableSnapshot ?? false;
|
|
25
|
+
definePluginOptions['FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN'] =
|
|
26
|
+
disableSnapshot;
|
|
27
|
+
// Determine ENV_TARGET: only if manually specified in experiments.optimization.target
|
|
28
|
+
if (experiments?.optimization &&
|
|
29
|
+
typeof experiments.optimization === 'object' &&
|
|
30
|
+
experiments.optimization !== null &&
|
|
31
|
+
'target' in experiments.optimization) {
|
|
32
|
+
const manualTarget = experiments.optimization.target;
|
|
33
|
+
// Ensure the target is one of the expected values before setting
|
|
34
|
+
if (manualTarget === 'web' || manualTarget === 'node') {
|
|
35
|
+
definePluginOptions['ENV_TARGET'] = JSON.stringify(manualTarget);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
// No inference for ENV_TARGET. If not manually set and valid, it's not defined.
|
|
39
|
+
new compiler.webpack.DefinePlugin(definePluginOptions).apply(compiler);
|
|
22
40
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
41
|
+
_checkSingleton(compiler) {
|
|
42
|
+
let count = 0;
|
|
43
|
+
compiler.options.plugins.forEach((p) => {
|
|
44
|
+
if (typeof p !== 'object' || !p) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (p['name'] === this.name) {
|
|
48
|
+
count++;
|
|
49
|
+
if (count > 1) {
|
|
50
|
+
throw new Error(`Detect duplicate register ${this.name},please ensure ${this.name} is singleton!`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
35
53
|
});
|
|
36
|
-
} else {
|
|
37
|
-
obj[key] = value;
|
|
38
|
-
}
|
|
39
|
-
return obj;
|
|
40
|
-
}
|
|
41
|
-
function _instanceof(left, right) {
|
|
42
|
-
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
43
|
-
return !!right[Symbol.hasInstance](left);
|
|
44
|
-
} else {
|
|
45
|
-
return left instanceof right;
|
|
46
54
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
53
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
54
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
55
|
-
}));
|
|
55
|
+
apply(compiler) {
|
|
56
|
+
bindLoggerToCompiler(logger, compiler, PLUGIN_NAME);
|
|
57
|
+
const { _options: options } = this;
|
|
58
|
+
if (!options.name) {
|
|
59
|
+
throw new Error('[ ModuleFederationPlugin ]: name is required');
|
|
56
60
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
61
|
+
this._checkSingleton(compiler);
|
|
62
|
+
this._patchBundlerConfig(compiler);
|
|
63
|
+
const containerManager = new ContainerManager();
|
|
64
|
+
containerManager.init(options);
|
|
65
|
+
if (containerManager.enable) {
|
|
66
|
+
this._patchChunkSplit(compiler, options.name);
|
|
67
|
+
}
|
|
68
|
+
// must before ModuleFederationPlugin
|
|
69
|
+
new RemoteEntryPlugin(options).apply(compiler);
|
|
70
|
+
if (options.experiments?.provideExternalRuntime) {
|
|
71
|
+
if (options.exposes) {
|
|
72
|
+
throw new Error('You can only set provideExternalRuntime: true in pure consumer which not expose modules.');
|
|
73
|
+
}
|
|
74
|
+
const runtimePlugins = options.runtimePlugins || [];
|
|
75
|
+
options.runtimePlugins = runtimePlugins.concat(require.resolve('@module-federation/inject-external-runtime-core-plugin'));
|
|
76
|
+
}
|
|
77
|
+
if (options.experiments?.externalRuntime === true) {
|
|
78
|
+
const Externals = compiler.webpack.ExternalsPlugin;
|
|
79
|
+
new Externals(compiler.options.externalsType || 'global', {
|
|
80
|
+
'@module-federation/runtime-core': '_FEDERATION_RUNTIME_CORE',
|
|
81
|
+
}).apply(compiler);
|
|
82
|
+
}
|
|
83
|
+
options.implementation = options.implementation || RuntimeToolsPath;
|
|
84
|
+
let disableManifest = options.manifest === false;
|
|
85
|
+
let disableDts = options.dts === false;
|
|
86
|
+
if (!disableDts) {
|
|
87
|
+
const dtsPlugin = new DtsPlugin(options);
|
|
88
|
+
// @ts-ignore
|
|
89
|
+
dtsPlugin.apply(compiler);
|
|
90
|
+
dtsPlugin.addRuntimePlugins();
|
|
91
|
+
}
|
|
92
|
+
if (!disableManifest && options.exposes) {
|
|
93
|
+
try {
|
|
94
|
+
options.exposes = containerManager.containerPluginExposesOptions;
|
|
95
|
+
}
|
|
96
|
+
catch (err) {
|
|
97
|
+
if (err instanceof Error) {
|
|
98
|
+
err.message = `[ ModuleFederationPlugin ]: Manifest will not generate, because: ${err.message}`;
|
|
99
|
+
}
|
|
100
|
+
logger.warn(err);
|
|
101
|
+
disableManifest = true;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
new compiler.webpack.container.ModuleFederationPlugin(options).apply(compiler);
|
|
105
|
+
const runtimeESMPath = require.resolve('@module-federation/runtime/dist/index.esm.js', { paths: [options.implementation] });
|
|
106
|
+
compiler.hooks.afterPlugins.tap('PatchAliasWebpackPlugin', () => {
|
|
107
|
+
compiler.options.resolve.alias = {
|
|
108
|
+
...compiler.options.resolve.alias,
|
|
109
|
+
'@module-federation/runtime$': runtimeESMPath,
|
|
110
|
+
};
|
|
78
111
|
});
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
value: function _patchBundlerConfig(compiler) {
|
|
98
|
-
var _experiments_optimization;
|
|
99
|
-
var _this__options = this._options, name = _this__options.name, experiments = _this__options.experiments;
|
|
100
|
-
var definePluginOptions = {};
|
|
101
|
-
if (name) {
|
|
102
|
-
definePluginOptions['FEDERATION_BUILD_IDENTIFIER'] = JSON.stringify(composeKeyWithSeparator(name, utils.getBuildVersion()));
|
|
112
|
+
if (!disableManifest) {
|
|
113
|
+
this._statsPlugin = new StatsPlugin(options, {
|
|
114
|
+
pluginVersion: "0.0.0-perf-devtools-20260106124142",
|
|
115
|
+
bundler: 'rspack',
|
|
116
|
+
});
|
|
117
|
+
// @ts-ignore
|
|
118
|
+
this._statsPlugin.apply(compiler);
|
|
119
|
+
}
|
|
120
|
+
const checkBridgeReactInstalled = () => {
|
|
121
|
+
try {
|
|
122
|
+
const userPackageJsonPath = path.resolve(compiler.context, 'package.json');
|
|
123
|
+
if (fs.existsSync(userPackageJsonPath)) {
|
|
124
|
+
const userPackageJson = JSON.parse(fs.readFileSync(userPackageJsonPath, 'utf-8'));
|
|
125
|
+
const userDependencies = {
|
|
126
|
+
...userPackageJson.dependencies,
|
|
127
|
+
...userPackageJson.devDependencies,
|
|
128
|
+
};
|
|
129
|
+
return !!userDependencies['@module-federation/bridge-react'];
|
|
103
130
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
const hasBridgeReact = checkBridgeReactInstalled();
|
|
138
|
+
// react bridge plugin
|
|
139
|
+
const shouldEnableBridgePlugin = () => {
|
|
140
|
+
// Priority 1: Explicit enableBridgeRouter configuration
|
|
141
|
+
if (options?.bridge?.enableBridgeRouter === true) {
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
// Priority 2: Explicit disable via enableBridgeRouter:false or disableAlias:true
|
|
145
|
+
if (options?.bridge?.enableBridgeRouter === false ||
|
|
146
|
+
options?.bridge?.disableAlias === true) {
|
|
147
|
+
if (options?.bridge?.disableAlias === true) {
|
|
148
|
+
logger.warn('⚠️ [ModuleFederationPlugin] The `disableAlias` option is deprecated and will be removed in a future version.\n' +
|
|
149
|
+
' Please use `enableBridgeRouter: false` instead:\n' +
|
|
150
|
+
' {\n' +
|
|
151
|
+
' bridge: {\n' +
|
|
152
|
+
' enableBridgeRouter: false // Use this instead of disableAlias: true\n' +
|
|
153
|
+
' }\n' +
|
|
154
|
+
' }');
|
|
115
155
|
}
|
|
116
|
-
|
|
117
|
-
new compiler.webpack.DefinePlugin(definePluginOptions).apply(compiler);
|
|
156
|
+
return false;
|
|
118
157
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
158
|
+
// Priority 3: Automatic detection based on bridge-react installation
|
|
159
|
+
if (hasBridgeReact) {
|
|
160
|
+
logger.info('💡 [ModuleFederationPlugin] Detected @module-federation/bridge-react in your dependencies.\n' +
|
|
161
|
+
' For better control and to avoid future breaking changes, please explicitly set:\n' +
|
|
162
|
+
' {\n' +
|
|
163
|
+
' bridge: {\n' +
|
|
164
|
+
' enableBridgeRouter: true // Explicitly enable bridge router\n' +
|
|
165
|
+
' }\n' +
|
|
166
|
+
' }');
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
return false;
|
|
170
|
+
};
|
|
171
|
+
const enableBridgePlugin = shouldEnableBridgePlugin();
|
|
172
|
+
// When bridge plugin is disabled (router disabled), alias to /base entry
|
|
173
|
+
if (!enableBridgePlugin && hasBridgeReact) {
|
|
174
|
+
compiler.hooks.afterPlugins.tap('BridgeReactBaseAliasPlugin', () => {
|
|
175
|
+
try {
|
|
176
|
+
const bridgeReactBasePath = path.resolve(compiler.context, 'node_modules/@module-federation/bridge-react/dist/base.es.js');
|
|
177
|
+
if (!fs.existsSync(bridgeReactBasePath)) {
|
|
178
|
+
logger.warn('⚠️ [ModuleFederationPlugin] bridge-react /base entry not found, falling back to default entry');
|
|
127
179
|
return;
|
|
128
180
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
key: "apply",
|
|
140
|
-
value: function apply(compiler) {
|
|
141
|
-
var _options_experiments, _options_experiments1;
|
|
142
|
-
var _this = this, options = _this._options;
|
|
143
|
-
if (!options.name) {
|
|
144
|
-
throw new Error('[ ModuleFederationPlugin ]: name is required');
|
|
181
|
+
compiler.options.resolve.alias = {
|
|
182
|
+
...compiler.options.resolve.alias,
|
|
183
|
+
'@module-federation/bridge-react$': bridgeReactBasePath,
|
|
184
|
+
};
|
|
185
|
+
logger.info('✅ [ModuleFederationPlugin] Router disabled - using /base entry (no react-router-dom)');
|
|
145
186
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
var containerManager = new ContainerManager();
|
|
149
|
-
containerManager.init(options);
|
|
150
|
-
if (containerManager.enable) {
|
|
151
|
-
this._patchChunkSplit(compiler, options.name);
|
|
187
|
+
catch (error) {
|
|
188
|
+
logger.warn('⚠️ [ModuleFederationPlugin] Failed to set /base alias, using default entry');
|
|
152
189
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
if (enableBridgePlugin) {
|
|
193
|
+
new ReactBridgePlugin({
|
|
194
|
+
moduleFederationOptions: this._options,
|
|
195
|
+
}).apply(compiler);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
_patchChunkSplit(compiler, name) {
|
|
199
|
+
const { splitChunks } = compiler.options.optimization;
|
|
200
|
+
const patchChunkSplit = (cacheGroup) => {
|
|
201
|
+
switch (typeof cacheGroup) {
|
|
202
|
+
case 'boolean':
|
|
203
|
+
case 'string':
|
|
204
|
+
case 'function':
|
|
205
|
+
break;
|
|
206
|
+
// cacheGroup.chunks will inherit splitChunks.chunks, so you only need to modify the chunks that are set separately
|
|
207
|
+
case 'object': {
|
|
208
|
+
if (cacheGroup instanceof RegExp) {
|
|
209
|
+
break;
|
|
158
210
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
if (((_options_experiments1 = options.experiments) === null || _options_experiments1 === void 0 ? void 0 : _options_experiments1.externalRuntime) === true) {
|
|
163
|
-
var Externals = compiler.webpack.ExternalsPlugin;
|
|
164
|
-
new Externals(compiler.options.externalsType || 'global', {
|
|
165
|
-
'@module-federation/runtime-core': '_FEDERATION_RUNTIME_CORE'
|
|
166
|
-
}).apply(compiler);
|
|
167
|
-
}
|
|
168
|
-
options.implementation = options.implementation || RuntimeToolsPath;
|
|
169
|
-
var disableManifest = options.manifest === false;
|
|
170
|
-
var disableDts = options.dts === false;
|
|
171
|
-
if (!disableDts) {
|
|
172
|
-
var dtsPlugin = new DtsPlugin(options);
|
|
173
|
-
// @ts-ignore
|
|
174
|
-
dtsPlugin.apply(compiler);
|
|
175
|
-
dtsPlugin.addRuntimePlugins();
|
|
176
|
-
}
|
|
177
|
-
if (!disableManifest && options.exposes) {
|
|
178
|
-
try {
|
|
179
|
-
options.exposes = containerManager.containerPluginExposesOptions;
|
|
180
|
-
} catch (err) {
|
|
181
|
-
if (_instanceof(err, Error)) {
|
|
182
|
-
err.message = "[ ModuleFederationPlugin ]: Manifest will not generate, because: ".concat(err.message);
|
|
183
|
-
}
|
|
184
|
-
console.warn(err);
|
|
185
|
-
disableManifest = true;
|
|
211
|
+
if (!cacheGroup.chunks) {
|
|
212
|
+
break;
|
|
186
213
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
});
|
|
194
|
-
compiler.hooks.afterPlugins.tap('PatchAliasWebpackPlugin', function() {
|
|
195
|
-
compiler.options.resolve.alias = _object_spread_props(_object_spread({}, compiler.options.resolve.alias), {
|
|
196
|
-
'@module-federation/runtime$': runtimeESMPath
|
|
197
|
-
});
|
|
198
|
-
});
|
|
199
|
-
if (!disableManifest) {
|
|
200
|
-
this._statsPlugin = new StatsPlugin(options, {
|
|
201
|
-
pluginVersion: "0.0.0-next-20250924123930",
|
|
202
|
-
bundler: 'rspack'
|
|
203
|
-
});
|
|
204
|
-
// @ts-ignore
|
|
205
|
-
this._statsPlugin.apply(compiler);
|
|
206
|
-
}
|
|
207
|
-
// react bridge plugin
|
|
208
|
-
var nodeModulesPath = path.resolve(compiler.context, 'node_modules');
|
|
209
|
-
var reactPath = path.join(nodeModulesPath, '@module-federation/bridge-react');
|
|
210
|
-
// Check whether react exists
|
|
211
|
-
if (fs.existsSync(reactPath) && (!(options === null || options === void 0 ? void 0 : options.bridge) || !options.bridge.disableAlias)) {
|
|
212
|
-
new ReactBridgePlugin({
|
|
213
|
-
moduleFederationOptions: this._options
|
|
214
|
-
}).apply(compiler);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
key: "_patchChunkSplit",
|
|
220
|
-
value: function _patchChunkSplit(compiler, name) {
|
|
221
|
-
var splitChunks = compiler.options.optimization.splitChunks;
|
|
222
|
-
var patchChunkSplit = function(cacheGroup) {
|
|
223
|
-
switch(typeof cacheGroup === "undefined" ? "undefined" : _type_of(cacheGroup)){
|
|
224
|
-
case 'boolean':
|
|
225
|
-
case 'string':
|
|
226
|
-
case 'function':
|
|
227
|
-
break;
|
|
228
|
-
// cacheGroup.chunks will inherit splitChunks.chunks, so you only need to modify the chunks that are set separately
|
|
229
|
-
case 'object':
|
|
230
|
-
{
|
|
231
|
-
if (_instanceof(cacheGroup, RegExp)) {
|
|
232
|
-
break;
|
|
233
|
-
}
|
|
234
|
-
if (!cacheGroup.chunks) {
|
|
235
|
-
break;
|
|
236
|
-
}
|
|
237
|
-
if (typeof cacheGroup.chunks === 'function') {
|
|
238
|
-
var prevChunks = cacheGroup.chunks;
|
|
239
|
-
cacheGroup.chunks = function(chunk) {
|
|
240
|
-
if (chunk.name && (chunk.name === name || chunk.name === name + '_partial')) {
|
|
241
|
-
return false;
|
|
242
|
-
}
|
|
243
|
-
return prevChunks(chunk);
|
|
244
|
-
};
|
|
245
|
-
break;
|
|
246
|
-
}
|
|
247
|
-
if (cacheGroup.chunks === 'all') {
|
|
248
|
-
cacheGroup.chunks = function(chunk) {
|
|
249
|
-
if (chunk.name && (chunk.name === name || chunk.name === name + '_partial')) {
|
|
250
|
-
return false;
|
|
251
|
-
}
|
|
252
|
-
return true;
|
|
253
|
-
};
|
|
254
|
-
break;
|
|
255
|
-
}
|
|
256
|
-
if (cacheGroup.chunks === 'initial') {
|
|
257
|
-
cacheGroup.chunks = function(chunk) {
|
|
258
|
-
if (chunk.name && (chunk.name === name || chunk.name === name + '_partial')) {
|
|
259
|
-
return false;
|
|
260
|
-
}
|
|
261
|
-
return chunk.isOnlyInitial();
|
|
262
|
-
};
|
|
263
|
-
break;
|
|
264
|
-
}
|
|
265
|
-
break;
|
|
214
|
+
if (typeof cacheGroup.chunks === 'function') {
|
|
215
|
+
const prevChunks = cacheGroup.chunks;
|
|
216
|
+
cacheGroup.chunks = (chunk) => {
|
|
217
|
+
if (chunk.name &&
|
|
218
|
+
(chunk.name === name || chunk.name === name + '_partial')) {
|
|
219
|
+
return false;
|
|
266
220
|
}
|
|
221
|
+
return prevChunks(chunk);
|
|
222
|
+
};
|
|
223
|
+
break;
|
|
267
224
|
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
225
|
+
if (cacheGroup.chunks === 'all') {
|
|
226
|
+
cacheGroup.chunks = (chunk) => {
|
|
227
|
+
if (chunk.name &&
|
|
228
|
+
(chunk.name === name || chunk.name === name + '_partial')) {
|
|
229
|
+
return false;
|
|
230
|
+
}
|
|
231
|
+
return true;
|
|
232
|
+
};
|
|
233
|
+
break;
|
|
234
|
+
}
|
|
235
|
+
if (cacheGroup.chunks === 'initial') {
|
|
236
|
+
cacheGroup.chunks = (chunk) => {
|
|
237
|
+
if (chunk.name &&
|
|
238
|
+
(chunk.name === name || chunk.name === name + '_partial')) {
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
241
|
+
return chunk.isOnlyInitial();
|
|
242
|
+
};
|
|
243
|
+
break;
|
|
244
|
+
}
|
|
245
|
+
break;
|
|
277
246
|
}
|
|
278
|
-
// 修改 splitChunk.cacheGroups[key].chunks
|
|
279
|
-
Object.keys(cacheGroups).forEach(function(cacheGroupKey) {
|
|
280
|
-
patchChunkSplit(cacheGroups[cacheGroupKey]);
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
},
|
|
284
|
-
{
|
|
285
|
-
key: "statsResourceInfo",
|
|
286
|
-
get: function get() {
|
|
287
|
-
var _this__statsPlugin;
|
|
288
|
-
return (_this__statsPlugin = this._statsPlugin) === null || _this__statsPlugin === void 0 ? void 0 : _this__statsPlugin.resourceInfo;
|
|
289
247
|
}
|
|
248
|
+
};
|
|
249
|
+
if (!splitChunks) {
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
// 修改 splitChunk.chunks
|
|
253
|
+
patchChunkSplit(splitChunks);
|
|
254
|
+
const { cacheGroups } = splitChunks;
|
|
255
|
+
if (!cacheGroups) {
|
|
256
|
+
return;
|
|
290
257
|
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
258
|
+
// 修改 splitChunk.cacheGroups[key].chunks
|
|
259
|
+
Object.keys(cacheGroups).forEach((cacheGroupKey) => {
|
|
260
|
+
patchChunkSplit(cacheGroups[cacheGroupKey]);
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
const GetPublicPathPlugin = RemoteEntryPlugin;
|
|
295
265
|
|
|
296
266
|
export { GetPublicPathPlugin, ModuleFederationPlugin, PLUGIN_NAME };
|
|
297
267
|
//# sourceMappingURL=plugin.esm.mjs.map
|
package/dist/plugin.esm.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.esm.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.esm.mjs","sources":["../../src/ModuleFederationPlugin.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;AA+BA,MAAM,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC,kCAAkC,CAAC;AAErE,MAAM,WAAW,GAAG;MACd,sBAAsB,CAAA;AAKjC,I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