Skip to content

Commit 5f13d06

Browse files
Alan Agiusalexeagle
Alan Agius
authored andcommitted
fix(@angular-devkit/build-angular): ignore bundle budgets when running karma or devserver
Fixes #14100
1 parent bd16cbc commit 5f13d06

File tree

4 files changed

+42
-4
lines changed

4 files changed

+42
-4
lines changed

packages/angular_devkit/build_angular/src/dev-server/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ export function serveWebpackBrowser(
106106
[key]: options[key],
107107
}), {});
108108

109+
// In dev server we should not have budgets because of extra libs such as socks-js
110+
overrides.budgets = undefined;
111+
109112
const browserName = await context.getBuilderNameForTarget(browserTarget);
110113
const browserOptions = await context.validateOptions<json.JsonObject & BrowserBuilderSchema>(
111114
{ ...rawBrowserOptions, ...overrides },

packages/angular_devkit/build_angular/src/karma/index.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,10 @@ async function initialize(
3636
// tslint:disable-next-line:no-implicit-dependencies
3737
): Promise<[typeof import ('karma'), webpack.Configuration]> {
3838
const { config } = await generateBrowserWebpackConfigFromContext(
39-
// only one property is missing:
40-
// * `index` which is not used for tests
41-
{ ...options as unknown as BrowserBuilderOptions, outputPath: '' },
39+
// only two properties are missing:
40+
// * `outputPath` which is fixed for tests
41+
// * `budgets` which might be incorrect due to extra dev libs
42+
{ ...options as unknown as BrowserBuilderOptions, outputPath: '', budgets: undefined },
4243
context,
4344
wco => [
4445
getCommonConfig(wco),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* @license
3+
* Copyright Google Inc. All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
import { normalize, virtualFs } from '@angular-devkit/core';
9+
import { createArchitect, host } from '../utils';
10+
11+
describe('Dev Server Builder bundle budgets', () => {
12+
const targetSpec = { project: 'app', target: 'serve' };
13+
14+
beforeEach(async () => host.initialize().toPromise());
15+
afterEach(async () => host.restore().toPromise());
16+
17+
it('should ignore budgets', async () => {
18+
const config = host.scopedSync().read(normalize('angular.json'));
19+
const jsonConfig = JSON.parse(virtualFs.fileBufferToString(config));
20+
const buildOptions = jsonConfig.projects.app.targets.build.options;
21+
22+
buildOptions.budgets = [{ type: 'all', maximumError: '100b' }],
23+
buildOptions.optimization = true;
24+
25+
host.writeMultipleFiles({
26+
'angular.json': JSON.stringify(jsonConfig),
27+
});
28+
29+
const architect = (await createArchitect(host.root())).architect;
30+
const run = await architect.scheduleTarget(targetSpec);
31+
const output = await run.result;
32+
expect(output.success).toBe(true);
33+
await run.stop();
34+
});
35+
});

packages/angular_devkit/build_angular/test/dev-server/proxy_spec_large.ts

-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ describe('Dev Server Builder proxy', () => {
6363
}, 30000);
6464

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

0 commit comments

Comments
 (0)