File tree 5 files changed +33
-4
lines changed
5 files changed +33
-4
lines changed Original file line number Diff line number Diff line change 9
9
"main" : " build/index.js" ,
10
10
"dependencies" : {
11
11
"browser-resolve" : " ^1.11.2" ,
12
- "chalk" : " ^2.0.1" ,
13
- "is-builtin-module" : " ^1.0.0"
12
+ "chalk" : " ^2.0.1"
14
13
},
15
14
"devDependencies" : {
16
15
"jest-haste-map" : " ^21.2.0"
Original file line number Diff line number Diff line change
1
+ const isBuiltinModule = require ( '../is_builtin_module' ) ;
2
+
3
+ describe ( 'isBuiltinModule' , ( ) => {
4
+ it ( 'should return true for the `path` module' , ( ) => {
5
+ expect ( isBuiltinModule ( 'path' ) ) . toBe ( true ) ;
6
+ } ) ;
7
+
8
+ it ( 'should return false for the `chalk` module' , ( ) => {
9
+ expect ( isBuiltinModule ( 'chalk' ) ) . toBe ( false ) ;
10
+ } ) ;
11
+
12
+ it ( 'should return true for the `_http_common` module' , ( ) => {
13
+ expect ( isBuiltinModule ( '_http_common' ) ) . toBe ( true ) ;
14
+ } ) ;
15
+
16
+ it ( 'should return false for any internal node builtins' , ( ) => {
17
+ expect ( isBuiltinModule ( 'internal/http' ) ) . toBe ( false ) ;
18
+ } ) ;
19
+ } ) ;
Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ type ErrorWithCode = Error & {code?: string};
42
42
43
43
import fs from 'fs' ;
44
44
import path from 'path' ;
45
- import isBuiltinModule from 'is-builtin-module ' ;
45
+ import isBuiltinModule from './is_builtin_module ' ;
46
46
47
47
import nodeModulesPaths from './node_modules_paths' ;
48
48
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ import type {ResolveModuleConfig} from 'types/Resolve';
14
14
import fs from 'fs' ;
15
15
import path from 'path' ;
16
16
import nodeModulesPaths from './node_modules_paths' ;
17
- import isBuiltinModule from 'is-builtin-module ' ;
17
+ import isBuiltinModule from './is_builtin_module ' ;
18
18
import defaultResolver from './default_resolver.js' ;
19
19
import chalk from 'chalk' ;
20
20
Original file line number Diff line number Diff line change
1
+ declare var process: {
2
+ binding ( type : string ) : { } ,
3
+ } ;
4
+
5
+ const BUILTIN_MODULES = Object . keys ( process . binding ( 'natives' ) ) . filter (
6
+ ( module : string ) => ! / ^ i n t e r n a l \/ / . test ( module ) ,
7
+ ) ;
8
+
9
+ module . exports = function isBuiltinModule ( module : string ) : boolean {
10
+ return BUILTIN_MODULES . indexOf ( module ) !== - 1 ;
11
+ } ;
You can’t perform that action at this time.
0 commit comments