Skip to content

Commit 9f57010

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

File tree

2 files changed

+18
-10
lines changed
  • packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs
  • tests/legacy-cli/e2e/tests/build

2 files changed

+18
-10
lines changed

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
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)