Skip to content

Commit d880d4f

Browse files
committed
Don't look for .js files when resolving node modules
1 parent 7a94031 commit d880d4f

2 files changed

Lines changed: 2 additions & 26 deletions

File tree

src/compiler/program.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ namespace ts {
7070
}
7171

7272
function loadNodeModuleFromFile(candidate: string, failedLookupLocation: string[], host: ModuleResolutionHost): string {
73-
return forEach(supportedJsExtensions, tryLoad);
73+
return forEach(supportedExtensions, tryLoad);
7474

7575
function tryLoad(ext: string): string {
7676
let fileName = fileExtensionIs(candidate, ext) ? candidate : candidate + ext;

tests/cases/unittests/moduleResolution.ts

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ module ts {
8282
assert.equal(resolution.resolvedModule.resolvedFileName, moduleFile.name);
8383
assert.equal(!!resolution.resolvedModule.isExternalLibraryImport, false);
8484
// expect three failed lookup location - attempt to load module as file with all supported extensions
85-
assert.equal(resolution.failedLookupLocations.length, 5);
85+
assert.equal(resolution.failedLookupLocations.length, 3);
8686
}
8787

8888
it("module name as directory - load from typings", () => {
@@ -103,8 +103,6 @@ module ts {
103103
"/a/b/foo.ts",
104104
"/a/b/foo.tsx",
105105
"/a/b/foo.d.ts",
106-
"/a/b/foo.js",
107-
"/a/b/foo.jsx",
108106
"/a/b/foo/index.ts",
109107
"/a/b/foo/index.tsx",
110108
]);
@@ -121,25 +119,17 @@ module ts {
121119
"/a/b/c/d/node_modules/foo.ts",
122120
"/a/b/c/d/node_modules/foo.tsx",
123121
"/a/b/c/d/node_modules/foo.d.ts",
124-
"/a/b/c/d/node_modules/foo.js",
125-
"/a/b/c/d/node_modules/foo.jsx",
126122
"/a/b/c/d/node_modules/foo/package.json",
127123
"/a/b/c/d/node_modules/foo/index.ts",
128124
"/a/b/c/d/node_modules/foo/index.tsx",
129125
"/a/b/c/d/node_modules/foo/index.d.ts",
130-
"/a/b/c/d/node_modules/foo/index.js",
131-
"/a/b/c/d/node_modules/foo/index.jsx",
132126
"/a/b/c/node_modules/foo.ts",
133127
"/a/b/c/node_modules/foo.tsx",
134128
"/a/b/c/node_modules/foo.d.ts",
135-
"/a/b/c/node_modules/foo.js",
136-
"/a/b/c/node_modules/foo.jsx",
137129
"/a/b/c/node_modules/foo/package.json",
138130
"/a/b/c/node_modules/foo/index.ts",
139131
"/a/b/c/node_modules/foo/index.tsx",
140132
"/a/b/c/node_modules/foo/index.d.ts",
141-
"/a/b/c/node_modules/foo/index.js",
142-
"/a/b/c/node_modules/foo/index.jsx"
143133
])
144134
});
145135

@@ -161,41 +151,27 @@ module ts {
161151
"/a/node_modules/b/c/node_modules/d/node_modules/foo.ts",
162152
"/a/node_modules/b/c/node_modules/d/node_modules/foo.tsx",
163153
"/a/node_modules/b/c/node_modules/d/node_modules/foo.d.ts",
164-
"/a/node_modules/b/c/node_modules/d/node_modules/foo.js",
165-
"/a/node_modules/b/c/node_modules/d/node_modules/foo.jsx",
166154
"/a/node_modules/b/c/node_modules/d/node_modules/foo/package.json",
167155
"/a/node_modules/b/c/node_modules/d/node_modules/foo/index.ts",
168156
"/a/node_modules/b/c/node_modules/d/node_modules/foo/index.tsx",
169157
"/a/node_modules/b/c/node_modules/d/node_modules/foo/index.d.ts",
170-
"/a/node_modules/b/c/node_modules/d/node_modules/foo/index.js",
171-
"/a/node_modules/b/c/node_modules/d/node_modules/foo/index.jsx",
172158
"/a/node_modules/b/c/node_modules/foo.ts",
173159
"/a/node_modules/b/c/node_modules/foo.tsx",
174160
"/a/node_modules/b/c/node_modules/foo.d.ts",
175-
"/a/node_modules/b/c/node_modules/foo.js",
176-
"/a/node_modules/b/c/node_modules/foo.jsx",
177161
"/a/node_modules/b/c/node_modules/foo/package.json",
178162
"/a/node_modules/b/c/node_modules/foo/index.ts",
179163
"/a/node_modules/b/c/node_modules/foo/index.tsx",
180164
"/a/node_modules/b/c/node_modules/foo/index.d.ts",
181-
"/a/node_modules/b/c/node_modules/foo/index.js",
182-
"/a/node_modules/b/c/node_modules/foo/index.jsx",
183165
"/a/node_modules/b/node_modules/foo.ts",
184166
"/a/node_modules/b/node_modules/foo.tsx",
185167
"/a/node_modules/b/node_modules/foo.d.ts",
186-
"/a/node_modules/b/node_modules/foo.js",
187-
"/a/node_modules/b/node_modules/foo.jsx",
188168
"/a/node_modules/b/node_modules/foo/package.json",
189169
"/a/node_modules/b/node_modules/foo/index.ts",
190170
"/a/node_modules/b/node_modules/foo/index.tsx",
191171
"/a/node_modules/b/node_modules/foo/index.d.ts",
192-
"/a/node_modules/b/node_modules/foo/index.js",
193-
"/a/node_modules/b/node_modules/foo/index.jsx",
194172
"/a/node_modules/foo.ts",
195173
"/a/node_modules/foo.tsx",
196174
"/a/node_modules/foo.d.ts",
197-
"/a/node_modules/foo.js",
198-
"/a/node_modules/foo.jsx",
199175
"/a/node_modules/foo/package.json",
200176
"/a/node_modules/foo/index.ts",
201177
"/a/node_modules/foo/index.tsx"

0 commit comments

Comments
 (0)