Skip to content

feat(@angular/build): support patterns in library entryPoints - #34127

Closed
thekhegay wants to merge 3 commits into
angular:mainfrom
thekhegay:library-entry-point-patterns
Closed

thekhegay wants to merge 3 commits into
angular:mainfrom
thekhegay:library-entry-point-patterns

Conversation

@thekhegay

Copy link
Copy Markdown
Contributor

PR Checklist

Please check to confirm your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.dev application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

This is on top of #34106, which adds @angular/build:library, so there is nothing to merge it into yet and only the last commit is new. Draft until #34106 lands. cc @alan-agius4

Follow-up to #34106 (comment). entryPoints lists every entry point by hand, so a library with many of them keeps a copy of its folder layout in angular.json, and an entry point missing from it is not published without any error.

Issue Number: N/A

What is the new behavior?

A key and its entry file path can each contain one *, as with subpath patterns in package.json exports:

"entryPoints": {
  ".": "projects/lib/public-api.ts",
  "./*": "projects/lib/*/public-api.ts"
}

* matches any non-empty part of the path, including /, so nested entry points are picked up too. Explicit entries take precedence over a pattern match with the same name or the same file, which also allows renaming one or giving it its own tsConfig. A pattern that matches no files is an error. Patterns are expanded once when the build starts.

On ngwr (228 entry points, 99 of them nested) these two lines replace a 230-line map, the output is identical to the build with the explicit map, and the expansion takes ~10 ms.

Does this PR introduce a breaking change?

  • Yes
  • No

alan-agius4 and others added 3 commits September 19, 2026 08:59
Add a new native `@angular/build:library` builder providing a modern, high-performance compilation and packaging pipeline.
A key and its entry file path in `entryPoints` can each contain one `*`,
as with subpath patterns in package.json `exports`. For example
`"./*": "projects/lib/*/public-api.ts"` adds an entry point for every
matching file, with the matched part of the path, which can include `/`,
used in the key.

Explicit entry points take precedence over a pattern match with the same
name or the same entry file, and a pattern that matches no files is an
error. Patterns are expanded when the build starts.
@alan-agius4

Copy link
Copy Markdown
Collaborator

Appreciate your contribution! Let's circle back to this after we get the initial API out the door.

@thekhegay

Copy link
Copy Markdown
Contributor Author

@alan-agius4 circling back on this now that builder is out in 22.3.0-next

Since entry points moved to library package.json exports, pattern there is just Node syntax and nothing new to configure in angular.json
Right now "./*": "./*/public-api.ts" in exports fails with TS6053 for projects/lib/*/public-api.ts, * is taken as literal path

I redid it on top of main, pattern keys with .ts target get expanded to explicit subpaths before entry points are normalized
Rules are same as Node uses for exports: exact subpath wins over patern and most specific pattern wins, so "./*/internal": null can drop internal barrels
Pattern that matches nothing fails build
Built package.json still lists every entry point explicitly, so what gets published stays visible
On ngwr exports goes from 227 keys to 32 and dist is byte identical to build from explicit map with same 227 keys in expansion order

main...thekhegay:angular-cli:library-export-patterns

Should I open it as new PR, or better wait until builder settles?

@alan-agius4

Copy link
Copy Markdown
Collaborator

Thanks for following up, @thekhegay.

For now, we'd prefer to hold off on supporting subpath patterns/globs for library entry points. Our main concern is that wildcard expansion makes it easy to accidentally expose new public entry points simply by adding a matching file on disk, rather than intentionally declaring public API subpaths in package.json.

Let's keep entry point definitions explicit for now while the new library builder stabilizes, and we can revisit this in the future if we see significant demand from the community.

@thekhegay

Copy link
Copy Markdown
Contributor Author

@alan-agius4 Makes sense, thanks for looking into it. Will keep explicit map on ngwr for now

@angular-automatic-lock-bot

Copy link
Copy Markdown

This pull request has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Nov 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area: @angular/build detected: feature PR contains a feature commit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants