Skip to content

Commit 070a133

Browse files
committed
fix(@angular-devkit/build-angular): configure webpack target in common configuration
Previously, `target` was unset for `test` which caused the target to be set incorrectly. Closes #21239
1 parent 6a2b119 commit 070a133

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

packages/angular_devkit/build_angular/src/webpack/configs/browser.ts

-4
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,6 @@ export function getBrowserConfig(wco: WebpackConfigOptions): webpack.Configurati
8181
resolve: {
8282
mainFields: ['es2015', 'browser', 'module', 'main'],
8383
},
84-
target:
85-
wco.tsConfig.options.target === ScriptTarget.ES5 || buildBrowserFeatures.isEs5SupportNeeded()
86-
? ['web', 'es5']
87-
: 'web',
8884
output: {
8985
crossOriginLoading,
9086
trustedTypes: 'angular#bundler',

packages/angular_devkit/build_angular/src/webpack/configs/common.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ import {
4040
maxWorkers,
4141
persistentBuildCacheEnabled,
4242
profilingEnabled,
43-
shouldBeautify,
4443
} from '../../utils/environment-options';
4544
import { findAllNodeModules } from '../../utils/find-up';
4645
import { Spinner } from '../../utils/spinner';
@@ -358,12 +357,19 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
358357
return {
359358
mode: scriptsOptimization || stylesOptimization.minify ? 'production' : 'development',
360359
devtool: false,
360+
target: [
361+
platform === 'server' ? 'node' : 'web',
362+
tsConfig.options.target === ScriptTarget.ES5 ||
363+
(platform !== 'server' && buildBrowserFeatures.isEs5SupportNeeded())
364+
? 'es5'
365+
: 'es2015',
366+
],
361367
profile: buildOptions.statsJson,
362368
resolve: {
363369
roots: [projectRoot],
364370
extensions: ['.ts', '.tsx', '.mjs', '.js'],
365371
symlinks: !buildOptions.preserveSymlinks,
366-
modules: [wco.tsConfig.options.baseUrl || projectRoot, 'node_modules'],
372+
modules: [tsConfig.options.baseUrl || projectRoot, 'node_modules'],
367373
},
368374
resolveLoader: {
369375
symlinks: !buildOptions.preserveSymlinks,

packages/angular_devkit/build_angular/src/webpack/configs/server.ts

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ export function getServerConfig(wco: WebpackConfigOptions): Configuration {
3535
resolve: {
3636
mainFields: ['es2015', 'main', 'module'],
3737
},
38-
target: 'node',
3938
output: {
4039
libraryTarget: 'commonjs',
4140
},

0 commit comments

Comments
 (0)