Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): ignore bundle budgets when runnin…
Browse files Browse the repository at this point in the history
…g karma or devserver

Fixes #14100
  • Loading branch information
Alan Agius authored and alexeagle committed Apr 12, 2019
1 parent bd16cbc commit 5f13d06
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 4 deletions.
3 changes: 3 additions & 0 deletions packages/angular_devkit/build_angular/src/dev-server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ export function serveWebpackBrowser(
[key]: options[key],
}), {});

// In dev server we should not have budgets because of extra libs such as socks-js
overrides.budgets = undefined;

const browserName = await context.getBuilderNameForTarget(browserTarget);
const browserOptions = await context.validateOptions<json.JsonObject & BrowserBuilderSchema>(
{ ...rawBrowserOptions, ...overrides },
Expand Down
7 changes: 4 additions & 3 deletions packages/angular_devkit/build_angular/src/karma/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ async function initialize(
// tslint:disable-next-line:no-implicit-dependencies
): Promise<[typeof import ('karma'), webpack.Configuration]> {
const { config } = await generateBrowserWebpackConfigFromContext(
// only one property is missing:
// * `index` which is not used for tests
{ ...options as unknown as BrowserBuilderOptions, outputPath: '' },
// only two properties are missing:
// * `outputPath` which is fixed for tests
// * `budgets` which might be incorrect due to extra dev libs
{ ...options as unknown as BrowserBuilderOptions, outputPath: '', budgets: undefined },
context,
wco => [
getCommonConfig(wco),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import { normalize, virtualFs } from '@angular-devkit/core';
import { createArchitect, host } from '../utils';

describe('Dev Server Builder bundle budgets', () => {
const targetSpec = { project: 'app', target: 'serve' };

beforeEach(async () => host.initialize().toPromise());
afterEach(async () => host.restore().toPromise());

it('should ignore budgets', async () => {
const config = host.scopedSync().read(normalize('angular.json'));
const jsonConfig = JSON.parse(virtualFs.fileBufferToString(config));
const buildOptions = jsonConfig.projects.app.targets.build.options;

buildOptions.budgets = [{ type: 'all', maximumError: '100b' }],
buildOptions.optimization = true;

host.writeMultipleFiles({
'angular.json': JSON.stringify(jsonConfig),
});

const architect = (await createArchitect(host.root())).architect;
const run = await architect.scheduleTarget(targetSpec);
const output = await run.result;
expect(output.success).toBe(true);
await run.stop();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ describe('Dev Server Builder proxy', () => {
}, 30000);

it('errors out with a missing proxy file', async () => {
const overrides: Partial<DevServerBuilderOptions> = { proxyConfig: '../proxy.config.json' };
const run = await architect.scheduleTarget(target, { proxyConfig: 'INVALID.json' });
runs.push(run);

Expand Down

0 comments on commit 5f13d06

Please sign in to comment.