refactor(@angular/build): Expose codeBundleCache to buildApplicationInternal - #32527
Aukevanoost wants to merge 1 commit into
Conversation
Exposes the codeBundle cache used in executeBuild to allow for performant multi-builder setups.
0b8a4c4 to
8ddcbe1
Compare
|
Hi all, I had a small question. Is this feature/fix something that could (or is) considered for ng22? Are there any potential downsides for adding this extra option? For tools that rely on the Angular builder this could be a huge decrease in build time. I'm happy to discuss the details. Also, I realized later that adding a predefined cache is not very productive if the cache is being purged right before starting the builder.[1] Would it make sense to skip purging the old cache if a codeBundleCache is provided? Thanks |
|
Thanks for putting this together and for your patience. While the concept of sharing the cache across builds makes sense, with our transition to Because of this, we'd prefer not to expand or expose these internal interfaces right now. Let's reconsider this in the future once the new pipeline settles. |
|
Fair answer, I appreciate you coming back to this. Our tooling pipeline revolves around multiple runs over a codebase, each touching different zones. So being able to reuse precompiled classes saves us a bunch of build time. I'd love to help around where I can on the new pipeline! Cheers |
First off, thanks for having a look at this!
This PR exposes the
codeBundleCacheused in executeBuild part of thebuildApplicationInternalto allow for performant multi-builder setups (because they can share the TS cache).PR Checklist
Please check to confirm your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Right now the
SourceFileCacheis initialized locally in theexecuteBuild()function.Issue Number: N/A
What is the new behavior?
The
SourceFileCacheis now part of theInternalOptions, allowing tools that use this builder to (optionally) provide a shared cache that can be re-used over multiple builds. As fallback it will create the default cache object.Does this PR introduce a breaking change?
Other information
We (native-federation) need this feature to speed up our builder. This way we can share the cache between the ESBuild plugin and main builder which decreases our build time drastically:
If interested, find the changes on our end here (it's a proof-of-concept): https://github.com/native-federation/angular-adapter/pull/4/changes#diff-6508a5b483eb2d55fd58361931d864832b5ba20178c796d07be21f9e8ac327ae