Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): keep licenses if extraction is di…
Browse files Browse the repository at this point in the history
…sabled
  • Loading branch information
clydin authored and vikerman committed Oct 25, 2019
1 parent ef77ce3 commit dd4bc23
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
Expand Up @@ -380,7 +380,8 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
safari10: true,
output: {
ecma: terserEcma,
comments: false,
// default behavior (undefined value) is to keep only important comments (licenses, etc.)
comments: !buildOptions.extractLicenses && undefined,
webkit: true,
},
// On server, we don't want to compress anything. We still set the ngDevMode = false for it
Expand Down
Expand Up @@ -130,6 +130,7 @@ describe('Browser Builder bundle budgets', () => {
it(`when 'bundle' budget`, async () => {
const overrides = {
optimization: true,
extractLicenses: true,
budgets: [{ type: 'bundle', name: 'main', maximumError: '3Kb' }],
};

Expand Down
25 changes: 16 additions & 9 deletions tests/legacy-cli/e2e/tests/build/extract-licenses.ts
@@ -1,12 +1,19 @@
import {join} from 'path';
import {expectFileToExist} from '../../utils/fs';
import {expectToFail} from '../../utils/utils';
import {ng} from '../../utils/process';
import { expectFileToExist, expectFileToMatch } from '../../utils/fs';
import { ng } from '../../utils/process';
import { expectToFail } from '../../utils/utils';

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

return ng('build', '--prod', '--extract-licenses=false')
.then(() => expectFileToExist(join(process.cwd(), 'dist')))
.then(() => expectToFail(() => expectFileToExist('dist/test-project/3rdpartylicenses.txt')));
await expectToFail(() => expectFileToExist('dist/test-project/3rdpartylicenses.txt'));
await expectFileToMatch('dist/test-project/main-es2015.js', '@license');
await expectFileToMatch('dist/test-project/main-es5.js', '@license');

// Licenses should be removed if extraction is enabled
await ng('build', '--prod', '--extract-licenses', '--output-hashing=none');

await expectFileToExist('dist/test-project/3rdpartylicenses.txt');
await expectToFail(() => expectFileToMatch('dist/test-project/main-es2015.js', '@license'));
await expectToFail(() => expectFileToMatch('dist/test-project/main-es5.js', '@license'));
}

0 comments on commit dd4bc23

Please sign in to comment.