Repository navigation
perf(@angular/build): avoid reading external component stylesheets twice - #34434
Conversation
- Skip calling `this.readFile(filename)` in `host.readResource(filename)` when `!hasTemplateExtension(filename)` so external component stylesheets (`styleUrl` / `styleUrls`) are not read from disk on the Angular compiler worker thread and serialized over the worker `MessagePort` only to be ignored by `transformStylesheet`. - Only short-circuit empty `data` in `host.transformResource(data, context)` for inline styles (`!context.resourceFile`) so external stylesheets still proceed to `transformStylesheet`.
There was a problem hiding this comment.
Code Review
This pull request optimizes resource loading and transformation in the Angular compiler host. Specifically, readResource is updated to only read template files, bypassing external stylesheets which are bundled during transformResource. Additionally, transformResource is adjusted to only short-circuit empty inline styles, ensuring empty external stylesheets are still processed. Unit tests have been added to verify these changes. As there are no review comments, I have no feedback to provide.
|
This pull request has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
host.readResource(filename), return''directly when!hasTemplateExtension(filename)instead of reading the external stylesheet file from disk on the Angular compiler worker thread and serializing its contents over the workerMessagePort, sincetransformStylesheetignoresdatawhenstylesheetFileis provided and reads/bundles the file viastylesheetBundler.bundleFile(stylesheetFile).host.transformResource(data, context), only short-circuit emptydatafor inline styles (!context.resourceFile && data.trim().length === 0) so external stylesheets proceed tohostOptions.transformStylesheet.