@@ -53,13 +53,13 @@ namespace ts {
53
53
if ( getRootLength ( moduleName ) !== 0 || nameStartsWithDotSlashOrDotDotSlash ( moduleName ) ) {
54
54
const failedLookupLocations : string [ ] = [ ] ;
55
55
const candidate = normalizePath ( combinePaths ( containingDirectory , moduleName ) ) ;
56
- let resolvedFileName = loadNodeModuleFromFile ( candidate , failedLookupLocations , host ) ;
56
+ let resolvedFileName = loadNodeModuleFromFile ( supportedJsExtensions , candidate , failedLookupLocations , host ) ;
57
57
58
58
if ( resolvedFileName ) {
59
59
return { resolvedModule : { resolvedFileName } , failedLookupLocations } ;
60
60
}
61
61
62
- resolvedFileName = loadNodeModuleFromDirectory ( candidate , failedLookupLocations , host ) ;
62
+ resolvedFileName = loadNodeModuleFromDirectory ( supportedJsExtensions , candidate , failedLookupLocations , host ) ;
63
63
return resolvedFileName
64
64
? { resolvedModule : { resolvedFileName } , failedLookupLocations }
65
65
: { resolvedModule : undefined , failedLookupLocations } ;
@@ -69,8 +69,8 @@ namespace ts {
69
69
}
70
70
}
71
71
72
- function loadNodeModuleFromFile ( candidate : string , failedLookupLocation : string [ ] , host : ModuleResolutionHost ) : string {
73
- return forEach ( supportedExtensions , tryLoad ) ;
72
+ function loadNodeModuleFromFile ( extensions : string [ ] , candidate : string , failedLookupLocation : string [ ] , host : ModuleResolutionHost ) : string {
73
+ return forEach ( extensions , tryLoad ) ;
74
74
75
75
function tryLoad ( ext : string ) : string {
76
76
const fileName = fileExtensionIs ( candidate , ext ) ? candidate : candidate + ext ;
@@ -84,7 +84,7 @@ namespace ts {
84
84
}
85
85
}
86
86
87
- function loadNodeModuleFromDirectory ( candidate : string , failedLookupLocation : string [ ] , host : ModuleResolutionHost ) : string {
87
+ function loadNodeModuleFromDirectory ( extensions : string [ ] , candidate : string , failedLookupLocation : string [ ] , host : ModuleResolutionHost ) : string {
88
88
const packageJsonPath = combinePaths ( candidate , "package.json" ) ;
89
89
if ( host . fileExists ( packageJsonPath ) ) {
90
90
@@ -100,7 +100,7 @@ namespace ts {
100
100
}
101
101
102
102
if ( jsonContent . typings ) {
103
- const result = loadNodeModuleFromFile ( normalizePath ( combinePaths ( candidate , jsonContent . typings ) ) , failedLookupLocation , host ) ;
103
+ const result = loadNodeModuleFromFile ( extensions , normalizePath ( combinePaths ( candidate , jsonContent . typings ) ) , failedLookupLocation , host ) ;
104
104
if ( result ) {
105
105
return result ;
106
106
}
@@ -111,7 +111,7 @@ namespace ts {
111
111
failedLookupLocation . push ( packageJsonPath ) ;
112
112
}
113
113
114
- return loadNodeModuleFromFile ( combinePaths ( candidate , "index" ) , failedLookupLocation , host ) ;
114
+ return loadNodeModuleFromFile ( extensions , combinePaths ( candidate , "index" ) , failedLookupLocation , host ) ;
115
115
}
116
116
117
117
function loadModuleFromNodeModules ( moduleName : string , directory : string , host : ModuleResolutionHost ) : ResolvedModuleWithFailedLookupLocations {
@@ -122,12 +122,12 @@ namespace ts {
122
122
if ( baseName !== "node_modules" ) {
123
123
const nodeModulesFolder = combinePaths ( directory , "node_modules" ) ;
124
124
const candidate = normalizePath ( combinePaths ( nodeModulesFolder , moduleName ) ) ;
125
- let result = loadNodeModuleFromFile ( candidate , failedLookupLocations , host ) ;
125
+ let result = loadNodeModuleFromFile ( supportedExtensions , candidate , failedLookupLocations , host ) ;
126
126
if ( result ) {
127
127
return { resolvedModule : { resolvedFileName : result , isExternalLibraryImport : true } , failedLookupLocations } ;
128
128
}
129
129
130
- result = loadNodeModuleFromDirectory ( candidate , failedLookupLocations , host ) ;
130
+ result = loadNodeModuleFromDirectory ( supportedExtensions , candidate , failedLookupLocations , host ) ;
131
131
if ( result ) {
132
132
return { resolvedModule : { resolvedFileName : result , isExternalLibraryImport : true } , failedLookupLocations } ;
133
133
}
@@ -162,7 +162,7 @@ namespace ts {
162
162
const failedLookupLocations : string [ ] = [ ] ;
163
163
164
164
let referencedSourceFile : string ;
165
- let extensions = compilerOptions . allowNonTsExtensions ? supportedJsExtensions : supportedExtensions ;
165
+ const extensions = compilerOptions . allowNonTsExtensions ? supportedJsExtensions : supportedExtensions ;
166
166
while ( true ) {
167
167
searchName = normalizePath ( combinePaths ( searchPath , moduleName ) ) ;
168
168
referencedSourceFile = forEach ( extensions , extension => {
@@ -689,7 +689,7 @@ namespace ts {
689
689
return ;
690
690
}
691
691
692
- let isJavaScriptFile = isSourceFileJavaScript ( file ) ;
692
+ const isJavaScriptFile = isSourceFileJavaScript ( file ) ;
693
693
694
694
let imports : LiteralExpression [ ] ;
695
695
for ( const node of file . statements ) {
0 commit comments