feat(@angular/build): add library builder - #34106
alan-agius4 wants to merge 2 commits into
Conversation
e9c43b0 to
67110b0
Compare
67110b0 to
5513da2
Compare
5513da2 to
b3ffd2d
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a new library builder (@angular/build:library) designed to compile, bundle, and package Angular libraries in compliance with the Angular Package Format (APF). It includes features such as incremental compilation, watch mode, asset copying, secondary entry point resolution, and package.json generation. The review feedback highlights a few critical areas for improvement: ensuring the package name is updated in options when package.json changes in watch mode, optimizing startup by avoiding redundant reads of package.json, and capturing and propagating stylesheet compilation warnings to the user.
There was a problem hiding this comment.
Code Review
This pull request introduces a new library builder for Angular, enabling the compilation, bundling, and packaging of libraries in accordance with the Angular Package Format (APF). The changes include the core builder logic, a dependency graph scanner for entry points, an incremental compilation pipeline, and support for secondary entry points. My review highlights performance optimizations for the dependency predicate and file change detection logic, which are critical for maintaining build speed in larger projects.
7239409 to
4ee7685
Compare
5ef0ac4 to
b19ab2c
Compare
9f149cd to
2b8932e
Compare
|
Hello! @alan-agius4 thank you for your great job. A few questions (cause i'm planning to test new builder):
If it will help: happy to report back what brakes. ngwr using 227 entry points, per-entry-point sass, harnesses in secondary entry points |
2b8932e to
e1fa579
Compare
|
@thekhegay, thanks for the questions! Here are the details:
Testing on a project with 227 entry points, per-entry Sass, and secondary test harnesses would be fantastic and extremely helpful please feel free to share any issues you run into! |
|
@alan-agius4 out of scope of this PR, just flagging it: about entryPoints map. ngwr has 228 entry points (99 of them nested, like The part that worries me isn't size - adding an entry point becomes two steps instead of one, and forgetting second fails silently - entry point just is not published. Would a glob value be on the table ( Sorry for dropping this here - discussions are off in this repor and i wasnt sure where question belongs. happy to move it to and issue if you'd rather keep this PR clean P.S. I have started building ngwr against this branch and running tests against output. If i hit anything i ll file if as an issue with reproductin rather than comment in this PR. |
e1fa579 to
4403612
Compare
|
I actually just tested this against
To address your questions:
Please feel free to open issues with any reproductions or edge cases you encounter while testing your feedback is greatly appreciated! |
a84e8ef to
5579d74
Compare
Add a new native `@angular/build:library` builder providing a modern, high-performance compilation and packaging pipeline.
bdc7872 to
bed00ba
Compare
bed00ba to
005e05e
Compare
|
Hi @alan-agius4, this is great! Now that TypeScript projects are growing in size and TypeScript itself is moving to the native Golang rewrite, driven by the need to optimize build times, I think that the approach to the new library builder is the way to go.
You have a very good point on incremental rebuilds in watch mode. The disk-heavy I/O in That said, optimus-ui should also be a valid reference to run benchmarks.
Fully agree. The disk-heavy I/O in I'll also agree that focusing on build times and therefore dropping auto-discovery of source files is a valid point.
Definetely. Centralizing this layout stops configuration drift across deeply nested directories. I think, this is an incredible and much-needed milestone for the ecosystem! I’ve been heavily experimenting with a similar in-memory architecture for Seeing your benchmarks, especially the incremental TS/SCSS rebuild times hitting <250ms compared to legacy chains, completely validates that memory-bound compilation is the way forward for large-scale source repositories. |
|
Thanks for the feedback, @dherges! Also, thanks for pointing out optimus-ui, I'll definitely look into running benchmarks against it as well. Just one clarification regarding the in memory aspect: The performance gains we're seeing here, especially for incremental TS and SCSS rebuilds, mainly come from tighter integration with Angular's compiler host and caching infrastructure, along with a direct async rebuild pipeline that eliminates the orchestration overhead of the reactive RxJS transform architecture and per entry point sub pipelines. |
|
@alan-agius4 about entryPoints: I put up the glob version as a draft #34127. An entry point that silently doesn't get published was the part that worried me most, so I wanted something concrete to discuss rather than just an issue. On ngwr these two lines replace the 230-line map, the output is identical to the explicit map, and the scan takes ~10ms. It's a draft since there's nothing to merge it into yet. Happy to change approach or close it if you'd rather do it differently. |
That makes total sense. I was exploring the disk I/O of the source discovery and the
So you're saying: sharing the compiler host and the stylesheet bundling across multiple entry points is the real difference. Right? To better understand the approach: is the speedup here just removing RxJS transforms, or removing RxJS transforms plus additional benefit that come along with it? |
|
Thanks for putting together #34127 so quickly, @thekhegay! Having a concrete implementation to look at makes evaluating the ergonomics much easier, and the data on @dherges That is definitely a large part of it, but the speedup comes from several specific architectural changes beyond just removing the RxJS transform layer:
|
PR Checklist
Please check to confirm your PR fulfills the following requirements:
PR Type
What is the current behavior?
Currently, there is no native
@angular/build:librarybuilder in@angular/build.Issue Number: N/A
What is the new behavior?
Add a new native
@angular/build:librarybuilder providing a modern, high-performance compilation and packaging pipeline.Does this PR introduce a breaking change?
Other information