Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): configure webpack target in commo…
Browse files Browse the repository at this point in the history
…n configuration

Previously, `target` was unset for `test` which caused the target to be set incorrectly.

Closes #21239

(cherry picked from commit 070a133)
  • Loading branch information
alan-agius4 committed Jun 30, 2021
1 parent dd60228 commit 2039d62
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
Expand Up @@ -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',
Expand Down
Expand Up @@ -40,7 +40,6 @@ import {
maxWorkers,
persistentBuildCacheEnabled,
profilingEnabled,
shouldBeautify,
} from '../../utils/environment-options';
import { findAllNodeModules } from '../../utils/find-up';
import { Spinner } from '../../utils/spinner';
Expand Down Expand Up @@ -395,12 +394,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,
Expand Down
Expand Up @@ -35,7 +35,6 @@ export function getServerConfig(wco: WebpackConfigOptions): Configuration {
resolve: {
mainFields: ['es2015', 'main', 'module'],
},
target: 'node',
output: {
libraryTarget: 'commonjs',
},
Expand Down

0 comments on commit 2039d62

Please sign in to comment.