File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 33import assert from 'assert' ;
44import fs from 'fs/promises' ;
55import path from 'path' ;
6- import { builtinModules } from 'module' ;
6+ import module , { builtinModules } from 'module' ;
77import picomatch from 'picomatch' ;
88import { globSync } from 'tinyglobby' ;
99
@@ -76,10 +76,17 @@ const win32 = process.platform === 'win32';
7676
7777/**
7878 * Checks if a module is a core module
79- * module.isBuiltin is available in Node.js 16.17.0 or later. Once we drop support for older
80- * versions of Node.js, we can use module.isBuiltin instead of this function .
79+ * module.isBuiltin is available in Node.js 16.17.0 or later. Use that if available
80+ * as prefix-only modules (those starting with 'node:') can only be checked that way .
8181 */
8282function isBuiltin ( moduleName : string ) {
83+ if (
84+ Reflect . has ( module , 'isBuiltin' ) &&
85+ typeof module . isBuiltin === 'function'
86+ ) {
87+ return module . isBuiltin ( moduleName ) ;
88+ }
89+
8390 const moduleNameWithoutPrefix = moduleName . startsWith ( 'node:' )
8491 ? moduleName . slice ( 5 )
8592 : moduleName ;
You can’t perform that action at this time.
0 commit comments