Skip to content

Commit 93bddf7

Browse files
committed
fix(@angular-devkit/build-angular): keep licenses if extraction is disabled
1 parent 99c174c commit 93bddf7

3 files changed

Lines changed: 19 additions & 10 deletions

File tree

packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/common.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,8 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
380380
safari10: true,
381381
output: {
382382
ecma: terserEcma,
383-
comments: false,
383+
// default behavior (undefined value) is to keep only important comments (licenses, etc.)
384+
comments: !buildOptions.extractLicenses && undefined,
384385
webkit: true,
385386
},
386387
// On server, we don't want to compress anything. We still set the ngDevMode = false for it

packages/angular_devkit/build_angular/test/browser/bundle-budgets_spec_large.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ describe('Browser Builder bundle budgets', () => {
130130
it(`when 'bundle' budget`, async () => {
131131
const overrides = {
132132
optimization: true,
133+
extractLicenses: true,
133134
budgets: [{ type: 'bundle', name: 'main', maximumError: '3Kb' }],
134135
};
135136

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
1-
import {join} from 'path';
2-
import {expectFileToExist} from '../../utils/fs';
3-
import {expectToFail} from '../../utils/utils';
4-
import {ng} from '../../utils/process';
1+
import { expectFileToExist, expectFileToMatch } from '../../utils/fs';
2+
import { ng } from '../../utils/process';
3+
import { expectToFail } from '../../utils/utils';
54

6-
export default function() {
7-
// TODO(architect): Delete this test. It is now in devkit/build-angular.
5+
export default async function() {
6+
// Licenses should be left intact if extraction is disabled
7+
await ng('build', '--prod', '--extract-licenses=false', '--output-hashing=none');
88

9-
return ng('build', '--prod', '--extract-licenses=false')
10-
.then(() => expectFileToExist(join(process.cwd(), 'dist')))
11-
.then(() => expectToFail(() => expectFileToExist('dist/test-project/3rdpartylicenses.txt')));
9+
await expectToFail(() => expectFileToExist('dist/test-project/3rdpartylicenses.txt'));
10+
await expectFileToMatch('dist/test-project/main-es2015.js', '@license');
11+
await expectFileToMatch('dist/test-project/main-es5.js', '@license');
12+
13+
// Licenses should be removed if extraction is enabled
14+
await ng('build', '--prod', '--extract-licenses', '--output-hashing=none');
15+
16+
await expectFileToExist('dist/test-project/3rdpartylicenses.txt');
17+
await expectToFail(() => expectFileToMatch('dist/test-project/main-es2015.js', '@license'));
18+
await expectToFail(() => expectFileToMatch('dist/test-project/main-es5.js', '@license'));
1219
}

0 commit comments

Comments
 (0)