Skip to content

Commit 000b0e5

Browse files
alan-agius4filipesilva
authored andcommitted
feat(@angular-devkit/build-angular): remove deprecated dev-server options
BREAKING CHANGE: With this change a number of deprecated dev-server builder options which proxied to the browser builder have been removed. These options should be configured in the browser builder instead. The removed options are: - `aot` - `sourceMap` - `deployUrl` - `baseHref` - `vendorChunk` - `commonChunk` - `optimization` - `progress`
1 parent 1aad76f commit 000b0e5

File tree

4 files changed

+38
-178
lines changed

4 files changed

+38
-178
lines changed

goldens/public-api/angular_devkit/build_angular/src/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ export interface KarmaBuilderOptions {
193193
progress?: boolean;
194194
reporters?: string[];
195195
scripts?: ExtraEntryPoint_2[];
196-
sourceMap?: SourceMapUnion_3;
196+
sourceMap?: SourceMapUnion_2;
197197
stylePreprocessorOptions?: StylePreprocessorOptions_2;
198198
styles?: ExtraEntryPoint_2[];
199199
tsConfig: string;
@@ -264,7 +264,7 @@ export interface ServerBuilderOptions {
264264
localize?: Localize_2;
265265
main: string;
266266
namedChunks?: boolean;
267-
optimization?: OptimizationUnion_3;
267+
optimization?: OptimizationUnion_2;
268268
outputHashing?: OutputHashing_2;
269269
outputPath: string;
270270
poll?: number;
@@ -273,7 +273,7 @@ export interface ServerBuilderOptions {
273273
resourcesOutputPath?: string;
274274
// @deprecated
275275
showCircularDependencies?: boolean;
276-
sourceMap?: SourceMapUnion_4;
276+
sourceMap?: SourceMapUnion_3;
277277
statsJson?: boolean;
278278
stylePreprocessorOptions?: StylePreprocessorOptions_3;
279279
tsConfig: string;

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

Lines changed: 17 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -50,38 +50,6 @@ import { Schema } from './schema';
5050

5151
export type DevServerBuilderOptions = Schema & json.JsonObject;
5252

53-
const devServerBuildOverriddenKeys: (keyof DevServerBuilderOptions)[] = [
54-
'watch',
55-
'optimization',
56-
'aot',
57-
'sourceMap',
58-
'vendorChunk',
59-
'commonChunk',
60-
'baseHref',
61-
'progress',
62-
'poll',
63-
'verbose',
64-
'deployUrl',
65-
];
66-
67-
// Get dev-server only options.
68-
type DevServerOptions = Partial<
69-
Omit<
70-
Schema,
71-
| 'watch'
72-
| 'optimization'
73-
| 'aot'
74-
| 'sourceMap'
75-
| 'vendorChunk'
76-
| 'commonChunk'
77-
| 'baseHref'
78-
| 'progress'
79-
| 'poll'
80-
| 'verbose'
81-
| 'deployUrl'
82-
>
83-
>;
84-
8553
/**
8654
* @experimental Direct usage of this type is considered experimental.
8755
*/
@@ -120,42 +88,8 @@ export function serveWebpackBrowser(
12088
projectRoot: string;
12189
locale: string | undefined;
12290
}> {
123-
// Get the browser configuration from the target name.
124-
const rawBrowserOptions = (await context.getTargetOptions(browserTarget)) as json.JsonObject &
125-
BrowserBuilderSchema;
12691
options.port = await checkPort(options.port ?? 4200, options.host || 'localhost');
12792

128-
// Override options we need to override, if defined.
129-
const overrides = (Object.keys(options) as (keyof DevServerBuilderOptions)[])
130-
.filter((key) => options[key] !== undefined && devServerBuildOverriddenKeys.includes(key))
131-
.reduce<json.JsonObject & Partial<BrowserBuilderSchema>>(
132-
(previous, key) => ({
133-
...previous,
134-
[key]: options[key],
135-
}),
136-
{},
137-
);
138-
139-
const devServerOptions: DevServerOptions = (Object.keys(options) as (keyof Schema)[])
140-
.filter((key) => !devServerBuildOverriddenKeys.includes(key) && key !== 'browserTarget')
141-
.reduce<DevServerOptions>(
142-
(previous, key) => ({
143-
...previous,
144-
[key]: options[key],
145-
}),
146-
{},
147-
);
148-
149-
// In dev server we should not have budgets because of extra libs such as socks-js
150-
overrides.budgets = undefined;
151-
152-
if (rawBrowserOptions.outputHashing && rawBrowserOptions.outputHashing !== OutputHashing.None) {
153-
// Disable output hashing for dev build as this can cause memory leaks
154-
// See: https://github.com/webpack/webpack-dev-server/issues/377#issuecomment-241258405
155-
overrides.outputHashing = OutputHashing.None;
156-
logger.warn(`Warning: 'outputHashing' option is disabled when using the dev-server.`);
157-
}
158-
15993
if (options.hmr) {
16094
logger.warn(tags.stripIndents`NOTICE: Hot Module Replacement (HMR) is enabled for the dev server.
16195
See https://webpack.js.org/guides/hot-module-replacement for information on working with HMR for Webpack.`);
@@ -185,14 +119,26 @@ export function serveWebpackBrowser(
185119
for more information.
186120
`);
187121
}
122+
// Get the browser configuration from the target name.
123+
const rawBrowserOptions = (await context.getTargetOptions(browserTarget)) as json.JsonObject &
124+
BrowserBuilderSchema;
188125

189-
// Webpack's live reload functionality adds the `strip-ansi` package which is commonJS
190-
rawBrowserOptions.allowedCommonJsDependencies ??= [];
191-
rawBrowserOptions.allowedCommonJsDependencies.push('strip-ansi');
126+
if (rawBrowserOptions.outputHashing && rawBrowserOptions.outputHashing !== OutputHashing.None) {
127+
// Disable output hashing for dev build as this can cause memory leaks
128+
// See: https://github.com/webpack/webpack-dev-server/issues/377#issuecomment-241258405
129+
rawBrowserOptions.outputHashing = OutputHashing.None;
130+
logger.warn(`Warning: 'outputHashing' option is disabled when using the dev-server.`);
131+
}
192132

193133
const browserName = await context.getBuilderNameForTarget(browserTarget);
194134
const browserOptions = (await context.validateOptions(
195-
{ ...rawBrowserOptions, ...overrides },
135+
{
136+
...rawBrowserOptions,
137+
watch: options.watch,
138+
verbose: options.verbose,
139+
// In dev server we should not have budgets because of extra libs such as socks-js
140+
budgets: undefined,
141+
} as json.JsonObject & BrowserBuilderSchema,
196142
browserName,
197143
)) as json.JsonObject & BrowserBuilderSchema;
198144

@@ -221,7 +167,7 @@ export function serveWebpackBrowser(
221167
getTypeScriptConfig(wco),
222168
browserOptions.webWorkerTsConfig ? getWorkerConfig(wco) : {},
223169
],
224-
devServerOptions,
170+
options,
225171
);
226172

227173
if (!config.devServer) {

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

Lines changed: 0 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -92,98 +92,6 @@
9292
"description": "Rebuild on change.",
9393
"default": true
9494
},
95-
"optimization": {
96-
"description": "Enables optimization of the build output. Including minification of scripts and styles, tree-shaking, dead-code elimination, tree-shaking and fonts inlining. For more information, see https://angular.io/guide/workspace-config#optimization-configuration.",
97-
"x-user-analytics": 16,
98-
"oneOf": [
99-
{
100-
"type": "object",
101-
"properties": {
102-
"scripts": {
103-
"type": "boolean",
104-
"description": "Enables optimization of the scripts output.",
105-
"default": true
106-
},
107-
"styles": {
108-
"type": "boolean",
109-
"description": "Enables optimization of the styles output.",
110-
"default": true
111-
}
112-
},
113-
"additionalProperties": false
114-
},
115-
{
116-
"type": "boolean"
117-
}
118-
],
119-
"x-deprecated": "Use the \"optimization\" option in the browser builder instead."
120-
},
121-
"aot": {
122-
"type": "boolean",
123-
"description": "Build using Ahead of Time compilation.",
124-
"x-user-analytics": 13,
125-
"x-deprecated": "Use the \"aot\" option in the browser builder instead."
126-
},
127-
"sourceMap": {
128-
"description": "Output source maps for scripts and styles. For more information, see https://angular.io/guide/workspace-config#source-map-configuration.",
129-
"oneOf": [
130-
{
131-
"type": "object",
132-
"properties": {
133-
"scripts": {
134-
"type": "boolean",
135-
"description": "Output source maps for all scripts.",
136-
"default": true
137-
},
138-
"styles": {
139-
"type": "boolean",
140-
"description": "Output source maps for all styles.",
141-
"default": true
142-
},
143-
"hidden": {
144-
"type": "boolean",
145-
"description": "Output source maps used for error reporting tools.",
146-
"default": false
147-
},
148-
"vendor": {
149-
"type": "boolean",
150-
"description": "Resolve vendor packages source maps.",
151-
"default": false
152-
}
153-
},
154-
"additionalProperties": false
155-
},
156-
{
157-
"type": "boolean"
158-
}
159-
],
160-
"x-deprecated": "Use the \"sourceMap\" option in the browser builder instead."
161-
},
162-
"vendorChunk": {
163-
"type": "boolean",
164-
"description": "Generate a seperate bundle containing only vendor libraries. This option should only used for development.",
165-
"x-deprecated": "Use the \"vendorChunk\" option in the browser builder instead."
166-
},
167-
"commonChunk": {
168-
"type": "boolean",
169-
"description": "Generate a seperate bundle containing code used across multiple bundles.",
170-
"x-deprecated": "Use the \"commonChunk\" option in the browser builder instead."
171-
},
172-
"baseHref": {
173-
"type": "string",
174-
"description": "Base url for the application being built.",
175-
"x-deprecated": "Use the \"baseHref\" option in the browser builder instead."
176-
},
177-
"deployUrl": {
178-
"type": "string",
179-
"description": "URL where files will be deployed.",
180-
"x-deprecated": "Use the \"deployUrl\" option in the browser builder instead."
181-
},
182-
"progress": {
183-
"type": "boolean",
184-
"description": "Log progress to the console while building.",
185-
"x-deprecated": "Use the \"progress\" option in the browser builder instead."
186-
},
18795
"poll": {
18896
"type": "number",
18997
"description": "Enable and define the file watching poll time period in milliseconds."

packages/schematics/angular/migrations/update-13/update-angular-config.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,24 @@ export default function (): Rule {
1616
// Delete removed tslint builder
1717
if (target.builder === '@angular-devkit/build-angular:tslint') {
1818
project.targets.delete(name);
19-
continue;
20-
}
21-
22-
if (!target.builder.startsWith('@angular-devkit/build-angular')) {
23-
continue;
24-
}
25-
26-
// Only interested in Angular Devkit builders
27-
for (const [, options] of allTargetOptions(target)) {
28-
delete options.extractCss;
29-
delete options.servePathDefaultWarning;
30-
delete options.hmrWarning;
19+
} else if (target.builder === '@angular-devkit/build-angular:dev-server') {
20+
for (const [, options] of allTargetOptions(target)) {
21+
delete options.optimization;
22+
delete options.aot;
23+
delete options.progress;
24+
delete options.deployUrl;
25+
delete options.sourceMap;
26+
delete options.vendorChunk;
27+
delete options.commonChunk;
28+
delete options.baseHref;
29+
delete options.servePathDefaultWarning;
30+
delete options.hmrWarning;
31+
}
32+
} else if (target.builder.startsWith('@angular-devkit/build-angular')) {
33+
// Only interested in Angular Devkit builders
34+
for (const [, options] of allTargetOptions(target)) {
35+
delete options.extractCss;
36+
}
3137
}
3238
}
3339
}

0 commit comments

Comments
 (0)