From 328e6ba9e5aaf6ec9da8050fa0aea67fded398b1 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Fri, 11 Jun 2021 15:10:15 +0200 Subject: [PATCH] fix(@angular-devkit/build-angular): explicitly set compilation target in test configuration When not set, and browserslist returns no reesults due to the file being empty or commented. Webpack will generate invalid code because it doesn't know which enviorment we want to target. ```diff - (self["webpackChunktest_app"] = self["webpackChunktest_app"] || []).push([["vendor"],{ /***/ 8583: ``` Closes #21111 --- .../angular_devkit/build_angular/src/webpack/configs/test.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/angular_devkit/build_angular/src/webpack/configs/test.ts b/packages/angular_devkit/build_angular/src/webpack/configs/test.ts index 09e7f4d654e7..87a207ddc3a8 100644 --- a/packages/angular_devkit/build_angular/src/webpack/configs/test.ts +++ b/packages/angular_devkit/build_angular/src/webpack/configs/test.ts @@ -8,6 +8,7 @@ import * as glob from 'glob'; import * as path from 'path'; +import { ScriptTarget } from 'typescript'; import * as webpack from 'webpack'; import { WebpackConfigOptions, WebpackTestOptions } from '../../utils/build-options'; import { getSourceMapDevTool, isPolyfillsEntry } from '../utils/helpers'; @@ -51,6 +52,7 @@ export function getTestConfig( return { mode: 'development', + target: wco.tsConfig.options.target === ScriptTarget.ES5 ? ['web', 'es5'] : 'web', resolve: { mainFields: ['es2015', 'browser', 'module', 'main'], },