Make file as externalLibrary import if path contains node_modules

This commit is contained in:
Sheetal Nandi 2018-08-14 16:21:22 -07:00
parent a32f62b310
commit 1dd3cd288e
4 changed files with 2 additions and 21 deletions

View file

@ -769,7 +769,7 @@ namespace ts {
const loader: ResolutionKindSpecificLoader = (extensions, candidate, failedLookupLocations, onlyRecordFailures, state) => nodeLoadModuleByRelativeName(extensions, candidate, failedLookupLocations, onlyRecordFailures, state, /*considerPackageJson*/ true);
const resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, failedLookupLocations, state);
if (resolved) {
return toSearchResult({ resolved, isExternalLibraryImport: false });
return toSearchResult({ resolved, isExternalLibraryImport: resolved.path.indexOf("/node_modules/") !== -1 });
}
if (!isExternalModuleNameRelative(moduleName)) {

View file

@ -7,8 +7,6 @@ module.exports = { a: 10 };
import foobar from "foo/bar/foobar.js";
//// [/bin/node_modules/foo/bar/foobar.js]
module.exports = { a: 10 };
//// [/bin/a.js]
"use strict";
exports.__esModule = true;

View file

@ -2,10 +2,3 @@
import foobar from "foo/bar/foobar.js";
>foobar : Symbol(foobar, Decl(a.ts, 0, 6))
=== /node_modules/foo/bar/foobar.js ===
module.exports = { a: 10 };
>module.exports : Symbol("/node_modules/foo/bar/foobar", Decl(foobar.js, 0, 0))
>module : Symbol(export=, Decl(foobar.js, 0, 0))
>exports : Symbol(export=, Decl(foobar.js, 0, 0))
>a : Symbol(a, Decl(foobar.js, 0, 18))

View file

@ -1,14 +1,4 @@
=== /a.ts ===
import foobar from "foo/bar/foobar.js";
>foobar : { a: number; }
=== /node_modules/foo/bar/foobar.js ===
module.exports = { a: 10 };
>module.exports = { a: 10 } : { a: number; }
>module.exports : { a: number; }
>module : { "/node_modules/foo/bar/foobar": { a: number; }; }
>exports : { a: number; }
>{ a: 10 } : { a: number; }
>a : number
>10 : 10
>foobar : any