Skip to content

Commit 79c44ad

Browse files
clydinalan-agius4
authored andcommittedMar 15, 2024·
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 99104cd)
1 parent a6ec0bb commit 79c44ad

File tree

1 file changed

+5
-0
lines changed
  • packages/angular_devkit/build_angular/src/tools/esbuild/angular

1 file changed

+5
-0
lines changed
 

Diff for: ‎packages/angular_devkit/build_angular/src/tools/esbuild/angular/angular-host.ts

+5
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ export function createAngularCompilerHost(
6868
return null;
6969
}
7070

71+
// No transformation required if the resource is empty
72+
if (data.trim().length === 0) {
73+
return { content: '' };
74+
}
75+
7176
const result = await hostOptions.transformStylesheet(
7277
data,
7378
context.containingFile,

0 commit comments

Comments
 (0)
Please sign in to comment.