Repository navigation
perf(@angular/build): optimize library dts bundling and enable dts tree-shaking - #34431
Conversation
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.
9857ff4 to
c25e237
Compare
…ee-shaking
- Enable tree-shaking (`treeshake: isDts`) for `.d.ts` bundles in `executeMultiBundle` so unexported internal types and unused namespace declarations are stripped while preserving modules with `declare global` or `declare module` augmentations.
- 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`.
c25e237 to
9165ee5
Compare
… dts tree-shaking
… dts tree-shaking
|
This PR was merged into the repository. The changes were merged into the following branches:
|
|
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. |
Summary
.d.tstree-shaking: Settreeshake: isDtsinexecuteMultiBundleto strip unexported internal types and unused namespace declarations from.d.tsbundles while preserving modules withdeclare globalordeclare moduleaugmentations.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