Repository navigation
fix(@angular/build): resolve unimported NgModule scopes when filtering unit-test files - #34329
Merged
dgp1130 merged 1 commit intoOct 14, 2026
Merged
Conversation
…g unit-test files When `rootFiles` overrides are provided (such as during `unit-test` runs), the initial TypeScript program is restricted to those entry points and their transitive imports. If a test imports a non-standalone `@Component` directly without importing its declaring `@NgModule`, the `NgModule` may be omitted from the program and leave the component without its compilation scope. Preserve the full `tsconfig` root file set as `fallbackRootNames` for application builds when `rootFiles` is a subset of the `tsconfig` files. If AOT analysis detects a non-standalone component lacking an owning `NgModule` scope (`getOwningNgModule(component) === null`) and additional uncompiled `tsconfig` files exist, recreate and re-analyze the Angular program with the full root file set so all `NgModule` declarations can be discovered.
clydin
force-pushed
the
fix/unit-test-ngmodule-scope-fallback
branch
from
October 13, 2026 16:56
6be51ea to
957de2a
Compare
clydin
marked this pull request as ready for review
October 13, 2026 18:47
There was a problem hiding this comment.
Code Review
This pull request introduces a fallback mechanism to the full tsconfig root file set (fallbackRootNames) during AOT compilation when explicit rootFiles filtering is active. This fallback is triggered if a non-standalone component is encountered that lacks a resolved NgModule scope, allowing the Angular compiler to discover all NgModules and resolve component compilation scopes. Unit tests have been added to verify this behavior. I have no additional feedback to provide as there are no review comments.
1 task done
alan-agius4
approved these changes
Oct 14, 2026
Collaborator
|
This PR was merged into the repository. The changes were merged into the following branches:
|
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.
When
rootFilesoverrides are provided (such as duringunit-testruns), the initial TypeScript program is restricted to those entry points and their transitive imports. If a test imports a non-standalone@Componentdirectly without importing its declaring@NgModule, theNgModulemay be omitted from the program and leave the component without its compilation scope.Preserve the full
tsconfigroot file set asfallbackRootNamesfor application builds whenrootFilesis a subset of thetsconfigfiles. If AOT analysis detects a non-standalone component lacking an owningNgModulescope (getOwningNgModule(component) === null) and additional uncompiledtsconfigfiles exist, recreate and re-analyze the Angular program with the full root file set so allNgModuledeclarations can be discovered.