File tree 1 file changed +12
-0
lines changed
1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change 1
1
import { dirname , join , win32 } from 'node:path'
2
+ import { createRequire } from 'node:module'
2
3
import fs from 'node:fs'
3
4
import fsp from 'node:fs/promises'
4
5
import process from 'node:process'
@@ -28,6 +29,17 @@ function _resolve(path: string, options: PackageResolvingOptions = {}) {
28
29
if ( options . platform === 'auto' || ! options . platform )
29
30
options . platform = process . platform === 'win32' ? 'win32' : 'posix'
30
31
32
+ if ( process . versions . pnp ) {
33
+ const paths = options . paths || [ ]
34
+ if ( paths . length === 0 )
35
+ paths . push ( process . cwd ( ) )
36
+ const targetRequire = createRequire ( import . meta. url )
37
+ try {
38
+ return targetRequire . resolve ( path , { paths } )
39
+ }
40
+ catch { }
41
+ }
42
+
31
43
const modulePath = resolvePathSync ( path , {
32
44
url : options . paths ,
33
45
} )
You can’t perform that action at this time.
0 commit comments