Skip to content

Revised module resolution #4154

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Aug 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
226deec
reuse structure of the program if changes in files don't affect impor…
vladima Jun 23, 2015
39e832d
use existing information about module resolutions
vladima Jun 23, 2015
7a7d775
Merge remote-tracking branch 'origin/master' into reuseProgramStructure
vladima Jun 23, 2015
ba3eb0d
added Program.structureIsReused property, disallow reuse if target mo…
vladima Jun 24, 2015
16deccd
revert unintentional change
vladima Jun 24, 2015
9e81ac9
merge with master
vladima Jun 24, 2015
df508de
fix formatting in parser
vladima Jun 24, 2015
c968b36
addressed PR feedback
vladima Jun 25, 2015
66f6736
addressed PR feedback
vladima Jun 25, 2015
2685d40
addressed PR feedback
vladima Jul 9, 2015
6a502cd
Merge remote-tracking branch 'origin/master' into reuseProgramStructure
vladima Jul 9, 2015
e15c700
clean old program to prevent it from being captured into the closure
vladima Jul 9, 2015
9332f7e
introduce ModuleResolutionHost interface
vladima Jul 14, 2015
d7661ec
do not try to resolve modules that has '!' in the name, put .tsx exte…
vladima Jul 29, 2015
544a793
return ambient external modules as a results of preprocessing
vladima Jul 29, 2015
36043cd
merge with master
vladima Jul 30, 2015
f9c0758
fix formatting
vladima Jul 30, 2015
f22c160
Merge remote-tracking branch 'origin/master' into reuseAndCache
vladima Aug 3, 2015
49ad395
resolveModuleName => resolvedModuleNames, added tests
vladima Aug 4, 2015
a72994d
removed extra whitespaces, added commments
vladima Aug 4, 2015
03aaf7c
addressed PR feedback
vladima Aug 5, 2015
fc1e89a
addressed CR feedback: merged getDefaultModuleResolver and resolveMod…
vladima Aug 5, 2015
6455b8e
merge with master
vladima Aug 6, 2015
a69b041
delete entry from the cache when referenced file is removed, added tests
vladima Aug 6, 2015
b4faf3c
added missing test assets
vladima Aug 6, 2015
405db82
mismatch order of arguments
vladima Aug 12, 2015
a88bfbd
Merge branch 'master' into reuseAndCache
vladima Aug 17, 2015
b6b735c
merge with master
vladima Aug 17, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Jakefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ var harnessSources = harnessCoreSources.concat([
"session.ts",
"versionCache.ts",
"convertToBase64.ts",
"transpile.ts"
"transpile.ts",
"reuseProgramStructure.ts",
"cachingInServerLSHost.ts"
].map(function (f) {
return path.join(unittestsDirectory, f);
})).concat([
Expand Down
21 changes: 6 additions & 15 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -965,28 +965,19 @@ namespace ts {
// Escape the name in the "require(...)" clause to ensure we find the right symbol.
let moduleName = escapeIdentifier(moduleReferenceLiteral.text);

if (!moduleName) return;
if (!moduleName) {
return;
}
let isRelative = isExternalModuleNameRelative(moduleName);
if (!isRelative) {
let symbol = getSymbol(globals, "\"" + moduleName + "\"", SymbolFlags.ValueModule);
if (symbol) {
return symbol;
}
}
let fileName: string;
let sourceFile: SourceFile;
while (true) {
fileName = normalizePath(combinePaths(searchPath, moduleName));
sourceFile = forEach(supportedExtensions, extension => host.getSourceFile(fileName + extension));
if (sourceFile || isRelative) {
break;
}
let parentPath = getDirectoryPath(searchPath);
if (parentPath === searchPath) {
break;
}
searchPath = parentPath;
}

let fileName = getResolvedModuleFileName(getSourceFile(location), moduleReferenceLiteral.text);
let sourceFile = fileName && host.getSourceFile(fileName);
if (sourceFile) {
if (sourceFile.symbol) {
return sourceFile.symbol;
Expand Down
7 changes: 6 additions & 1 deletion src/compiler/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ namespace ts {
set,
contains,
remove,
clear,
forEachValue: forEachValueInMap
};

Expand Down Expand Up @@ -51,6 +52,10 @@ namespace ts {
function normalizeKey(key: string) {
return getCanonicalFileName(normalizeSlashes(key));
}

function clear() {
files = {};
}
}

export const enum Comparison {
Expand Down Expand Up @@ -716,7 +721,7 @@ namespace ts {
/**
* List of supported extensions in order of file resolution precedence.
*/
export const supportedExtensions = [".tsx", ".ts", ".d.ts"];
export const supportedExtensions = [".ts", ".tsx", ".d.ts"];

const extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx"];
export function removeFileExtension(path: string): string {
Expand Down
Loading