Skip to content

fix(@angular/build): improve library bundler resolution and watch shared chunk consistency - #34440

Draft
alan-agius4 wants to merge 3 commits into
angular:mainfrom
alan-agius4:fix/library-bundler-memory-loader
Draft

alan-agius4 wants to merge 3 commits into
angular:mainfrom
alan-agius4:fix/library-bundler-memory-loader

Conversation

@alan-agius4

@alan-agius4 alan-agius4 commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes module resolution issues in createMemoryFileLoaderPlugin and ensures shared chunk consistency during partial watch-mode rebuilds in the @angular/build:library bundler pipeline:

  • Trailing slash normalization: Strip trailing slashes from relative directory specifiers (import './dir/') before probing candidate extensions so .../dir/index.js is resolved instead of .../dir//index.js.
  • .mjs -> .d.mts declaration preference: In .d.ts bundling mode, prefer .d.mts when an explicit .mjs specifier is used and both .d.ts and .d.mts exist.
  • Windows drive-letter paths: Recognize normalized POSIX paths with Windows drive letters (C:/...) as internal modules in resolveId rather than marking them as external.
  • Watch-mode shared chunk consistency: When a partial watch rebuild includes entry points that previously emitted shared chunks (fesm2022/shared-*.mjs or types/shared-*.d.ts), expand the Rolldown invocation to include all entry points present in the in-memory esmFiles / dtsFiles maps and update bundleResults for all bundled entry points so shared chunk hashes and stale file cleanup remain consistent.

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant