File tree Expand file tree Collapse file tree 2 files changed +26
-10
lines changed Expand file tree Collapse file tree 2 files changed +26
-10
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ var getCompiledPath = require('./get-compiled-path')
3
3
var sep = require ( 'path' ) . sep
4
4
var join = require ( 'path' ) . join
5
5
var execSync = require ( 'child_process' ) . execSync
6
+ var Module = require ( "module" )
6
7
var compilationId
7
8
var timeThreshold = 0
8
9
var allowJs = false
@@ -97,7 +98,9 @@ function registerJsExtension() {
97
98
}
98
99
}
99
100
100
- require ( sourceMapSupportPath ) . install ( {
101
+ var sourceMapRequire = Module . createRequire ? Module . createRequire ( sourceMapSupportPath ) : require
102
+
103
+ sourceMapRequire ( sourceMapSupportPath ) . install ( {
101
104
hookRequire : true
102
105
} )
103
106
Original file line number Diff line number Diff line change 1
- var resolve = require ( 'resolve' ) . sync ;
1
+ var resolve = require ( 'resolve' ) ;
2
2
3
- module . exports = function ( main ) {
4
- var resolved
5
- var opts = {
6
- basedir : process . cwd ( ) ,
7
- paths : [ process . cwd ( ) ]
3
+ function resolveRequest ( req ) {
4
+ // The `resolve` package is prebuilt through ncc, which prevents
5
+ // PnP from being able to inject itself into it. To circumvent
6
+ // this, we simply use PnP directly when available.
7
+ // @ts -ignore
8
+ if ( process . versions . pnp ) {
9
+ const { resolveRequest } = require ( `pnpapi` )
10
+ return resolveRequest ( req , process . cwd ( ) + "/" )
11
+ } else {
12
+
13
+ var opts = {
14
+ basedir : process . cwd ( ) ,
15
+ paths : [ process . cwd ( ) ]
16
+ } ;
17
+ return resolve . sync ( req , opts )
8
18
}
19
+ }
20
+
21
+ module . exports = function ( main ) {
9
22
try {
10
- return resolve ( main + '.ts' , opts ) ;
23
+ return resolveRequest ( main + '.ts' ) ;
11
24
} catch ( e ) {
12
25
try {
13
- return resolve ( main + '/index.ts' , opts ) ;
26
+ return resolveRequest ( main + '/index.ts' ) ;
14
27
} catch ( e ) {
15
- return resolve ( main , opts ) ;
28
+ return resolveRequest ( main ) ;
16
29
}
17
30
}
18
31
} ;
You can’t perform that action at this time.
0 commit comments