perf(compiler): don’t emit summaries for jit by default

This re-adds the flag `enableSummariesForJit` to the compiler options
that already existed in Angular 4.
This commit is contained in:
Tobias Bosch
2017-09-29 14:55:44 -07:00
committed by Alex Rickabaugh
parent 0038712474
commit b0868915ae
9 changed files with 76 additions and 36 deletions

View File

@ -3,7 +3,8 @@
// For TypeScript 1.8, we have to lay out generated files
// in the same source directory with your code.
"genDir": ".",
"debug": true
"debug": true,
"enableSummariesForJit": true
},
"compilerOptions": {

View File

@ -144,6 +144,12 @@ export interface CompilerOptions extends ts.CompilerOptions {
/** generate all possible generated files */
allowEmptyCodegenFiles?: boolean;
/**
* Whether to generate .ngsummary.ts files that allow to use AOTed artifacts
* in JIT mode. This is off by default.
*/
enableSummariesForJit?: boolean;
}
export interface CompilerHost extends ts.CompilerHost {

View File

@ -533,7 +533,7 @@ function getAotCompilerOptions(options: CompilerOptions): AotCompilerOptions {
locale: options.i18nInLocale,
i18nFormat: options.i18nInFormat || options.i18nOutFormat, translations, missingTranslation,
enableLegacyTemplate: options.enableLegacyTemplate,
enableSummariesForJit: true,
enableSummariesForJit: options.enableSummariesForJit,
preserveWhitespaces: options.preserveWhitespaces,
fullTemplateTypeCheck: options.fullTemplateTypeCheck,
allowEmptyCodegenFiles: options.allowEmptyCodegenFiles,

View File

@ -336,18 +336,21 @@ describe('ngc transformer command-line', () => {
});
}
function expectAllGeneratedFilesToExist() {
function expectAllGeneratedFilesToExist(enableSummariesForJit = true) {
modules.forEach(moduleName => {
if (/module|comp/.test(moduleName)) {
shouldExist(moduleName + '.ngfactory.js');
shouldExist(moduleName + '.ngfactory.d.ts');
shouldExist(moduleName + '.ngsummary.js');
shouldExist(moduleName + '.ngsummary.d.ts');
} else {
shouldNotExist(moduleName + '.ngfactory.js');
shouldNotExist(moduleName + '.ngfactory.d.ts');
}
if (enableSummariesForJit) {
shouldExist(moduleName + '.ngsummary.js');
shouldExist(moduleName + '.ngsummary.d.ts');
} else {
shouldNotExist(moduleName + '.ngsummary.js');
shouldNotExist(moduleName + '.ngsummary.d.ts');
}
shouldExist(moduleName + '.ngsummary.json');
shouldNotExist(moduleName + '.ngfactory.metadata.json');
@ -359,10 +362,11 @@ describe('ngc transformer command-line', () => {
shouldExist('emulated.css.shim.ngstyle.d.ts');
}
it('should emit generated files from sources', () => {
it('should emit generated files from sources with summariesForJit', () => {
writeConfig(`{
"extends": "./tsconfig-base.json",
"angularCompilerOptions": {
"enableSummariesForJit": true
},
"include": ["src/**/*.ts"]
}`);
@ -370,7 +374,22 @@ describe('ngc transformer command-line', () => {
expect(exitCode).toEqual(0);
outDir = path.resolve(basePath, 'built', 'src');
expectJsDtsMetadataJsonToExist();
expectAllGeneratedFilesToExist();
expectAllGeneratedFilesToExist(true);
});
it('should not emit generated files from sources without summariesForJit', () => {
writeConfig(`{
"extends": "./tsconfig-base.json",
"angularCompilerOptions": {
"enableSummariesForJit": false
},
"include": ["src/**/*.ts"]
}`);
const exitCode = main(['-p', path.join(basePath, 'tsconfig.json')], errorSpy);
expect(exitCode).toEqual(0);
outDir = path.resolve(basePath, 'built', 'src');
expectJsDtsMetadataJsonToExist();
expectAllGeneratedFilesToExist(false);
});
it('should emit generated files from libraries', () => {
@ -408,7 +427,8 @@ describe('ngc transformer command-line', () => {
writeConfig(`{
"extends": "./tsconfig-base.json",
"angularCompilerOptions": {
"skipTemplateCodegen": false
"skipTemplateCodegen": false,
"enableSummariesForJit": true
},
"compilerOptions": {
"outDir": "built"
@ -880,7 +900,8 @@ describe('ngc transformer command-line', () => {
write('tsconfig-ng.json', `{
"extends": "./tsconfig-base.json",
"angularCompilerOptions": {
"generateCodeForLibraries": true
"generateCodeForLibraries": true,
"enableSummariesForJit": true
},
"compilerOptions": {
"outDir": "."
@ -896,7 +917,8 @@ describe('ngc transformer command-line', () => {
write('lib1/tsconfig-lib1.json', `{
"extends": "../tsconfig-base.json",
"angularCompilerOptions": {
"generateCodeForLibraries": false
"generateCodeForLibraries": false,
"enableSummariesForJit": true
},
"compilerOptions": {
"rootDir": ".",
@ -919,7 +941,8 @@ describe('ngc transformer command-line', () => {
write('lib2/tsconfig-lib2.json', `{
"extends": "../tsconfig-base.json",
"angularCompilerOptions": {
"generateCodeForLibraries": false
"generateCodeForLibraries": false,
"enableSummariesForJit": true
},
"compilerOptions": {
"rootDir": ".",
@ -941,7 +964,8 @@ describe('ngc transformer command-line', () => {
write('app/tsconfig-app.json', `{
"extends": "../tsconfig-base.json",
"angularCompilerOptions": {
"generateCodeForLibraries": false
"generateCodeForLibraries": false,
"enableSummariesForJit": true
},
"compilerOptions": {
"rootDir": ".",

View File

@ -300,7 +300,10 @@ describe('ng program', () => {
export * from './main';
`,
});
const options = testSupport.createCompilerOptions({allowEmptyCodegenFiles: true});
const options = testSupport.createCompilerOptions({
allowEmptyCodegenFiles: true,
enableSummariesForJit: true,
});
const host = ng.createCompilerHost({options});
const written = new Map < string, {
original: ts.SourceFile[]|undefined;
@ -384,11 +387,11 @@ describe('ng program', () => {
testSupport.shouldExist('built/main.ngfactory.js');
testSupport.shouldExist('built/main.ngfactory.d.ts');
testSupport.shouldExist('built/main.ngsummary.json');
testSupport.shouldNotExist('build/node_modules/lib/index.js');
testSupport.shouldNotExist('build/node_modules/lib/index.d.ts');
testSupport.shouldNotExist('build/node_modules/lib/index.ngfactory.js');
testSupport.shouldNotExist('build/node_modules/lib/index.ngfactory.d.ts');
testSupport.shouldNotExist('build/node_modules/lib/index.ngsummary.json');
testSupport.shouldNotExist('built/node_modules/lib/index.js');
testSupport.shouldNotExist('built/node_modules/lib/index.d.ts');
testSupport.shouldNotExist('built/node_modules/lib/index.ngfactory.js');
testSupport.shouldNotExist('built/node_modules/lib/index.ngfactory.d.ts');
testSupport.shouldNotExist('built/node_modules/lib/index.ngsummary.json');
});
describe('createSrcToOutPathMapper', () => {