@ -34,7 +34,7 @@ import {StaticReflector} from './static_reflector';
|
||||
import {StaticSymbol} from './static_symbol';
|
||||
import {ResolvedStaticSymbol, StaticSymbolResolver} from './static_symbol_resolver';
|
||||
import {createForJitStub, serializeSummaries} from './summary_serializer';
|
||||
import {ngfactoryFilePath, splitTypescriptSuffix, summaryFileName, summaryForJitFileName, summaryForJitName} from './util';
|
||||
import {ngfactoryFilePath, normalizeGenFileSuffix, splitTypescriptSuffix, summaryFileName, summaryForJitFileName, summaryForJitName} from './util';
|
||||
|
||||
enum StubEmitFlags {
|
||||
Basic = 1 << 0,
|
||||
@ -103,7 +103,7 @@ export class AotCompiler {
|
||||
genFileNames.push(summaryForJitFileName(file.fileName, true));
|
||||
}
|
||||
}
|
||||
const fileSuffix = splitTypescriptSuffix(file.fileName, true)[1];
|
||||
const fileSuffix = normalizeGenFileSuffix(splitTypescriptSuffix(file.fileName, true)[1]);
|
||||
file.directives.forEach((dirSymbol) => {
|
||||
const compMeta =
|
||||
this._metadataResolver.getNonNormalizedDirectiveMetadata(dirSymbol) !.metadata;
|
||||
@ -317,7 +317,7 @@ export class AotCompiler {
|
||||
srcFileUrl: string, ngModuleByPipeOrDirective: Map<StaticSymbol, CompileNgModuleMetadata>,
|
||||
directives: StaticSymbol[], pipes: StaticSymbol[], ngModules: CompileNgModuleMetadata[],
|
||||
injectables: StaticSymbol[]): GeneratedFile[] {
|
||||
const fileSuffix = splitTypescriptSuffix(srcFileUrl, true)[1];
|
||||
const fileSuffix = normalizeGenFileSuffix(splitTypescriptSuffix(srcFileUrl, true)[1]);
|
||||
const generatedFiles: GeneratedFile[] = [];
|
||||
|
||||
const outputCtx = this._createOutputContext(ngfactoryFilePath(srcFileUrl, true));
|
||||
|
@ -13,7 +13,7 @@ const JIT_SUMMARY_NAME = /NgSummary$/;
|
||||
|
||||
export function ngfactoryFilePath(filePath: string, forceSourceFile = false): string {
|
||||
const urlWithSuffix = splitTypescriptSuffix(filePath, forceSourceFile);
|
||||
return `${urlWithSuffix[0]}.ngfactory${urlWithSuffix[1]}`;
|
||||
return `${urlWithSuffix[0]}.ngfactory${normalizeGenFileSuffix(urlWithSuffix[1])}`;
|
||||
}
|
||||
|
||||
export function stripGeneratedFileSuffix(filePath: string): string {
|
||||
@ -38,6 +38,10 @@ export function splitTypescriptSuffix(path: string, forceSourceFile = false): st
|
||||
return [path, ''];
|
||||
}
|
||||
|
||||
export function normalizeGenFileSuffix(srcFileSuffix: string): string {
|
||||
return srcFileSuffix === '.tsx' ? '.ts' : srcFileSuffix;
|
||||
}
|
||||
|
||||
export function summaryFileName(fileName: string): string {
|
||||
const fileNameWithoutSuffix = fileName.replace(STRIP_SRC_FILE_SUFFIXES, '');
|
||||
return `${fileNameWithoutSuffix}.ngsummary.json`;
|
||||
|
@ -905,6 +905,14 @@ describe('compiler (bundled Angular)', () => {
|
||||
expect(genFiles.find(f => /app\.component\.ngfactory\.ts/.test(f.genFileUrl))).toBeDefined();
|
||||
expect(genFiles.find(f => /app\.module\.ngfactory\.ts/.test(f.genFileUrl))).toBeDefined();
|
||||
});
|
||||
|
||||
it('should support tsx', () => {
|
||||
const tsOptions = {jsx: ts.JsxEmit.React};
|
||||
const {genFiles} =
|
||||
compile([QUICKSTART_TSX, angularFiles], /* options */ undefined, tsOptions);
|
||||
expect(genFiles.find(f => /app\.component\.ngfactory\.ts/.test(f.genFileUrl))).toBeDefined();
|
||||
expect(genFiles.find(f => /app\.module\.ngfactory\.ts/.test(f.genFileUrl))).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Bundled library', () => {
|
||||
@ -978,6 +986,34 @@ const QUICKSTART: MockDirectory = {
|
||||
}
|
||||
};
|
||||
|
||||
const QUICKSTART_TSX: MockDirectory = {
|
||||
quickstart: {
|
||||
app: {
|
||||
// #20555
|
||||
'app.component.tsx': `
|
||||
import {Component} from '@angular/core';
|
||||
|
||||
@Component({
|
||||
template: '<h1>Hello {{name}}</h1>'
|
||||
})
|
||||
export class AppComponent {
|
||||
name = 'Angular';
|
||||
}
|
||||
`,
|
||||
'app.module.ts': `
|
||||
import { NgModule } from '@angular/core';
|
||||
import { AppComponent } from './app.component';
|
||||
|
||||
@NgModule({
|
||||
declarations: [ AppComponent ],
|
||||
bootstrap: [ AppComponent ]
|
||||
})
|
||||
export class AppModule { }
|
||||
`
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const LIBRARY: MockDirectory = {
|
||||
bolder: {
|
||||
'public-api.ts': `
|
||||
|
Reference in New Issue
Block a user