diff --git a/packages/angular_devkit/build_angular/src/webpack/configs/browser.ts b/packages/angular_devkit/build_angular/src/webpack/configs/browser.ts index 97139d3c8cff..051bb46951f8 100644 --- a/packages/angular_devkit/build_angular/src/webpack/configs/browser.ts +++ b/packages/angular_devkit/build_angular/src/webpack/configs/browser.ts @@ -81,10 +81,6 @@ export function getBrowserConfig(wco: WebpackConfigOptions): webpack.Configurati resolve: { mainFields: ['es2015', 'browser', 'module', 'main'], }, - target: - wco.tsConfig.options.target === ScriptTarget.ES5 || buildBrowserFeatures.isEs5SupportNeeded() - ? ['web', 'es5'] - : 'web', output: { crossOriginLoading, trustedTypes: 'angular#bundler', diff --git a/packages/angular_devkit/build_angular/src/webpack/configs/common.ts b/packages/angular_devkit/build_angular/src/webpack/configs/common.ts index f435d1f8dd2b..94822f03ac6f 100644 --- a/packages/angular_devkit/build_angular/src/webpack/configs/common.ts +++ b/packages/angular_devkit/build_angular/src/webpack/configs/common.ts @@ -40,7 +40,6 @@ import { maxWorkers, persistentBuildCacheEnabled, profilingEnabled, - shouldBeautify, } from '../../utils/environment-options'; import { findAllNodeModules } from '../../utils/find-up'; import { Spinner } from '../../utils/spinner'; @@ -358,12 +357,19 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration { return { mode: scriptsOptimization || stylesOptimization.minify ? 'production' : 'development', devtool: false, + target: [ + platform === 'server' ? 'node' : 'web', + tsConfig.options.target === ScriptTarget.ES5 || + (platform !== 'server' && buildBrowserFeatures.isEs5SupportNeeded()) + ? 'es5' + : 'es2015', + ], profile: buildOptions.statsJson, resolve: { roots: [projectRoot], extensions: ['.ts', '.tsx', '.mjs', '.js'], symlinks: !buildOptions.preserveSymlinks, - modules: [wco.tsConfig.options.baseUrl || projectRoot, 'node_modules'], + modules: [tsConfig.options.baseUrl || projectRoot, 'node_modules'], }, resolveLoader: { symlinks: !buildOptions.preserveSymlinks, diff --git a/packages/angular_devkit/build_angular/src/webpack/configs/server.ts b/packages/angular_devkit/build_angular/src/webpack/configs/server.ts index 9e28d25131da..82241e555831 100644 --- a/packages/angular_devkit/build_angular/src/webpack/configs/server.ts +++ b/packages/angular_devkit/build_angular/src/webpack/configs/server.ts @@ -35,7 +35,6 @@ export function getServerConfig(wco: WebpackConfigOptions): Configuration { resolve: { mainFields: ['es2015', 'main', 'module'], }, - target: 'node', output: { libraryTarget: 'commonjs', },