Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/large-suits-sit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@module-federation/managers': patch
---

chore: support normalize shared.import option
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ class ModuleFederationPlugin implements WebpackPluginInstance {

private _patchBundlerConfig(compiler: Compiler): void {
const { name } = this._options;
if (name) {
const MFPluginNum = compiler.options.plugins.filter(
(p) => p && p.name === 'ModuleFederationPlugin',
).length;
if (name && MFPluginNum < 2) {
new compiler.webpack.DefinePlugin({
FEDERATION_BUILD_IDENTIFIER: JSON.stringify(
composeKeyWithSeparator(name, utils.getBuildVersion()),
Expand Down
1 change: 0 additions & 1 deletion packages/enhanced/test/setupTestFramework.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,5 @@ if (process.env.DEBUG_INFO) {
// Workaround for a memory leak in wabt
// It leaks an Error object on construction
// so it leaks the whole stack trace
require('wast-loader');
process.removeAllListeners('uncaughtException');
process.removeAllListeners('unhandledRejection');
1 change: 1 addition & 0 deletions packages/managers/__tests__/SharedManager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ describe('SharedManager', () => {
'name',
'version',
'eager',
'import',
].includes(key),
),
).toEqual(true);
Expand Down
11 changes: 9 additions & 2 deletions packages/managers/src/SharedManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,21 @@ class SharedManager extends BasicPluginOptionsManager<moduleFederationPlugin.Mod
get sharedPluginOptions(): SharePluginOptions {
const normalizedShared = this.normalizedOptions;
const shared = Object.keys(normalizedShared).reduce((sum, cur) => {
const { singleton, requiredVersion, version, eager, shareScope } =
normalizedShared[cur];
const {
singleton,
requiredVersion,
version,
eager,
shareScope,
import: sharedImport,
} = normalizedShared[cur];
sum[cur] = {
singleton,
requiredVersion,
version,
eager,
shareScope,
import: sharedImport,
};
return sum;
}, {});
Expand Down