diff --git a/.changeset/rotten-pears-knock.md b/.changeset/rotten-pears-knock.md new file mode 100644 index 00000000000..5aebcd71f9c --- /dev/null +++ b/.changeset/rotten-pears-knock.md @@ -0,0 +1,5 @@ +--- +'@module-federation/dts-plugin': patch +--- + +use `cwd` to create Module Federation tsconfig diff --git a/packages/dts-plugin/src/core/lib/typeScriptCompiler.ts b/packages/dts-plugin/src/core/lib/typeScriptCompiler.ts index d6af86836d7..82adcf26233 100644 --- a/packages/dts-plugin/src/core/lib/typeScriptCompiler.ts +++ b/packages/dts-plugin/src/core/lib/typeScriptCompiler.ts @@ -62,13 +62,14 @@ function writeTempTsConfig( tsConfig: TsConfigJson, context: string, name: string, + cwd?: string, ) { const createHash = (contents: string) => { return crypto.createHash('md5').update(contents).digest('hex'); }; const hash = createHash(`${JSON.stringify(tsConfig)}${name}`); const tempTsConfigJsonPath = resolve( - context, + cwd ?? context, 'node_modules', TEMP_DIR, `tsconfig.${hash}.json`, @@ -170,6 +171,9 @@ export const compileTs = async ( tsConfig, remoteOptions.context, remoteOptions.moduleFederationConfig.name || 'mf', + typeof remoteOptions.moduleFederationConfig.dts !== 'boolean' + ? (remoteOptions.moduleFederationConfig.dts?.cwd ?? undefined) + : undefined, ); try { const mfTypePath = retrieveMfTypesPath(tsConfig, remoteOptions);