From 53081093fa662b0860d174b9d0e8fc98badcb009 Mon Sep 17 00:00:00 2001 From: WooWan Date: Wed, 5 Nov 2025 12:50:25 +0900 Subject: [PATCH 1/2] feat(dts-plugin): support type generation for yarn pnp --- .../src/core/lib/typeScriptCompiler.ts | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/packages/dts-plugin/src/core/lib/typeScriptCompiler.ts b/packages/dts-plugin/src/core/lib/typeScriptCompiler.ts index 5678180b8b5..744d64c4486 100644 --- a/packages/dts-plugin/src/core/lib/typeScriptCompiler.ts +++ b/packages/dts-plugin/src/core/lib/typeScriptCompiler.ts @@ -158,6 +158,29 @@ const processTypesFile = async (options: { } }; +const getPMFromUserAgent = () => { + const userAgent = process.env['npm_config_user_agent']; + if (userAgent == null) { + return 'null'; + } + + const name = userAgent.split('/')[0]; + return name; +}; + +const resolvePackageManagerExecutable = () => { + const pm = getPMFromUserAgent(); + + switch (pm) { + case 'yarn': + return 'yarn'; + case 'npm': + case 'pnpm': + default: + return 'npx'; + } +}; + export const compileTs = async ( mapComponentsToExpose: Record, tsConfig: TsConfigJson, @@ -186,7 +209,8 @@ export const compileTs = async ( : undefined, }); const execPromise = util.promisify(exec); - const cmd = `npx ${remoteOptions.compilerInstance} --project '${tempTsConfigJsonPath}'`; + const pmExecutable = resolvePackageManagerExecutable(); + const cmd = `${pmExecutable} ${remoteOptions.compilerInstance} --project '${tempTsConfigJsonPath}'`; try { await execPromise(cmd, { cwd: From fbbd52ad015b811d74369f1c100179d735c6631a Mon Sep 17 00:00:00 2001 From: WooWan Date: Wed, 5 Nov 2025 12:59:57 +0900 Subject: [PATCH 2/2] chore: add changeset --- .changeset/curly-carrots-wink.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/curly-carrots-wink.md diff --git a/.changeset/curly-carrots-wink.md b/.changeset/curly-carrots-wink.md new file mode 100644 index 00000000000..6b37fe1fa15 --- /dev/null +++ b/.changeset/curly-carrots-wink.md @@ -0,0 +1,5 @@ +--- +'@module-federation/dts-plugin': patch +--- + +Support type generation for yarn pnp enviornments