fix(angular): process only the in progress entry points in ng-packagr-lite's write bundles transform function#33784
Merged
leosvelperez merged 1 commit intomasterfrom Dec 10, 2025
Merged
Conversation
…-lite's write bundles transform function
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
✅ Deploy Preview for nx-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
|
View your CI Pipeline Execution ↗ for commit 65295b7
☁️ Nx Cloud last updated this comment at |
Coly010
approved these changes
Dec 10, 2025
FrozenPandaz
pushed a commit
that referenced
this pull request
Dec 15, 2025
…-lite's write bundles transform function (#33784) ## Current Behavior When building Angular libraries with `ng-packagr` >20.3.0, the build fails with: ```bash TypeError: Cannot read properties of undefined (reading 'outputCache') ``` This occurs because `ng-packagr` v20.3.1 introduced a memory optimization ([ng-packagr#3172](ng-packagr/ng-packagr#3172)) that calls `dispose()` on entry points after they're processed, setting `entry.cache = undefined`. Nx's custom `writeBundlesTransform` was iterating over **all** entries in the graph, including already-disposed entry points, causing the crash when accessing their cache. ## Expected Behavior Angular library builds should succeed with `ng-packagr` >20.3.0, including libraries with secondary entry points. Workspaces using lower versions of `ng-packagr` should remain unaffected. ## Solution Align with `ng-packagr`'s own pattern by using `graph.find(isEntryPointInProgress())` to process only the currently in-progress entry point, rather than iterating over all graph entries. **Key changes:** - Use `isEntryPointInProgress()` instead of iterating all entries with `isEntryPoint()` - Remove unused `BuildGraph` import (no longer creating a new graph) - Update package node only when processing the primary entry point (more efficient) - Return nothing from the transform (original graph passes through, same as ng-packagr) This approach: - Matches `ng-packagr`'s `writeBundlesTransform` implementation pattern - Only accesses cache of the in-progress entry point (guaranteed not to be disposed) - Works with all supported `ng-packagr` versions (v19+) since `isEntryPointInProgress()` has been available since v19 ## Related Issue(s) Fixes #33560
Contributor
|
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Current Behavior
When building Angular libraries with
ng-packagr>20.3.0, the build fails with:This occurs because
ng-packagrv20.3.1 introduced a memory optimization (ng-packagr#3172) that callsdispose()on entry points after they're processed, settingentry.cache = undefined.Nx's custom
writeBundlesTransformwas iterating over all entries in the graph, including already-disposed entry points, causing the crash when accessing their cache.Expected Behavior
Angular library builds should succeed with
ng-packagr>20.3.0, including libraries with secondary entry points. Workspaces using lower versions ofng-packagrshould remain unaffected.Solution
Align with
ng-packagr's own pattern by usinggraph.find(isEntryPointInProgress())to process only the currently in-progress entry point, rather than iterating over all graph entries.Key changes:
isEntryPointInProgress()instead of iterating all entries withisEntryPoint()BuildGraphimport (no longer creating a new graph)This approach:
ng-packagr'swriteBundlesTransformimplementation patternng-packagrversions (v19+) sinceisEntryPointInProgress()has been available since v19Related Issue(s)
Fixes #33560