Skip to content

Commit

Permalink
perf(@angular-devkit/build-angular): avoid transforming empty compone…
Browse files Browse the repository at this point in the history
…nt 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)
  • Loading branch information
clydin authored and alan-agius4 committed Mar 15, 2024
1 parent a6ec0bb commit 79c44ad
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 79c44ad

Please sign in to comment.