Skip to content

Commit 560ec40

Browse files
committed
refactor(@angular-devkit/build-angular): reduce usage of @angular-devkit/core types
Logging types are now based on the BuilderContext's type instead of the `@angular-devkit/core` type. This reduces the need to directly depend on this package while also allowing the builder logging type to diverge if needed. The two usages of the BaseException type which is a small wrapper around Error have also been removed.
1 parent 93e918e commit 560ec40

File tree

7 files changed

+13
-15
lines changed

7 files changed

+13
-15
lines changed

packages/angular_devkit/build_angular/src/builders/application/build-action.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import { BuilderOutput } from '@angular-devkit/architect';
10-
import type { logging } from '@angular-devkit/core';
9+
import { BuilderContext, BuilderOutput } from '@angular-devkit/architect';
1110
import { existsSync } from 'node:fs';
1211
import path from 'node:path';
1312
import { BuildOutputFile } from '../../tools/esbuild/bundler-context';
@@ -44,7 +43,7 @@ export async function* runEsBuildBuildAction(
4443
workspaceRoot: string;
4544
projectRoot: string;
4645
outputOptions: NormalizedOutputOptions;
47-
logger: logging.LoggerApi;
46+
logger: BuilderContext['logger'];
4847
cacheOptions: NormalizedCachedOptions;
4948
writeToFileSystem: boolean;
5049
writeToFileSystemFilter: ((file: BuildOutputFile) => boolean) | undefined;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import type { BuilderContext } from '@angular-devkit/architect';
10-
import type { json, logging } from '@angular-devkit/core';
10+
import type { json } from '@angular-devkit/core';
1111
import type { Plugin } from 'esbuild';
1212
import assert from 'node:assert';
1313
import { readFile } from 'node:fs/promises';
@@ -314,7 +314,7 @@ function handleUpdate(
314314
generatedFiles: Map<string, OutputFileRecord>,
315315
server: ViteDevServer,
316316
serverOptions: NormalizedDevServerOptions,
317-
logger: logging.LoggerApi,
317+
logger: BuilderContext['logger'],
318318
): void {
319319
const updatedFiles: string[] = [];
320320

packages/angular_devkit/build_angular/src/tools/esbuild/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import { logging } from '@angular-devkit/core';
9+
import { BuilderContext } from '@angular-devkit/architect';
1010
import { BuildOptions, Metafile, OutputFile, formatMessages } from 'esbuild';
1111
import { createHash } from 'node:crypto';
1212
import { constants as fsConstants } from 'node:fs';
@@ -456,7 +456,7 @@ export async function createJsonBuildManifest(
456456
}
457457

458458
export async function logMessages(
459-
logger: logging.LoggerApi,
459+
logger: BuilderContext['logger'],
460460
executionResult: ExecutionResult,
461461
color?: boolean,
462462
jsonLogs?: boolean,

packages/angular_devkit/build_angular/src/utils/normalize-asset-patterns.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import { BaseException } from '@angular-devkit/core';
109
import { statSync } from 'fs';
1110
import * as path from 'path';
1211
import { AssetPattern, AssetPatternClass } from '../builders/browser/schema';
1312

14-
export class MissingAssetSourceRootException extends BaseException {
13+
export class MissingAssetSourceRootException extends Error {
1514
constructor(path: string) {
1615
super(`The ${path} asset path must start with the project source root.`);
1716
}

packages/angular_devkit/build_angular/src/utils/normalize-file-replacements.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,11 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import { BaseException } from '@angular-devkit/core';
109
import { existsSync } from 'fs';
1110
import * as path from 'path';
1211
import { FileReplacement } from '../builders/browser/schema';
1312

14-
export class MissingFileReplacementException extends BaseException {
13+
export class MissingFileReplacementException extends Error {
1514
constructor(path: string) {
1615
super(`The ${path} path in file replacements does not exist.`);
1716
}

packages/angular_devkit/build_angular/src/utils/supported-browsers.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import { logging } from '@angular-devkit/core';
109
import browserslist from 'browserslist';
1110

12-
export function getSupportedBrowsers(projectRoot: string, logger: logging.LoggerApi): string[] {
11+
export function getSupportedBrowsers(
12+
projectRoot: string,
13+
logger: { warn(message: string): void },
14+
): string[] {
1315
browserslist.defaults = [
1416
'last 2 Chrome versions',
1517
'last 1 Firefox version',

packages/angular_devkit/build_angular/src/utils/webpack-browser-config.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
*/
88

99
import { BuilderContext } from '@angular-devkit/architect';
10-
import { logging } from '@angular-devkit/core';
1110
import * as path from 'path';
1211
import { Configuration, javascript } from 'webpack';
1312
import { merge as webpackMerge } from 'webpack-merge';
@@ -34,7 +33,7 @@ export async function generateWebpackConfig(
3433
projectName: string,
3534
options: NormalizedBrowserBuilderSchema,
3635
webpackPartialGenerator: WebpackPartialGenerator,
37-
logger: logging.LoggerApi,
36+
logger: BuilderContext['logger'],
3837
extraBuildOptions: Partial<NormalizedBrowserBuilderSchema>,
3938
): Promise<Configuration> {
4039
// Ensure Build Optimizer is only used with AOT.

0 commit comments

Comments
 (0)