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/metal-keys-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@module-federation/enhanced': patch
---

fix(enhanced): Mark all exports as provided, to avoid webpack's export analysis from marking them as unused since we copy buildMeta
8 changes: 6 additions & 2 deletions packages/enhanced/src/lib/sharing/ConsumeSharedPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy
*/

'use strict';
Expand Down Expand Up @@ -736,6 +736,10 @@ class ConsumeSharedPlugin {
// This ensures ConsumeSharedModule inherits ESM/CJS detection (exportsType) and other optimization metadata
module.buildMeta = { ...fallbackModule.buildMeta };
module.buildInfo = { ...fallbackModule.buildInfo };
// Mark all exports as provided, to avoid webpack's export analysis from marking them as unused since we copy buildMeta
compilation.moduleGraph
.getExportsInfo(module)
.setUnknownExportsProvided();
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions packages/enhanced/test/unit/sharing/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ export const createMockCompilation = () => {
const mockModuleGraph = {
getModule: jest.fn(),
getOutgoingConnections: jest.fn().mockReturnValue([]),
getExportsInfo: jest.fn().mockReturnValue({
setUnknownExportsProvided: jest.fn(),
}),
};

// Cast to any to allow flexible property addition
Expand Down
Loading