File tree Expand file tree Collapse file tree 4 files changed +10
-16
lines changed Expand file tree Collapse file tree 4 files changed +10
-16
lines changed Original file line number Diff line number Diff line change @@ -146,7 +146,6 @@ const { safeGetenv } = internalBinding('credentials');
146
146
const {
147
147
getCjsConditions,
148
148
initializeCjsConditions,
149
- isUnderNodeModules,
150
149
loadBuiltinModule,
151
150
makeRequireFunction,
152
151
setHasStartedUserCJSExecution,
Original file line number Diff line number Diff line change 3
3
const {
4
4
RegExpPrototypeExec,
5
5
} = primordials ;
6
- const { kEmptyObject } = require ( 'internal/util' ) ;
6
+ const {
7
+ isUnderNodeModules,
8
+ kEmptyObject,
9
+ } = require ( 'internal/util' ) ;
7
10
8
11
const { defaultGetFormat } = require ( 'internal/modules/esm/get_format' ) ;
9
12
const { validateAttributes, emitImportAssertionWarning } = require ( 'internal/modules/esm/assert' ) ;
@@ -14,9 +17,6 @@ const defaultType =
14
17
getOptionValue ( '--experimental-default-type' ) ;
15
18
16
19
const { Buffer : { from : BufferFrom } } = require ( 'buffer' ) ;
17
- const {
18
- isUnderNodeModules,
19
- } = require ( 'internal/modules/helpers' ) ;
20
20
21
21
const { URL } = require ( 'internal/url' ) ;
22
22
const {
Original file line number Diff line number Diff line change 2
2
3
3
const {
4
4
ArrayPrototypeForEach,
5
- ArrayPrototypeIncludes,
6
5
ObjectDefineProperty,
7
6
ObjectFreeze,
8
7
ObjectPrototypeHasOwnProperty,
@@ -11,7 +10,6 @@ const {
11
10
StringPrototypeCharCodeAt,
12
11
StringPrototypeIncludes,
13
12
StringPrototypeSlice,
14
- StringPrototypeSplit,
15
13
StringPrototypeStartsWith,
16
14
} = primordials ;
17
15
const {
@@ -387,13 +385,6 @@ function stripTypeScriptTypes(source, filename) {
387
385
return `${ code } \n\n//# sourceURL=${ filename } ` ;
388
386
}
389
387
390
- function isUnderNodeModules ( filename ) {
391
- const resolvedPath = path . resolve ( filename ) ;
392
- const normalizedPath = path . normalize ( resolvedPath ) ;
393
- const splitPath = StringPrototypeSplit ( normalizedPath , path . sep ) ;
394
- return ArrayPrototypeIncludes ( splitPath , 'node_modules' ) ;
395
- }
396
-
397
388
/**
398
389
* Enable on-disk compiled cache for all user modules being complied in the current Node.js instance
399
390
* after this method is called.
@@ -493,7 +484,6 @@ module.exports = {
493
484
getCjsConditions,
494
485
getCompileCacheDir,
495
486
initializeCjsConditions,
496
- isUnderNodeModules,
497
487
loadBuiltinModule,
498
488
makeRequireFunction,
499
489
normalizeReferrerURL,
Original file line number Diff line number Diff line change @@ -481,6 +481,10 @@ function spliceOne(list, index) {
481
481
482
482
const kNodeModulesRE = / ^ (?: .* ) [ \\ / ] n o d e _ m o d u l e s [ \\ / ] / ;
483
483
484
+ function isUnderNodeModules ( filename ) {
485
+ return filename && ( RegExpPrototypeExec ( kNodeModulesRE , filename ) !== null ) ;
486
+ }
487
+
484
488
let getStructuredStackImpl ;
485
489
486
490
function lazyGetStructuredStack ( ) {
@@ -528,7 +532,7 @@ function isInsideNodeModules() {
528
532
) {
529
533
continue ;
530
534
}
531
- return RegExpPrototypeExec ( kNodeModulesRE , filename ) !== null ;
535
+ return isUnderNodeModules ( filename ) ;
532
536
}
533
537
}
534
538
return false ;
@@ -908,6 +912,7 @@ module.exports = {
908
912
guessHandleType,
909
913
isError,
910
914
isInsideNodeModules,
915
+ isUnderNodeModules,
911
916
isMacOS,
912
917
isWindows,
913
918
join,
You can’t perform that action at this time.
0 commit comments