Skip to content

Commit f2ecb90

Browse files
alan-agius4mgechev
authored andcommitted
fix(@angular-devkit/build-angular): serve option merging is being overridden by defaults in schema (#15328)
We have a number of browser options that we allow the dev-server to merge. However, this only happens when such as options are undefined from the dev-server builder. At the moment these option have defaults inside their schema which results in them never being `undefined`, and hence the overridden logic is bypassed. See: https://github.com/angular/angular-cli/blob/6dd5b186d4dc0ed750cc195d9ebe1aaa282bb640/packages/angular_devkit/build_angular/src/dev-server/index.ts#L49-L63 and https://github.com/angular/angular-cli/blob/6dd5b186d4dc0ed750cc195d9ebe1aaa282bb640/packages/angular_devkit/build_angular/src/dev-server/index.ts#L107-L115 Fixes #15273 and fixes #15064
1 parent ba7b4a1 commit f2ecb90

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const open = require('open');
4646

4747
export type DevServerBuilderOptions = Schema & json.JsonObject;
4848

49-
export const devServerBuildOverriddenKeys: (keyof DevServerBuilderOptions)[] = [
49+
const devServerBuildOverriddenKeys: (keyof DevServerBuilderOptions)[] = [
5050
'watch',
5151
'optimization',
5252
'aot',

packages/angular_devkit/build_angular/src/dev-server/schema.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@
4444
},
4545
"verbose": {
4646
"type": "boolean",
47-
"description": "Adds more details to output logging.",
48-
"default": false
47+
"description": "Adds more details to output logging."
4948
},
5049
"liveReload": {
5150
"type": "boolean",
@@ -117,7 +116,6 @@
117116
},
118117
"sourceMap": {
119118
"description": "Output sourcemaps.",
120-
"default": true,
121119
"oneOf": [
122120
{
123121
"type": "object",
@@ -153,8 +151,7 @@
153151
"vendorSourceMap": {
154152
"type": "boolean",
155153
"description": "Resolve vendor packages sourcemaps.",
156-
"x-deprecated": true,
157-
"default": false
154+
"x-deprecated": true
158155
},
159156
"evalSourceMap": {
160157
"type": "boolean",

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,14 @@ describe('Dev Server Builder', () => {
9292
expect(await response.text()).toContain('<title>HelloWorldApp</title>');
9393
});
9494

95+
it('should not generate sourcemaps when running prod build', async () => {
96+
// Production builds have sourcemaps turned off.
97+
const run = await architect.scheduleTarget({ ...target, configuration: 'production' });
98+
runs.push(run);
99+
const output = await run.result as DevServerBuilderOutput;
100+
expect(output.success).toBe(true);
101+
const hasSourceMaps = output.emittedFiles && output.emittedFiles.some(f => f.extension === '.map');
102+
expect(hasSourceMaps).toBe(false, `Expected emitted files not to contain '.map' files.`);
103+
});
104+
95105
});

0 commit comments

Comments
 (0)