Repository navigation
fix(@angular/build): improve library bundler resolution and watch shared chunk consistency - #34440
Conversation
There was a problem hiding this comment.
Code Review
This pull request enhances the library bundler pipeline to maintain shared chunk consistency during watch mode rebuilds and improves path resolution in the memory file loader plugin, including handling trailing slashes, Windows drive-letter paths, and preferring .d.mts for .mjs specifiers. A high-severity issue was identified where partial rebuilds that only trigger ESM or DTS changes will fail to update bundleResults due to a strict check requiring both bundles to be present, which can lead to stale file cleanup issues or unnecessary full rebuilds.
…red chunk consistency - Strip trailing slashes when resolving relative directory imports in `createMemoryFileLoaderPlugin` so `./dir/` resolves `.../dir/index.js`. - Support `.cjs` and `.d.cts` extensions, and prioritize `.d.mts`/`.d.cts` before `.d.ts` when resolving explicit `.mjs`/`.cjs` specifiers in `.d.ts` mode. - Treat Windows drive-letter absolute paths (`/^[a-zA-Z]:\//`) as internal modules. - Fall back to on-disk declaration files in `.d.ts` mode for hand-authored ambient/declaration files not emitted into the in-memory `dtsFiles` map. - Re-bundle all entry points from in-memory outputs during partial watch rebuilds when previous bundle results contained shared chunks to prevent inlining shared code into a subset of entry points.
82efdc3 to
4e8c365
Compare
…tch shared chunk consistency
…tch shared chunk consistency
|
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
Fixes module resolution issues in
createMemoryFileLoaderPluginand ensures shared chunk consistency during partial watch-mode rebuilds in the@angular/build:librarybundler pipeline:import './dir/') before probing candidate extensions so.../dir/index.jsis resolved instead of.../dir//index.js..mjs->.d.mtsdeclaration preference: In.d.tsbundling mode, prefer.d.mtswhen an explicit.mjsspecifier is used and both.d.tsand.d.mtsexist.C:/...) as internal modules inresolveIdrather than marking them as external.fesm2022/shared-*.mjsortypes/shared-*.d.ts), expand the Rolldown invocation to include all entry points present in the in-memoryesmFiles/dtsFilesmaps and updatebundleResultsfor all bundled entry points so shared chunk hashes and stale file cleanup remain consistent.