fix(compiler): make tsx file aot compatible

fixes #20555
This commit is contained in:
Trotyl
2017-11-29 15:27:16 +08:00
committed by Alex Rickabaugh
parent d91ff17adc
commit 05ff6c09ca
7 changed files with 80 additions and 8 deletions

View File

@ -326,7 +326,7 @@ export class TsCompilerAotCompilerTypeCheckHostAdapter implements ts.CompilerHos
return {generate: false};
}
const [, base, genSuffix, suffix] = genMatch;
if (suffix !== 'ts') {
if (suffix !== 'ts' && suffix !== 'tsx') {
return {generate: false};
}
let baseFileName: string|undefined;
@ -337,9 +337,9 @@ export class TsCompilerAotCompilerTypeCheckHostAdapter implements ts.CompilerHos
}
} else {
// Note: on-the-fly generated files always have a `.ts` suffix,
// but the file from which we generated it can be a `.ts`/ `.d.ts`
// but the file from which we generated it can be a `.ts`/ `.tsx`/ `.d.ts`
// (see options.generateCodeForLibraries).
baseFileName = [`${base}.ts`, `${base}.d.ts`].find(
baseFileName = [`${base}.ts`, `${base}.tsx`, `${base}.d.ts`].find(
baseFileName => this.isSourceFile(baseFileName) && this.originalFileExists(baseFileName));
if (!baseFileName) {
return {generate: false};

View File

@ -337,7 +337,7 @@ class AngularCompilerProgram implements Program {
metadataJsonCount++;
const metadata = this.metadataCache.getMetadata(sf);
const metadataText = JSON.stringify([metadata]);
const outFileName = srcToOutPath(sf.fileName.replace(/\.ts$/, '.metadata.json'));
const outFileName = srcToOutPath(sf.fileName.replace(/\.tsx?$/, '.metadata.json'));
this.writeFile(outFileName, metadataText, false, undefined, undefined, [sf]);
}
});