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

@ -54,13 +54,13 @@ export class CompilerHost implements AotCompilerHost {
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'));
}
m = m.replace(EXT, '');
const resolved =
ts.resolveModuleName(m, containingFile.replace(/\\/g, '/'), this.options, this.context)
.resolvedModule;
return resolved ? resolved.resolvedFileName : null;
return resolved ? this.getCanonicalFileName(resolved.resolvedFileName) : null;
};
/**

View File

@ -32,8 +32,8 @@ export class Extractor {
const programSymbols: compiler.StaticSymbol[] =
extractProgramSymbols(this.program, this.staticReflector, this.compilerHost, this.options);
const {ngModules, files} = compiler.analyzeAndValidateNgModules(
programSymbols, {transitiveModules: true}, this.metadataResolver);
const {ngModules, files} =
compiler.analyzeAndValidateNgModules(programSymbols, {}, this.metadataResolver);
return compiler.loadNgModuleDirectives(ngModules).then(() => {
const errors: compiler.ParseError[] = [];

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] : [];
}