fix(compiler-cli): Use typescript to resolve modules for metadata (#22856)

The current module resolution simply attaches .ts to the import/export path, which does
not work if the path is using Node / CommonJS behavior to resolve to an index.ts file.
This patch uses typescript's module resolution logic, and will attempt to load the original
typescript file if this resolution returns a .js or .d.ts file

PR Close #22856
This commit is contained in:
Jeff Burn
2018-07-07 10:02:08 +10:00
committed by Miško Hevery
parent 98b18cd49f
commit 7717ff187a
5 changed files with 245 additions and 24 deletions

View File

@ -19,7 +19,9 @@ export class MockAotContext {
fileExists(fileName: string): boolean { return typeof this.getEntry(fileName) === 'string'; }
directoryExists(path: string): boolean { return typeof this.getEntry(path) === 'object'; }
directoryExists(path: string): boolean {
return path === this.currentDirectory || typeof this.getEntry(path) === 'object';
}
readFile(fileName: string): string {
const data = this.getEntry(fileName);