feat(compiler): generate shallow imports compiler generated references (#14388)

This commit is contained in:
Chuck Jazdzewski
2017-02-14 13:33:06 -08:00
committed by Igor Minar
parent e4e9dbe33d
commit 8b81bb1eb6
14 changed files with 378 additions and 343 deletions

View File

@ -18,6 +18,7 @@ const NODE_MODULES = '/node_modules/';
const IS_GENERATED = /\.(ngfactory|ngstyle)$/;
const GENERATED_FILES = /\.ngfactory\.ts$|\.ngstyle\.ts$/;
const GENERATED_OR_DTS_FILES = /\.d\.ts$|\.ngfactory\.ts$|\.ngstyle\.ts$/;
const SHALLOW_IMPORT = /^(\w+|(\@\w+\/\w+))$/;
export interface CompilerHostContext extends ts.ModuleResolutionHost {
readResource(fileName: string): Promise<string>;
@ -133,6 +134,9 @@ export class CompilerHost implements AotCompilerHost {
// assume that they are on top of each other.
importedFile = importedFile.replace(this.basePath, this.genDir);
}
if (SHALLOW_IMPORT.test(importedFile)) {
return importedFile;
}
return this.dotRelative(containingDir, importedFile);
}
}