File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -4,24 +4,26 @@ import Module from "../module.js"
4
4
5
5
import { sep } from "../safe/path.js"
6
6
7
+ import escapeRegExp from "../util/escape-regexp.js"
8
+
7
9
const {
8
10
FLAGS
9
11
} = ENV
10
12
11
- const YARN_PNP_FILENAME = " .pnp.js"
13
+ const yarnPnpFilenameRegExp = new RegExp ( ` ${ escapeRegExp ( sep ) } \\ .pnp\\.c?js$` )
12
14
13
15
function hook ( pnp ) {
14
16
const { _cache } = Module
15
17
16
18
for ( const name in _cache ) {
17
- if ( name . endsWith ( sep + YARN_PNP_FILENAME ) ) {
19
+ if ( yarnPnpFilenameRegExp . test ( name ) ) {
18
20
Reflect . deleteProperty ( _cache , name )
19
21
break
20
22
}
21
23
}
22
24
23
25
for ( const request of FLAGS . preloadModules ) {
24
- if ( request . endsWith ( sep + YARN_PNP_FILENAME ) ) {
26
+ if ( yarnPnpFilenameRegExp . test ( request ) ) {
25
27
Module . _preloadModules ( [ request ] )
26
28
pnp . _resolveFilename = Module . _resolveFilename
27
29
break
You can’t perform that action at this time.
0 commit comments