Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(@angular/build): remove Webpack-specific options from Vite-only dev-server #27525

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 1 addition & 7 deletions goldens/public-api/angular/build/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,7 @@ export enum BuildOutputFileType {

// @public
export interface DevServerBuilderOptions {
allowedHosts?: string[];
// @deprecated
browserTarget?: string;
buildTarget?: string;
disableHostCheck?: boolean;
forceEsbuild?: boolean;
buildTarget: string;
headers?: {
[key: string]: string;
};
Expand All @@ -127,7 +122,6 @@ export interface DevServerBuilderOptions {
port?: number;
prebundle?: PrebundleUnion;
proxyConfig?: string;
publicHost?: string;
servePath?: string;
ssl?: boolean;
sslCert?: string;
Expand Down
12 changes: 2 additions & 10 deletions packages/angular/build/src/builders/dev-server/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ async function initialize(
const builderName = await context.getBuilderNameForTarget(normalizedOptions.buildTarget);

if (
!normalizedOptions.disableHostCheck &&
!/^127\.\d+\.\d+\.\d+/g.test(normalizedOptions.host) &&
normalizedOptions.host !== '::1' &&
normalizedOptions.host !== 'localhost'
) {
context.logger.warn(`
Expand All @@ -96,18 +96,10 @@ locally. It hasn't been reviewed for security issues.

Binding this server to an open connection can result in compromising your application or
computer. Using a different host than the one passed to the "--host" flag might result in
websocket connection issues. You might need to use "--disable-host-check" if that's the
case.
websocket connection issues.
`);
}

if (normalizedOptions.disableHostCheck) {
context.logger.warn(
'Warning: Running a server with --disable-host-check is a security risk. ' +
'See https://medium.com/webpack/webpack-dev-server-middleware-security-issues-1489d950874a for more information.',
);
}

normalizedOptions.port = await checkPort(normalizedOptions.port, normalizedOptions.host);

return {
Expand Down
10 changes: 1 addition & 9 deletions packages/angular/build/src/builders/dev-server/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export async function normalizeOptions(
const cacheOptions = normalizeCacheOptions(projectMetadata, workspaceRoot);

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

// Initial options to keep
Expand All @@ -46,18 +46,14 @@ export async function normalizeOptions(
open,
verbose,
watch,
allowedHosts,
disableHostCheck,
liveReload,
hmr,
headers,
proxyConfig,
servePath,
publicHost,
ssl,
sslCert,
sslKey,
forceEsbuild,
prebundle,
} = options;

Expand All @@ -76,15 +72,11 @@ export async function normalizeOptions(
workspaceRoot,
projectRoot,
cacheOptions,
allowedHosts,
disableHostCheck,
proxyConfig,
servePath,
publicHost,
ssl,
sslCert,
sslKey,
forceEsbuild,
// Prebundling defaults to true but requires caching to function
prebundle: cacheOptions.enabled && (prebundle ?? true),
};
Expand Down
32 changes: 2 additions & 30 deletions packages/angular/build/src/builders/dev-server/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@
"description": "Dev Server target options for Build Facade.",
"type": "object",
"properties": {
"browserTarget": {
"type": "string",
"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`.",
"pattern": "^[^:\\s]+:[^:\\s]+(:[^\\s]+)?$",
"x-deprecated": "Use 'buildTarget' instead."
},
"buildTarget": {
"type": "string",
"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`.",
Expand Down Expand Up @@ -67,27 +61,10 @@
"description": "Whether to reload the page on change, using live-reload.",
"default": true
},
"publicHost": {
"type": "string",
"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."
},
"allowedHosts": {
"type": "array",
"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.",
"default": [],
"items": {
"type": "string"
}
},
"servePath": {
"type": "string",
"description": "The pathname where the application will be served."
},
"disableHostCheck": {
"type": "boolean",
"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.",
"default": false
},
"hmr": {
"type": "boolean",
"description": "Enable hot module replacement.",
Expand All @@ -102,13 +79,8 @@
"type": "number",
"description": "Enable and define the file watching poll time period in milliseconds."
},
"forceEsbuild": {
"type": "boolean",
"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.",
"default": false
},
"prebundle": {
clydin marked this conversation as resolved.
Show resolved Hide resolved
"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.",
"description": "Enable and control the Vite-based development server's prebundling capabilities. To enable prebundling, the Angular CLI cache must also be enabled.",
"oneOf": [
{ "type": "boolean" },
{
Expand All @@ -127,5 +99,5 @@
}
},
"additionalProperties": false,
"anyOf": [{ "required": ["buildTarget"] }, { "required": ["browserTarget"] }]
"required": ["buildTarget"]
}

This file was deleted.

This file was deleted.

This file was deleted.