Skip to content

Commit 0eb25be

Browse files
filipesilvahansl
authored andcommitted
fix(@angular/cli): fix broken vendor chunk default
Followup to #8077 Fix #8169
1 parent 1a04b0f commit 0eb25be

File tree

5 files changed

+13
-19
lines changed

5 files changed

+13
-19
lines changed

packages/@angular/cli/commands/build.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,6 @@ const BuildCommand = Command.extend({
215215
Version.assertAngularVersionIs2_3_1OrHigher(this.project.root);
216216
Version.assertTypescriptVersion(this.project.root);
217217

218-
// Default vendor chunk to false when build optimizer is on.
219-
if (commandOptions.vendorChunk === undefined) {
220-
commandOptions.vendorChunk = !commandOptions.buildOptimizer;
221-
}
222-
223218
// Force commonjs module format for TS on dev watch builds.
224219
if (commandOptions.target === 'development' && commandOptions.watch === true) {
225220
commandOptions.forceTsCommonjs = true;

packages/@angular/cli/commands/eject.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ const EjectCommand = Command.extend({
3333

3434
run: function (commandOptions: EjectTaskOptions) {
3535

36-
// Default vendor chunk to false when build optimizer is on.
37-
if (commandOptions.vendorChunk === undefined) {
38-
commandOptions.vendorChunk = !commandOptions.buildOptimizer;
39-
}
40-
4136
const EjectTask = require('../tasks/eject').default;
4237
const ejectTask = new EjectTask({
4338
project: this.project,

packages/@angular/cli/commands/serve.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,6 @@ const ServeCommand = Command.extend({
130130
Version.assertAngularVersionIs2_3_1OrHigher(this.project.root);
131131
Version.assertTypescriptVersion(this.project.root);
132132

133-
// Default vendor chunk to false when build optimizer is on.
134-
if (commandOptions.vendorChunk === undefined) {
135-
commandOptions.vendorChunk = !commandOptions.buildOptimizer;
136-
}
137-
138133
// Force commonjs module format for TS on dev builds.
139134
if (commandOptions.target === 'development') {
140135
commandOptions.forceTsCommonjs = true;

packages/@angular/cli/models/webpack-config.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,23 @@ export class NgCliWebpackConfig<T extends BuildOptions = BuildOptions> {
108108
}
109109
};
110110

111-
const merged = Object.assign({}, targetDefaults[buildOptions.target], buildOptions);
111+
let merged = Object.assign({}, targetDefaults[buildOptions.target], buildOptions);
112112

113113
// Use Build Optimizer on prod AOT builds by default when AngularCompilerPlugin is supported.
114-
const buildOptimizer = {
114+
const buildOptimizerDefault = {
115115
buildOptimizer: merged.aot && AngularCompilerPlugin.isSupported()
116116
};
117117

118-
return Object.assign({}, buildOptimizer, merged);
118+
merged = Object.assign({}, buildOptimizerDefault, merged);
119+
120+
// Default vendor chunk to false when build optimizer is on.
121+
const vendorChunkDefault = {
122+
vendorChunk: !merged.buildOptimizer
123+
};
124+
125+
merged = Object.assign({}, vendorChunkDefault, merged);
126+
127+
return merged;
119128
}
120129

121130
// Fill in defaults from .angular-cli.json

tests/e2e/tests/build/script-target.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default function () {
99
const compilerOptions = configJson['compilerOptions'];
1010
compilerOptions['target'] = 'es2015';
1111
}))
12-
.then(() => ng('build', '--prod', '--output-hashing=none'))
12+
.then(() => ng('build', '--prod', '--output-hashing=none', '--vendor-chunk'))
1313
// Check class constructors are present in the vendor output.
1414
.then(() => expectFileToMatch('dist/vendor.bundle.js', /class \w{constructor\(\){/));
1515
}

0 commit comments

Comments
 (0)