Skip to content

Commit eecee74

Browse files
nachoaldamavScriptedAlchemy
andauthoredMar 14, 2025··
fix(dts-plugin): use cwd to create Module Federation tsconfig (#3381)
Co-authored-by: Zack Jackson <25274700+ScriptedAlchemy@users.noreply.github.com>
1 parent 5c4175e commit eecee74

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed
 

‎.changeset/rotten-pears-knock.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@module-federation/dts-plugin': patch
3+
---
4+
5+
use `cwd` to create Module Federation tsconfig

‎packages/dts-plugin/src/core/lib/typeScriptCompiler.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,14 @@ function writeTempTsConfig(
6262
tsConfig: TsConfigJson,
6363
context: string,
6464
name: string,
65+
cwd?: string,
6566
) {
6667
const createHash = (contents: string) => {
6768
return crypto.createHash('md5').update(contents).digest('hex');
6869
};
6970
const hash = createHash(`${JSON.stringify(tsConfig)}${name}${Date.now()}`);
7071
const tempTsConfigJsonPath = resolve(
71-
context,
72+
cwd ?? context,
7273
'node_modules',
7374
TEMP_DIR,
7475
`tsconfig.${hash}.json`,
@@ -170,6 +171,9 @@ export const compileTs = async (
170171
tsConfig,
171172
remoteOptions.context,
172173
remoteOptions.moduleFederationConfig.name || 'mf',
174+
typeof remoteOptions.moduleFederationConfig.dts !== 'boolean'
175+
? (remoteOptions.moduleFederationConfig.dts?.cwd ?? undefined)
176+
: undefined,
173177
);
174178
try {
175179
const mfTypePath = retrieveMfTypesPath(tsConfig, remoteOptions);

0 commit comments

Comments
 (0)
Please sign in to comment.