File tree 2 files changed +15
-6
lines changed 2 files changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ import fs = require('fs');
2
2
import os = require( 'os' ) ;
3
3
import path = require( 'path' ) ;
4
4
5
+ declare const ESBUILD_VERSION : string ;
6
+
5
7
// This feature was added to give external code a way to modify the binary
6
8
// path without modifying the code itself. Do not remove this because
7
9
// external code relies on this.
@@ -179,16 +181,22 @@ by esbuild to install the correct binary executable for your current platform.`)
179
181
// it's inside a virtual file system and the OS needs it in the real file
180
182
// system. So we need to copy the file out of the virtual file system into
181
183
// the real file system.
182
- let isYarnPnP = false ;
184
+ let pnpapi : any ;
183
185
try {
184
- require ( 'pnpapi' ) ;
185
- isYarnPnP = true ;
186
+ pnpapi = require ( 'pnpapi' ) ;
186
187
} catch ( e ) {
187
188
}
188
- if ( isYarnPnP ) {
189
- const esbuildLibDir = path . dirname ( require . resolve ( 'esbuild' ) ) ;
190
- const binTargetPath = path . join ( esbuildLibDir , `pnpapi-${ pkg } -${ path . basename ( subpath ) } ` ) ;
189
+ if ( pnpapi ) {
190
+ const root = pnpapi . getPackageInformation ( pnpapi . topLevel ) . packageLocation ;
191
+ const binTargetPath = path . join (
192
+ root ,
193
+ 'node_modules' ,
194
+ '.cache' ,
195
+ 'esbuild' ,
196
+ `pnpapi-${ pkg } -${ ESBUILD_VERSION } -${ path . basename ( subpath ) } ` ,
197
+ ) ;
191
198
if ( ! fs . existsSync ( binTargetPath ) ) {
199
+ fs . mkdirSync ( path . dirname ( binTargetPath ) , { recursive : true } ) ;
192
200
fs . copyFileSync ( binPath , binTargetPath ) ;
193
201
fs . chmodSync ( binTargetPath , 0o755 ) ;
194
202
}
Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ const buildNeutralLib = (esbuildPath) => {
49
49
'--outfile=' + path . join ( binDir , 'esbuild' ) ,
50
50
'--bundle' ,
51
51
'--target=' + nodeTarget ,
52
+ '--define:ESBUILD_VERSION=' + JSON . stringify ( version ) ,
52
53
'--external:esbuild' ,
53
54
'--platform=node' ,
54
55
'--log-level=warning' ,
You can’t perform that action at this time.
0 commit comments