Skip to content

fix(@angular/build): conditionally declare tslib in built library package - #34227

Open
alan-agius4 wants to merge 4 commits into
angular:mainfrom
alan-agius4:fix/library-tslib-dependency
Open

alan-agius4 wants to merge 4 commits into
angular:mainfrom
alan-agius4:fix/library-tslib-dependency

Conversation

@alan-agius4

Copy link
Copy Markdown
Collaborator

Inspects Rolldown output chunk imports to detect whether any generated library bundle imports tslib (for example, when custom decorators or explicit resource management helpers are emitted). When tslib is imported and not already declared in the library's package.json dependencies, resolves the tslib version range from @angular/compiler (with fallback to tslib/package.json) and adds it to the emitted package.json.

Closes #34131

…kage

Inspects Rolldown output chunk imports to detect whether any generated library bundle imports `tslib` (for example, when custom decorators or explicit resource management helpers are emitted). When `tslib` is imported and not already declared in the library's `package.json` `dependencies`, resolves the `tslib` version range from `@angular/compiler` (with fallback to `tslib/package.json`) and adds it to the emitted `package.json`.

Closes angular#34131

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the library builder pipeline to automatically and conditionally inject tslib into the generated package.json dependencies when any output chunks import it, while preserving any user-defined tslib versions. It also ensures this dependency is correctly updated during watch mode when imports change. The feedback suggests a minor improvement to use a standard file path like package.json instead of a directory path with a trailing slash when initializing createRequire for better robustness.

Comment thread packages/angular/build/src/builders/library/pipeline/package-manifests.ts Outdated
@alan-agius4
alan-agius4 requested a review from clydin October 1, 2026 08:22
@alan-agius4 alan-agius4 added target: minor This PR is targeted for the next minor release action: review The PR is still awaiting reviews from at least one requested reviewer labels Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: review The PR is still awaiting reviews from at least one requested reviewer area: @angular/build target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

library builder: tslib is not added to the output package.json

1 participant