fix(@angular/build): conditionally declare tslib in built library package - #34227
Open
alan-agius4 wants to merge 4 commits into
Open
alan-agius4 wants to merge 4 commits into
alan-agius4 wants to merge 4 commits into
Conversation
…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
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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). Whentslibis imported and not already declared in the library'spackage.jsondependencies, resolves thetslibversion range from@angular/compiler(with fallback totslib/package.json) and adds it to the emittedpackage.json.Closes #34131