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

fix(angular): add missing forceEsbuild option to dev-server executor #21753

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/generated/packages/angular/executors/dev-server.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@
"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. _Note: this is only supported in Angular versions >= 16.1.0_.",
"default": false
},
"buildLibsFromSource": {
"type": "boolean",
"description": "Read buildable libraries from source instead of building them separately. If not set, it will take the value specified in the `browserTarget` options, or it will default to `true` if it's also not set in the `browserTarget` options.",
Expand Down
12 changes: 2 additions & 10 deletions packages/angular/src/builders/dev-server/dev-server.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
normalizePath,
parseTargetString,
readCachedProjectGraph,
stripIndents,
type Target,
} from '@nx/devkit';
import { getRootTsConfigPath } from '@nx/js';
Expand All @@ -34,7 +33,7 @@ import {
mergeCustomWebpackConfig,
resolveIndexHtmlTransformer,
} from '../utilities/webpack';
import { normalizeOptions } from './lib';
import { normalizeOptions, validateOptions } from './lib';
import type {
NormalizedSchema,
Schema,
Expand All @@ -55,14 +54,7 @@ export function executeDevServerBuilder(
rawOptions: Schema,
context: import('@angular-devkit/architect').BuilderContext
) {
if (rawOptions.esbuildMiddleware?.length > 0) {
const { major: angularMajorVersion, version: angularVersion } =
getInstalledAngularVersionInfo();
if (angularMajorVersion < 17) {
throw new Error(stripIndents`The "esbuildMiddleware" option is only supported in Angular >= 17.0.0. You are currently using "${angularVersion}".
You can resolve this error by removing the "esbuildMiddleware" option or by migrating to Angular 17.0.0.`);
}
}
validateOptions(rawOptions);

process.env.NX_TSCONFIG_PATH = getRootTsConfigPath();

Expand Down
1 change: 1 addition & 0 deletions packages/angular/src/builders/dev-server/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './normalize-options';
export * from './validate-options';
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { stripIndents } from '@nx/devkit';
import { lt } from 'semver';
import { getInstalledAngularVersionInfo } from '../../../executors/utilities/angular-version-utils';
import type { Schema } from '../schema';

export function validateOptions(options: Schema): void {
const { major: angularMajorVersion, version: angularVersion } =
getInstalledAngularVersionInfo();

if (lt(angularVersion, '16.1.0') && options.forceEsbuild !== undefined) {
throw new Error(stripIndents`The "forceEsbuild" option is only supported in Angular >= 16.1.0. You are currently using "${angularVersion}".
You can resolve this error by removing the "forceEsbuild" option or by migrating to Angular 16.1.0.`);
}

if (angularMajorVersion < 17 && options.esbuildMiddleware?.length > 0) {
throw new Error(stripIndents`The "esbuildMiddleware" option is only supported in Angular >= 17.0.0. You are currently using "${angularVersion}".
You can resolve this error by removing the "esbuildMiddleware" option or by migrating to Angular 17.0.0.`);
}
}
1 change: 1 addition & 0 deletions packages/angular/src/builders/dev-server/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ interface BaseSchema {
hmr?: boolean;
watch?: boolean;
poll?: number;
forceEsbuild?: boolean;
buildLibsFromSource?: boolean;
esbuildMiddleware?: string[];
}
Expand Down
5 changes: 5 additions & 0 deletions packages/angular/src/builders/dev-server/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@
"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. _Note: this is only supported in Angular versions >= 16.1.0_.",
"default": false
},
"buildLibsFromSource": {
"type": "boolean",
"description": "Read buildable libraries from source instead of building them separately. If not set, it will take the value specified in the `browserTarget` options, or it will default to `true` if it's also not set in the `browserTarget` options.",
Expand Down