From 79c44adac4184408cbd1dc07989796f155cfc70e Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Thu, 14 Mar 2024 16:18:33 -0400 Subject: [PATCH] perf(@angular-devkit/build-angular): avoid transforming empty component stylesheets A stylesheet for a component that is empty or contains only whitespace will no longer be transformed and bundled during a build. Transforming the stylesheet was unnecessary work as an empty string would be returned as a result. While this may not be common in applications, it is a possibility. Both file and inline component stylesheets are affected by this change. (cherry picked from commit 99104cd9e5401cb67aff0c6608903bcb5b1a9db3) --- .../build_angular/src/tools/esbuild/angular/angular-host.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/angular_devkit/build_angular/src/tools/esbuild/angular/angular-host.ts b/packages/angular_devkit/build_angular/src/tools/esbuild/angular/angular-host.ts index 66108aebb346..ea5c676170da 100644 --- a/packages/angular_devkit/build_angular/src/tools/esbuild/angular/angular-host.ts +++ b/packages/angular_devkit/build_angular/src/tools/esbuild/angular/angular-host.ts @@ -68,6 +68,11 @@ export function createAngularCompilerHost( return null; } + // No transformation required if the resource is empty + if (data.trim().length === 0) { + return { content: '' }; + } + const result = await hostOptions.transformStylesheet( data, context.containingFile,