From 303b2c035ade57019f567c4b5ec51c7d5268ebac Mon Sep 17 00:00:00 2001 From: Filipe Silva Date: Sat, 18 Mar 2017 23:30:01 +0000 Subject: [PATCH] fix(@angular/cli): fix test typings Blocked by #5500 (fix is included in this PR so that CI will run). Our unit test webpack config was erroneously sending in entry points to karma-webpack, who should receive no entry points. This in turn was hiding errors related to typeRoots lookups. It was also causing unit tests compilation to behave weirdly: unit test errors would not stop compilation, because other entries would still compile. This might also have contributed to the overall slowness of unit tests in #5423. Related to TypeStrong/ts-node#283 Fix #3911 Fix #5332 Fix #5351 --- .../cli/blueprints/ng/files/__path__/tsconfig.spec.json | 6 ++++-- packages/@angular/cli/models/webpack-test-config.ts | 1 + packages/@ngtools/webpack/src/extract_i18n_plugin.ts | 3 ++- packages/@ngtools/webpack/src/plugin.ts | 3 ++- tests/e2e/tests/build/aot/exclude.ts | 1 + 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/@angular/cli/blueprints/ng/files/__path__/tsconfig.spec.json b/packages/@angular/cli/blueprints/ng/files/__path__/tsconfig.spec.json index 5dc8eeb57474..0bba9ea2069c 100644 --- a/packages/@angular/cli/blueprints/ng/files/__path__/tsconfig.spec.json +++ b/packages/@angular/cli/blueprints/ng/files/__path__/tsconfig.spec.json @@ -8,7 +8,8 @@ "emitDecoratorMetadata": true, "experimentalDecorators": true, "lib": [ - "es2016" + "es2016", + "dom" ],<% } %> "outDir": "<%= relativeRootPath %>/out-tsc/spec", "module": "commonjs", @@ -23,6 +24,7 @@ "test.ts" ], "include": [ - "**/*.spec.ts" + "**/*.spec.ts", + "**/*.d.ts" ] } diff --git a/packages/@angular/cli/models/webpack-test-config.ts b/packages/@angular/cli/models/webpack-test-config.ts index d7d3e81b7dd1..a5b9049f62db 100644 --- a/packages/@angular/cli/models/webpack-test-config.ts +++ b/packages/@angular/cli/models/webpack-test-config.ts @@ -28,6 +28,7 @@ export class WebpackTestConfig extends NgCliWebpackConfig { ]; this.config = webpackMerge(webpackConfigs); + delete this.config.entry; // Remove any instance of CommonsChunkPlugin, not needed with karma-webpack. this.config.plugins = this.config.plugins.filter((plugin: any) => diff --git a/packages/@ngtools/webpack/src/extract_i18n_plugin.ts b/packages/@ngtools/webpack/src/extract_i18n_plugin.ts index 06168b9b3f24..be7ec112beb3 100644 --- a/packages/@ngtools/webpack/src/extract_i18n_plugin.ts +++ b/packages/@ngtools/webpack/src/extract_i18n_plugin.ts @@ -46,7 +46,8 @@ export class ExtractI18nPlugin implements Tapable { if (!options.hasOwnProperty('tsConfigPath')) { throw new Error('Must specify "tsConfigPath" in the configuration of @ngtools/webpack.'); } - this._tsConfigPath = options.tsConfigPath; + // TS represents paths internally with '/' and expects the tsconfig path to be in this format + this._tsConfigPath = options.tsConfigPath.replace(/\\/g, '/'); // Check the base path. const maybeBasePath = path.resolve(process.cwd(), this._tsConfigPath); diff --git a/packages/@ngtools/webpack/src/plugin.ts b/packages/@ngtools/webpack/src/plugin.ts index 2addb6a29018..055c675ccee3 100644 --- a/packages/@ngtools/webpack/src/plugin.ts +++ b/packages/@ngtools/webpack/src/plugin.ts @@ -96,7 +96,8 @@ export class AotPlugin implements Tapable { if (!options.hasOwnProperty('tsConfigPath')) { throw new Error('Must specify "tsConfigPath" in the configuration of @ngtools/webpack.'); } - this._tsConfigPath = options.tsConfigPath; + // TS represents paths internally with '/' and expects the tsconfig path to be in this format + this._tsConfigPath = options.tsConfigPath.replace(/\\/g, '/'); // Check the base path. const maybeBasePath = path.resolve(process.cwd(), this._tsConfigPath); diff --git a/tests/e2e/tests/build/aot/exclude.ts b/tests/e2e/tests/build/aot/exclude.ts index 6f1518e9302c..98904d0f9f22 100644 --- a/tests/e2e/tests/build/aot/exclude.ts +++ b/tests/e2e/tests/build/aot/exclude.ts @@ -23,6 +23,7 @@ export default function () { })) .then(() => updateJsonFile('src/tsconfig.json', tsconfigJson => { delete tsconfigJson['exclude']; + delete tsconfigJson['compilerOptions']['types']; })) .then(() => ng('build', '--aot')) .then(() => !ejected && ng('test', '--single-run'));