Skip to content

Commit cce5404

Browse files
authored
chore: support normalize shared.import option (#2535)
1 parent 425fc9d commit cce5404

File tree

5 files changed

+19
-4
lines changed

5 files changed

+19
-4
lines changed

.changeset/large-suits-sit.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@module-federation/managers': patch
3+
---
4+
5+
chore: support normalize shared.import option

packages/enhanced/src/lib/container/ModuleFederationPlugin.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ class ModuleFederationPlugin implements WebpackPluginInstance {
5151

5252
private _patchBundlerConfig(compiler: Compiler): void {
5353
const { name } = this._options;
54-
if (name) {
54+
const MFPluginNum = compiler.options.plugins.filter(
55+
(p) => p && p.name === 'ModuleFederationPlugin',
56+
).length;
57+
if (name && MFPluginNum < 2) {
5558
new compiler.webpack.DefinePlugin({
5659
FEDERATION_BUILD_IDENTIFIER: JSON.stringify(
5760
composeKeyWithSeparator(name, utils.getBuildVersion()),

packages/enhanced/test/setupTestFramework.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,5 @@ if (process.env.DEBUG_INFO) {
130130
// Workaround for a memory leak in wabt
131131
// It leaks an Error object on construction
132132
// so it leaks the whole stack trace
133-
require('wast-loader');
134133
process.removeAllListeners('uncaughtException');
135134
process.removeAllListeners('unhandledRejection');

packages/managers/__tests__/SharedManager.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ describe('SharedManager', () => {
5555
'name',
5656
'version',
5757
'eager',
58+
'import',
5859
].includes(key),
5960
),
6061
).toEqual(true);

packages/managers/src/SharedManager.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,21 @@ class SharedManager extends BasicPluginOptionsManager<moduleFederationPlugin.Mod
1919
get sharedPluginOptions(): SharePluginOptions {
2020
const normalizedShared = this.normalizedOptions;
2121
const shared = Object.keys(normalizedShared).reduce((sum, cur) => {
22-
const { singleton, requiredVersion, version, eager, shareScope } =
23-
normalizedShared[cur];
22+
const {
23+
singleton,
24+
requiredVersion,
25+
version,
26+
eager,
27+
shareScope,
28+
import: sharedImport,
29+
} = normalizedShared[cur];
2430
sum[cur] = {
2531
singleton,
2632
requiredVersion,
2733
version,
2834
eager,
2935
shareScope,
36+
import: sharedImport,
3037
};
3138
return sum;
3239
}, {});

0 commit comments

Comments
 (0)