@@ -8,8 +8,8 @@ function constant(value) {
8
8
return ( ) => value
9
9
}
10
10
11
- function baseModule ( name ) {
12
- if ( isScoped ( name ) ) {
11
+ function baseModule ( name , path ) {
12
+ if ( isScoped ( name , path ) ) {
13
13
const [ scope , pkg ] = name . split ( '/' )
14
14
return `${ scope } /${ pkg } `
15
15
}
@@ -21,14 +21,16 @@ export function isAbsolute(name) {
21
21
return name . indexOf ( '/' ) === 0
22
22
}
23
23
24
- export function isBuiltIn ( name , settings ) {
25
- const base = baseModule ( name )
24
+ export function isBuiltIn ( name , settings , path ) {
25
+ const base = baseModule ( name , path )
26
26
const extras = ( settings && settings [ 'import/core-modules' ] ) || [ ]
27
27
return coreModules [ base ] || extras . indexOf ( base ) > - 1
28
28
}
29
29
30
30
function isExternalPath ( path , name , settings ) {
31
- const folders = ( settings && settings [ 'import/external-module-folders' ] ) || [ 'node_modules' ]
31
+ const folders = ( settings && settings [ 'import/external-module-folders' ] ) || [
32
+ 'node_modules'
33
+ ]
32
34
return ! path || folders . some ( folder => - 1 < path . indexOf ( join ( folder , name ) ) )
33
35
}
34
36
@@ -39,21 +41,26 @@ function isExternalModule(name, settings, path) {
39
41
40
42
const externalModuleMainRegExp = / ^ [ \w ] ( (? ! \/ ) .) * $ /
41
43
export function isExternalModuleMain ( name , settings , path ) {
42
- return externalModuleMainRegExp . test ( name ) && isExternalPath ( path , name , settings )
44
+ return (
45
+ externalModuleMainRegExp . test ( name ) && isExternalPath ( path , name , settings )
46
+ )
43
47
}
44
48
45
49
const scopedRegExp = / ^ @ [ ^ / ] + \/ [ ^ / ] + /
46
- function isScoped ( name ) {
47
- return scopedRegExp . test ( name )
50
+ function isScoped ( name , settings , path ) {
51
+ return scopedRegExp . test ( name ) && isExternalPath ( path , name , settings )
48
52
}
49
53
50
54
const scopedMainRegExp = / ^ @ [ ^ / ] + \/ ? [ ^ / ] + $ /
51
- export function isScopedMain ( name ) {
52
- return scopedMainRegExp . test ( name )
55
+ export function isScopedMain ( name , settings , path ) {
56
+ return scopedMainRegExp . test ( name ) && isExternalPath ( path , settings , name )
53
57
}
54
58
55
59
function isInternalModule ( name , settings , path ) {
56
- return externalModuleRegExp . test ( name ) && ! isExternalPath ( path , name , settings )
60
+ return (
61
+ ( scopedRegExp . test ( name ) || externalModuleRegExp . test ( name ) ) &&
62
+ ! isExternalPath ( path , name , settings )
63
+ )
57
64
}
58
65
59
66
function isRelativeToParent ( name ) {
0 commit comments