refactor(comiler): various cleanups

This commit is contained in:
Tobias Bosch
2016-11-17 20:11:55 -08:00
committed by Chuck Jazdzewski
parent adeea5d86a
commit 3c06a5dc25
6 changed files with 89 additions and 80 deletions

View File

@ -48,7 +48,7 @@ export class PathMappedCompilerHost extends CompilerHost {
throw new Error('Resolution of relative paths requires a containing file.');
}
// Any containing file gives the same result for absolute imports
containingFile = path.join(this.basePath, 'index.ts');
containingFile = this.getCanonicalFileName(path.join(this.basePath, 'index.ts'));
}
for (const root of this.options.rootDirs || ['']) {
const rootedContainingFile = path.join(root, containingFile);
@ -58,7 +58,7 @@ export class PathMappedCompilerHost extends CompilerHost {
if (this.options.traceResolution) {
console.log('resolve', m, containingFile, '=>', resolved.resolvedFileName);
}
return resolved.resolvedFileName;
return this.getCanonicalFileName(resolved.resolvedFileName);
}
}
}
@ -86,8 +86,7 @@ export class PathMappedCompilerHost extends CompilerHost {
}
const resolvable = (candidate: string) => {
const resolved =
this.getCanonicalFileName(this.moduleNameToFileName(candidate, importedFile));
const resolved = this.moduleNameToFileName(candidate, importedFile);
return resolved && resolved.replace(EXT, '') === importedFile.replace(EXT, '');
};
@ -133,7 +132,7 @@ export class PathMappedCompilerHost extends CompilerHost {
}
} else {
const sf = this.getSourceFile(rootedPath);
sf.fileName = this.getCanonicalFileName(sf.fileName);
sf.fileName = sf.fileName;
const metadata = this.metadataCollector.getMetadata(sf);
return metadata ? [metadata] : [];
}