Repository navigation
perf(@angular/build): optimize library dts bundling and enable dts tree-shaking - #34431
Open
alan-agius4 wants to merge 5 commits into
Open
alan-agius4 wants to merge 5 commits into
alan-agius4 wants to merge 5 commits into
Conversation
…ee-shaking
- Enable tree-shaking (`{ moduleSideEffects: false }`) for `.d.ts` bundles in `executeMultiBundle` so unexported internal types and unused namespace declarations are stripped, and skip emitting empty or virtual-only `rolldown-runtime` non-entry `.d.ts` chunks in `processRolldownOutput`.
- Cache the `rolldown-plugin-dts` module import promise and invoke `createFakeJsPlugin` directly in `bundleAllDts` instead of calling `dts({ dtsInput: true, ... })`, eliminating redundant per-build `oxc-resolver` (`ResolverFactory`) instantiation.
- Disable Rolldown `tsconfig` auto-discovery (`tsconfig: false`) and plugin timing instrumentation (`checks: { circularDependency: false, pluginTimings: false }`) in `executeMultiBundle`.
alan-agius4
marked this pull request as ready for review
October 20, 2026 10:34
There was a problem hiding this comment.
Code Review
This pull request optimizes the library bundler pipeline by dynamically loading rolldown-plugin-dts and directly instantiating createFakeJsPlugin to avoid unnecessary native resolver instantiation. It also introduces logic to skip empty or virtual-only .d.ts chunks (such as rolldown-runtime helpers) and adds corresponding unit and integration tests. Feedback was provided to ensure that skipped .d.ts chunks are not actively imported by other chunks, which could otherwise lead to broken import references. A code suggestion was provided to track and exclude imported files from being skipped.
… dts tree-shaking
… dts tree-shaking
… dts tree-shaking
… dts tree-shaking
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.d.tstree-shaking: Settreeshake: isDts ? { moduleSideEffects: false } : falseinexecuteMultiBundleto strip unexported internal types and unused namespace declarations from.d.tsbundles.dts()wrapper inbundleAllDts: Cache theimport('rolldown-plugin-dts')promise at module scope and invokecreateFakeJsPlugindirectly instead of callingdts({ dtsInput: true, ... })and filtering outrolldown-plugin-dts:resolver. This avoids unconditionally instantiating a nativeoxc-resolver(ResolverFactory) on every build.tsconfigauto-discovery and plugin timings: Passtsconfig: falseandchecks: { circularDependency: false, pluginTimings: false }torolldown()inexecuteMultiBundle.Benchmark
main