Skip to content

Commit c8b1fc0

Browse files
committed
refactor(@angular/build): remove Webpack-specific options from Vite-only dev-server
The `dev-server` build within the `@angular/build` package no longer uses Webpack. As a result, the Webpack related options have been removed from the builder schema. These options were not previously used by the Vite-based development server with the exception of `browserTarget` which was removed due to it being deprecated on the `@angular-devkit/build-angular` version.
1 parent 0a59eae commit c8b1fc0

File tree

8 files changed

+6
-348
lines changed

8 files changed

+6
-348
lines changed

goldens/public-api/angular/build/index.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,7 @@ export enum BuildOutputFileType {
110110

111111
// @public
112112
export interface DevServerBuilderOptions {
113-
allowedHosts?: string[];
114-
// @deprecated
115-
browserTarget?: string;
116-
buildTarget?: string;
117-
disableHostCheck?: boolean;
118-
forceEsbuild?: boolean;
113+
buildTarget: string;
119114
headers?: {
120115
[key: string]: string;
121116
};
@@ -127,7 +122,6 @@ export interface DevServerBuilderOptions {
127122
port?: number;
128123
prebundle?: PrebundleUnion;
129124
proxyConfig?: string;
130-
publicHost?: string;
131125
servePath?: string;
132126
ssl?: boolean;
133127
sslCert?: string;

packages/angular/build/src/builders/dev-server/builder.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ async function initialize(
8686
const builderName = await context.getBuilderNameForTarget(normalizedOptions.buildTarget);
8787

8888
if (
89-
!normalizedOptions.disableHostCheck &&
9089
!/^127\.\d+\.\d+\.\d+/g.test(normalizedOptions.host) &&
90+
normalizedOptions.host !== '::1' &&
9191
normalizedOptions.host !== 'localhost'
9292
) {
9393
context.logger.warn(`
@@ -96,18 +96,10 @@ locally. It hasn't been reviewed for security issues.
9696
9797
Binding this server to an open connection can result in compromising your application or
9898
computer. Using a different host than the one passed to the "--host" flag might result in
99-
websocket connection issues. You might need to use "--disable-host-check" if that's the
100-
case.
99+
websocket connection issues.
101100
`);
102101
}
103102

104-
if (normalizedOptions.disableHostCheck) {
105-
context.logger.warn(
106-
'Warning: Running a server with --disable-host-check is a security risk. ' +
107-
'See https://medium.com/webpack/webpack-dev-server-middleware-security-issues-1489d950874a for more information.',
108-
);
109-
}
110-
111103
normalizedOptions.port = await checkPort(normalizedOptions.port, normalizedOptions.host);
112104

113105
return {

packages/angular/build/src/builders/dev-server/options.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export async function normalizeOptions(
3535
const cacheOptions = normalizeCacheOptions(projectMetadata, workspaceRoot);
3636

3737
// Target specifier defaults to the current project's build target using a development configuration
38-
const buildTargetSpecifier = options.buildTarget ?? options.browserTarget ?? `::development`;
38+
const buildTargetSpecifier = options.buildTarget ?? `::development`;
3939
const buildTarget = targetFromTargetString(buildTargetSpecifier, projectName, 'build');
4040

4141
// Initial options to keep
@@ -46,18 +46,14 @@ export async function normalizeOptions(
4646
open,
4747
verbose,
4848
watch,
49-
allowedHosts,
50-
disableHostCheck,
5149
liveReload,
5250
hmr,
5351
headers,
5452
proxyConfig,
5553
servePath,
56-
publicHost,
5754
ssl,
5855
sslCert,
5956
sslKey,
60-
forceEsbuild,
6157
prebundle,
6258
} = options;
6359

@@ -76,15 +72,11 @@ export async function normalizeOptions(
7672
workspaceRoot,
7773
projectRoot,
7874
cacheOptions,
79-
allowedHosts,
80-
disableHostCheck,
8175
proxyConfig,
8276
servePath,
83-
publicHost,
8477
ssl,
8578
sslCert,
8679
sslKey,
87-
forceEsbuild,
8880
// Prebundling defaults to true but requires caching to function
8981
prebundle: cacheOptions.enabled && (prebundle ?? true),
9082
};

packages/angular/build/src/builders/dev-server/schema.json

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@
44
"description": "Dev Server target options for Build Facade.",
55
"type": "object",
66
"properties": {
7-
"browserTarget": {
8-
"type": "string",
9-
"description": "A browser builder target to serve in the format of `project:target[:configuration]`. You can also pass in more than one configuration name as a comma-separated list. Example: `project:target:production,staging`.",
10-
"pattern": "^[^:\\s]+:[^:\\s]+(:[^\\s]+)?$",
11-
"x-deprecated": "Use 'buildTarget' instead."
12-
},
137
"buildTarget": {
148
"type": "string",
159
"description": "A build builder target to serve in the format of `project:target[:configuration]`. You can also pass in more than one configuration name as a comma-separated list. Example: `project:target:production,staging`.",
@@ -67,27 +61,10 @@
6761
"description": "Whether to reload the page on change, using live-reload.",
6862
"default": true
6963
},
70-
"publicHost": {
71-
"type": "string",
72-
"description": "The URL that the browser client (or live-reload client, if enabled) should use to connect to the development server. Use for a complex dev server setup, such as one with reverse proxies. This option has no effect when using the 'application' or other esbuild-based builders."
73-
},
74-
"allowedHosts": {
75-
"type": "array",
76-
"description": "List of hosts that are allowed to access the dev server. This option has no effect when using the 'application' or other esbuild-based builders.",
77-
"default": [],
78-
"items": {
79-
"type": "string"
80-
}
81-
},
8264
"servePath": {
8365
"type": "string",
8466
"description": "The pathname where the application will be served."
8567
},
86-
"disableHostCheck": {
87-
"type": "boolean",
88-
"description": "Don't verify connected clients are part of allowed hosts. This option has no effect when using the 'application' or other esbuild-based builders.",
89-
"default": false
90-
},
9168
"hmr": {
9269
"type": "boolean",
9370
"description": "Enable hot module replacement.",
@@ -102,13 +79,8 @@
10279
"type": "number",
10380
"description": "Enable and define the file watching poll time period in milliseconds."
10481
},
105-
"forceEsbuild": {
106-
"type": "boolean",
107-
"description": "Force the development server to use the 'browser-esbuild' builder when building. This is a developer preview option for the esbuild-based build system.",
108-
"default": false
109-
},
11082
"prebundle": {
111-
"description": "Enable and control the Vite-based development server's prebundling capabilities. To enable prebundling, the Angular CLI cache must also be enabled. This option has no effect when using the 'browser' or other Webpack-based builders.",
83+
"description": "Enable and control the Vite-based development server's prebundling capabilities. To enable prebundling, the Angular CLI cache must also be enabled.",
11284
"oneOf": [
11385
{ "type": "boolean" },
11486
{
@@ -127,5 +99,5 @@
12799
}
128100
},
129101
"additionalProperties": false,
130-
"anyOf": [{ "required": ["buildTarget"] }, { "required": ["browserTarget"] }]
102+
"required": ["buildTarget"]
131103
}

packages/angular/build/src/builders/dev-server/tests/options/allowed-hosts_spec.ts

Lines changed: 0 additions & 71 deletions
This file was deleted.

packages/angular/build/src/builders/dev-server/tests/options/disable-host-check_spec.ts

Lines changed: 0 additions & 71 deletions
This file was deleted.

packages/angular/build/src/builders/dev-server/tests/options/force-esbuild_spec.ts

Lines changed: 0 additions & 79 deletions
This file was deleted.

0 commit comments

Comments
 (0)