From e022cce08eb9b84399aae899b5c05a12e0eae739 Mon Sep 17 00:00:00 2001 From: y-kurami Date: Wed, 11 Oct 2017 21:55:33 +0900 Subject: [PATCH] feat(@angular/cli): support test using ngSummaries --- packages/@angular/cli/commands/test.ts | 5 +++++ packages/@angular/cli/models/webpack-configs/typescript.ts | 6 ++++-- packages/@angular/cli/plugins/karma.ts | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/@angular/cli/commands/test.ts b/packages/@angular/cli/commands/test.ts index a585b20b7dd6..f06cd6b1a37a 100644 --- a/packages/@angular/cli/commands/test.ts +++ b/packages/@angular/cli/commands/test.ts @@ -54,6 +54,11 @@ const TestCommand = Command.extend({ description: oneLine`Use a specific config file. Defaults to the karma config file in .angular-cli.json.` }, + { + name: 'aot', + type: Boolean, + description: 'Build using Ahead of Time compilation.' + }, { name: 'single-run', type: Boolean, diff --git a/packages/@angular/cli/models/webpack-configs/typescript.ts b/packages/@angular/cli/models/webpack-configs/typescript.ts index 51278a38b1d7..8de1b29e9948 100644 --- a/packages/@angular/cli/models/webpack-configs/typescript.ts +++ b/packages/@angular/cli/models/webpack-configs/typescript.ts @@ -146,7 +146,8 @@ export function getAotConfig(wco: WebpackConfigOptions) { } export function getNonAotTestConfig(wco: WebpackConfigOptions) { - const { projectRoot, appConfig } = wco; + const { projectRoot, appConfig, buildOptions } = wco; + const { aot } = buildOptions; const tsConfigPath = path.resolve(projectRoot, appConfig.root, appConfig.testTsconfig); const appTsConfigPath = path.resolve(projectRoot, appConfig.root, appConfig.tsconfig); @@ -155,7 +156,8 @@ export function getNonAotTestConfig(wco: WebpackConfigOptions) { // since TS compilation there is stricter and tsconfig.spec.ts doesn't include them. const include = [appConfig.main, appConfig.polyfills]; - let pluginOptions: any = { tsConfigPath, skipCodeGeneration: true, include }; + let pluginOptions: any = { tsConfigPath, skipCodeGeneration: !aot, + enableSummariesForJit: aot, include }; // Fallback to correct module format on projects using a shared tsconfig. if (tsConfigPath === appTsConfigPath) { diff --git a/packages/@angular/cli/plugins/karma.ts b/packages/@angular/cli/plugins/karma.ts index ad893a5fadb5..cf1d2f747f05 100644 --- a/packages/@angular/cli/plugins/karma.ts +++ b/packages/@angular/cli/plugins/karma.ts @@ -55,6 +55,7 @@ const init: any = (config: any, emitter: any, customFileHandlers: any) => { sourcemaps: true, progress: true, preserveSymlinks: false, + aot: config.aot, }, config.angularCli); if (testConfig.sourcemaps) {