Skip to content

Commit

Permalink
fix(@angular/cli): fix broken vendor chunk default
Browse files Browse the repository at this point in the history
Followup to #8077
Fix #8169
  • Loading branch information
filipesilva authored and hansl committed Oct 24, 2017
1 parent 1a04b0f commit 0eb25be
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 19 deletions.
5 changes: 0 additions & 5 deletions packages/@angular/cli/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,6 @@ const BuildCommand = Command.extend({
Version.assertAngularVersionIs2_3_1OrHigher(this.project.root);
Version.assertTypescriptVersion(this.project.root);

// Default vendor chunk to false when build optimizer is on.
if (commandOptions.vendorChunk === undefined) {
commandOptions.vendorChunk = !commandOptions.buildOptimizer;
}

// Force commonjs module format for TS on dev watch builds.
if (commandOptions.target === 'development' && commandOptions.watch === true) {
commandOptions.forceTsCommonjs = true;
Expand Down
5 changes: 0 additions & 5 deletions packages/@angular/cli/commands/eject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ const EjectCommand = Command.extend({

run: function (commandOptions: EjectTaskOptions) {

// Default vendor chunk to false when build optimizer is on.
if (commandOptions.vendorChunk === undefined) {
commandOptions.vendorChunk = !commandOptions.buildOptimizer;
}

const EjectTask = require('../tasks/eject').default;
const ejectTask = new EjectTask({
project: this.project,
Expand Down
5 changes: 0 additions & 5 deletions packages/@angular/cli/commands/serve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,6 @@ const ServeCommand = Command.extend({
Version.assertAngularVersionIs2_3_1OrHigher(this.project.root);
Version.assertTypescriptVersion(this.project.root);

// Default vendor chunk to false when build optimizer is on.
if (commandOptions.vendorChunk === undefined) {
commandOptions.vendorChunk = !commandOptions.buildOptimizer;
}

// Force commonjs module format for TS on dev builds.
if (commandOptions.target === 'development') {
commandOptions.forceTsCommonjs = true;
Expand Down
15 changes: 12 additions & 3 deletions packages/@angular/cli/models/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,23 @@ export class NgCliWebpackConfig<T extends BuildOptions = BuildOptions> {
}
};

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

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

return Object.assign({}, buildOptimizer, merged);
merged = Object.assign({}, buildOptimizerDefault, merged);

// Default vendor chunk to false when build optimizer is on.
const vendorChunkDefault = {
vendorChunk: !merged.buildOptimizer
};

merged = Object.assign({}, vendorChunkDefault, merged);

return merged;
}

// Fill in defaults from .angular-cli.json
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/tests/build/script-target.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function () {
const compilerOptions = configJson['compilerOptions'];
compilerOptions['target'] = 'es2015';
}))
.then(() => ng('build', '--prod', '--output-hashing=none'))
.then(() => ng('build', '--prod', '--output-hashing=none', '--vendor-chunk'))
// Check class constructors are present in the vendor output.
.then(() => expectFileToMatch('dist/vendor.bundle.js', /class \w{constructor\(\){/));
}

0 comments on commit 0eb25be

Please sign in to comment.