Skip to content

Commit 361af3c

Browse files
Merge remote-tracking branch 'origin/main' into share-filter
2 parents e413337 + 8a80605 commit 361af3c

File tree

5 files changed

+36
-2
lines changed

5 files changed

+36
-2
lines changed

.changeset/metal-keys-check.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@module-federation/enhanced': patch
3+
---
4+
5+
fix(enhanced): Mark all exports as provided, to avoid webpack's export analysis from marking them as unused since we copy buildMeta

apps/website-new/docs/en/configure/dts.mdx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,13 @@ export default createModuleFederationConfig({
287287

288288
Configure the IP version family that will be used for network operations.
289289

290+
#### typesOnBuild
291+
- Type: `boolean`
292+
- Required: No
293+
- Default: `false`
294+
295+
By default, Module Federation does not load type files in production ( process.env.NODE_ENV === 'production' ). To enable type loading in production builds, set typesOnBuild to true .
296+
290297
### tsConfigPath
291298

292299
- Type: `string`

apps/website-new/docs/zh/configure/dts.mdx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,21 @@ export default createModuleFederationConfig({
276276
}
277277
});
278278
```
279+
#### family
280+
281+
- Type: `4 | 6`
282+
- Required: No
283+
- Default value: 4
284+
285+
配置 ip 版本,用于加载生产者类型文件。
286+
287+
#### typesOnBuild
288+
289+
- 类型:`boolean`
290+
- 是否必填:否
291+
- 默认值:`false`
292+
293+
默认情况下,MF 不会在生产环境(process.env.NODE_ENV === 'production')去加载类型文件。如果需要在生产环境去加载类型文件,需要设置 `typesOnBuild``true`
279294

280295
### tsConfigPath
281296

packages/enhanced/src/lib/sharing/ConsumeSharedPlugin.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
MIT License http://www.opensource.org/licenses/mit-license.php
3-
Author Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy
2+
MIT License http://www.opensource.org/licenses/mit-license.php
3+
Author Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy
44
*/
55

66
'use strict';
@@ -726,6 +726,10 @@ class ConsumeSharedPlugin {
726726
// This ensures ConsumeSharedModule inherits ESM/CJS detection (exportsType) and other optimization metadata
727727
module.buildMeta = { ...fallbackModule.buildMeta };
728728
module.buildInfo = { ...fallbackModule.buildInfo };
729+
// Mark all exports as provided, to avoid webpack's export analysis from marking them as unused since we copy buildMeta
730+
compilation.moduleGraph
731+
.getExportsInfo(module)
732+
.setUnknownExportsProvided();
729733
}
730734
}
731735
}

packages/enhanced/test/unit/sharing/utils.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@ export const createMockCompilation = () => {
202202
const mockModuleGraph = {
203203
getModule: jest.fn(),
204204
getOutgoingConnections: jest.fn().mockReturnValue([]),
205+
getExportsInfo: jest.fn().mockReturnValue({
206+
setUnknownExportsProvided: jest.fn(),
207+
}),
205208
};
206209

207210
// Cast to any to allow flexible property addition

0 commit comments

Comments
 (0)