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