@@ -80,12 +80,21 @@ function filePath(relative) {
8080}
8181
8282/**
83- * @param {string } path
83+ * Resolve a CLI shipped by a node_modules package to an absolute path, so we
84+ * can spawn it via `node` directly instead of going through `npx`/`npm exec`
85+ * (which adds a shell + npm wrapper process per concurrent build).
86+ * @param {string } pkg
87+ * @param {string } binName
8488 * @returns {string }
8589 */
86- function quotePath ( path ) {
87- return "\"" + path + "\"" ;
90+ function resolveNodeBin ( pkg , binName ) {
91+ // Resolve via package.json (always allowed) rather than a subpath that may
92+ // be excluded by the package's `exports` field.
93+ const pkgJson = require . resolve ( `${ pkg } /package.json` , { paths : [ ROOT ] } ) ;
94+ return path . join ( path . dirname ( pkgJson ) , require ( pkgJson ) . bin [ binName ] ) ;
8895}
96+ const VITE_BIN = resolveNodeBin ( 'vite' , 'vite' ) ;
97+ const TSC_BIN = resolveNodeBin ( 'typescript' , 'tsc' ) ;
8998
9099class Step {
91100 /**
@@ -866,31 +875,31 @@ const pkgSizePlugin = {
866875const webPackages = [ 'html-reporter' , 'recorder' , 'trace-viewer' , 'dashboard' ] ;
867876for ( const webPackage of webPackages ) {
868877 steps . push ( new ProgramStep ( {
869- command : 'npx' ,
878+ command : process . execPath ,
870879 args : [
871- 'vite' ,
880+ VITE_BIN ,
872881 'build' ,
873882 ...( watchMode ? [ '--watch' , '--minify=false' ] : [ ] ) ,
874883 ...( withSourceMaps ? [ '--sourcemap=inline' ] : [ ] ) ,
875884 '--clearScreen=false' ,
876885 ] ,
877- shell : true ,
886+ shell : false ,
878887 cwd : path . join ( __dirname , '..' , '..' , 'packages' , webPackage ) ,
879888 concurrent : true ,
880889 } ) ) ;
881890}
882891
883892// Build/watch extension
884893steps . push ( new ProgramStep ( {
885- command : 'npx' ,
894+ command : process . execPath ,
886895 args : [
887- 'vite' ,
896+ VITE_BIN ,
888897 'build' ,
889898 ...( watchMode ? [ '--watch' , '--minify=false' ] : [ ] ) ,
890899 ...( withSourceMaps ? [ '--sourcemap=inline' ] : [ ] ) ,
891900 '--clearScreen=false' ,
892901 ] ,
893- shell : true ,
902+ shell : false ,
894903 cwd : path . join ( __dirname , '..' , '..' , 'packages' , 'extension' ) ,
895904 concurrent : true ,
896905} ) ) ;
@@ -1014,9 +1023,9 @@ copyFiles.push({
10141023if ( watchMode ) {
10151024 // Run TypeScript for type checking.
10161025 steps . push ( new ProgramStep ( {
1017- command : 'npx' ,
1018- args : [ 'tsc' , '-w' , '--preserveWatchOutput' , '-p' , quotePath ( filePath ( '.' ) ) ] ,
1019- shell : true ,
1026+ command : process . execPath ,
1027+ args : [ TSC_BIN , '-w' , '--preserveWatchOutput' , '-p' , filePath ( '.' ) ] ,
1028+ shell : false ,
10201029 concurrent : true ,
10211030 } ) ) ;
10221031}
0 commit comments