mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-20 13:32:43 +08:00
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
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import * as webpack from 'webpack';
|
|
const webpackMerge = require('webpack-merge');
|
|
|
|
import { BuildOptions } from './build-options';
|
|
import { NgCliWebpackConfig } from './webpack-config';
|
|
import {
|
|
getCommonConfig,
|
|
getStylesConfig,
|
|
getNonAotTestConfig,
|
|
getTestConfig
|
|
} from './webpack-configs';
|
|
|
|
export interface WebpackTestOptions extends BuildOptions {
|
|
codeCoverage?: boolean;
|
|
}
|
|
export class WebpackTestConfig extends NgCliWebpackConfig {
|
|
constructor(private testOptions: WebpackTestOptions, appConfig: any) {
|
|
super(testOptions, appConfig);
|
|
}
|
|
|
|
public buildConfig() {
|
|
let webpackConfigs = [
|
|
getCommonConfig(this.wco),
|
|
getStylesConfig(this.wco),
|
|
this.getTargetConfig(this.wco),
|
|
getNonAotTestConfig(this.wco),
|
|
getTestConfig(this.testOptions)
|
|
];
|
|
|
|
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) =>
|
|
!(plugin instanceof webpack.optimize.CommonsChunkPlugin));
|
|
|
|
return this.config;
|
|
}
|
|
}
|