Skip to content

Commit e549f72

Browse files
committed
fix(@angular/cli): fix test typings
Blocked by angular#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 angular#5423. Related to TypeStrong/ts-node#283 Fix angular#5332 Fix angular#5351
1 parent dbaa04f commit e549f72

File tree

5 files changed

+18
-12
lines changed

5 files changed

+18
-12
lines changed

packages/@angular/cli/blueprints/ng/files/__path__/tsconfig.spec.json

+10-8
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"experimentalDecorators": true,
1010
"lib": [
1111
"es2016"
12+
"dom"
1213
],<% } %>
1314
"outDir": "<%= relativeRootPath %>/out-tsc/spec",
1415
"module": "commonjs",
@@ -17,12 +18,13 @@
1718
"types": [
1819
"jasmine",
1920
"node"
20-
]
21-
},
22-
"files": [
23-
"test.ts"
24-
],
25-
"include": [
26-
"**/*.spec.ts"
27-
]
21+
],
22+
"files": [
23+
"test.ts"
24+
],
25+
"include": [
26+
"**/*.spec.ts",
27+
"**/*.d.ts"
28+
]
29+
}
2830
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/* SystemJS module definition */
2-
declare var module: {
2+
declare var module: NodeModule;
3+
interface NodeModule {
34
id: string;
4-
};
5+
}

packages/@angular/cli/models/webpack-test-config.ts

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export class WebpackTestConfig extends NgCliWebpackConfig {
2828
];
2929

3030
this.config = webpackMerge(webpackConfigs);
31+
delete this.config.entry;
3132

3233
// Remove any instance of CommonsChunkPlugin, not needed with karma-webpack.
3334
this.config.plugins = this.config.plugins.filter((plugin: any) =>

packages/@ngtools/webpack/src/extract_i18n_plugin.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ export class ExtractI18nPlugin implements Tapable {
4646
if (!options.hasOwnProperty('tsConfigPath')) {
4747
throw new Error('Must specify "tsConfigPath" in the configuration of @ngtools/webpack.');
4848
}
49-
this._tsConfigPath = options.tsConfigPath;
49+
// TS represents paths internally with '/' and expects the tsconfig path to be in this format
50+
this._tsConfigPath = options.tsConfigPath.replace(/\\/g, '/');
5051

5152
// Check the base path.
5253
const maybeBasePath = path.resolve(process.cwd(), this._tsConfigPath);

packages/@ngtools/webpack/src/plugin.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ export class AotPlugin implements Tapable {
9696
if (!options.hasOwnProperty('tsConfigPath')) {
9797
throw new Error('Must specify "tsConfigPath" in the configuration of @ngtools/webpack.');
9898
}
99-
this._tsConfigPath = options.tsConfigPath;
99+
// TS represents paths internally with '/' and expects the tsconfig path to be in this format
100+
this._tsConfigPath = options.tsConfigPath.replace(/\\/g, '/');
100101

101102
// Check the base path.
102103
const maybeBasePath = path.resolve(process.cwd(), this._tsConfigPath);

0 commit comments

Comments
 (0)