File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed
packages/dts-plugin/src/core/lib Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @module-federation/dts-plugin ' : patch
3+ ---
4+
5+ Support type generation for yarn pnp enviornments
Original file line number Diff line number Diff line change @@ -158,6 +158,29 @@ const processTypesFile = async (options: {
158158 }
159159} ;
160160
161+ const getPMFromUserAgent = ( ) => {
162+ const userAgent = process . env [ 'npm_config_user_agent' ] ;
163+ if ( userAgent == null ) {
164+ return 'null' ;
165+ }
166+
167+ const name = userAgent . split ( '/' ) [ 0 ] ;
168+ return name ;
169+ } ;
170+
171+ const resolvePackageManagerExecutable = ( ) => {
172+ const pm = getPMFromUserAgent ( ) ;
173+
174+ switch ( pm ) {
175+ case 'yarn' :
176+ return 'yarn' ;
177+ case 'npm' :
178+ case 'pnpm' :
179+ default :
180+ return 'npx' ;
181+ }
182+ } ;
183+
161184export const compileTs = async (
162185 mapComponentsToExpose : Record < string , string > ,
163186 tsConfig : TsConfigJson ,
@@ -186,7 +209,8 @@ export const compileTs = async (
186209 : undefined ,
187210 } ) ;
188211 const execPromise = util . promisify ( exec ) ;
189- const cmd = `npx ${ remoteOptions . compilerInstance } --project '${ tempTsConfigJsonPath } '` ;
212+ const pmExecutable = resolvePackageManagerExecutable ( ) ;
213+ const cmd = `${ pmExecutable } ${ remoteOptions . compilerInstance } --project '${ tempTsConfigJsonPath } '` ;
190214 try {
191215 await execPromise ( cmd , {
192216 cwd :
You can’t perform that action at this time.
0 commit comments