Skip to content

fix(@angular/cli): fix broken vendor chunk default #8172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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\(\){/));
}