Skip to content

fix(core): handle AOT-compiled standalone components in TestBed correctly#46052

Closed
AndrewKushnir wants to merge 1 commit intoangular:mainfrom
AndrewKushnir:testbed_standalone_fix
Closed

fix(core): handle AOT-compiled standalone components in TestBed correctly#46052
AndrewKushnir wants to merge 1 commit intoangular:mainfrom
AndrewKushnir:testbed_standalone_fix

Conversation

@AndrewKushnir
Copy link
Contributor

Previously, the code in TestBed didn't take into account the fact that the cmp.dependencies array after the AOT compilation might contain regular (NgModule-based) Components/Directive/Pipes. As a result, some NgModule-specific code paths were invoked for non-NgModule types, thus leading to errors.

This commit updates the code to handle AOT-compiled structure of standalone components correctly.

PR Type

What kind of change does this PR introduce?

  • Bugfix

Does this PR introduce a breaking change?

  • Yes
  • No

…ctly

Previously, the code in TestBed didn't take into account the fact that the `cmp.dependencies` array after the AOT compilation might contain regular (NgModule-based) Components/Directive/Pipes. As a result, some NgModule-specific code paths were invoked for non-NgModule types, thus leading to errors.

This commit updates the code to handle AOT-compiled structure of standalone components correctly.
@AndrewKushnir AndrewKushnir added action: review The PR is still awaiting reviews from at least one requested reviewer area: core Issues related to the framework runtime target: rc This PR is targeted for the next release-candidate labels May 19, 2022
@ngbot ngbot bot added this to the Backlog milestone May 19, 2022
@AndrewKushnir
Copy link
Contributor Author

AndrewKushnir commented May 19, 2022

Initial presubmit + TGP.

@pkozlowski-opensource pkozlowski-opensource added the cross-cutting: standalone Issues related to the NgModule-less world label May 19, 2022
const def = getComponentDef(value);
queueTypesFromModulesArrayRecur(maybeUnwrapFn(def.dependencies ?? []));
const dependencies = maybeUnwrapFn(def.dependencies ?? []);
dependencies.forEach((dependency) => {
Copy link
Member

Choose a reason for hiding this comment

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

Prefer for...of loops

@AndrewKushnir AndrewKushnir added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels May 19, 2022
@AndrewKushnir
Copy link
Contributor Author

AndrewKushnir commented May 19, 2022

Thanks for the review @alxhub 👍
The TGP is fully "green", so I'll mark this PR for merge as is (to avoid invalidating the result) and will address the for..of comment in a separate PR (may be combined with other refactoring).

@alxhub
Copy link
Member

alxhub commented May 23, 2022

This PR was merged into the repository by commit dfba192.

@alxhub alxhub closed this in dfba192 May 23, 2022
alxhub pushed a commit that referenced this pull request May 23, 2022
…ctly (#46052)

Previously, the code in TestBed didn't take into account the fact that the `cmp.dependencies` array after the AOT compilation might contain regular (NgModule-based) Components/Directive/Pipes. As a result, some NgModule-specific code paths were invoked for non-NgModule types, thus leading to errors.

This commit updates the code to handle AOT-compiled structure of standalone components correctly.

PR Close #46052
@angular-automatic-lock-bot
Copy link

This issue 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 Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: core Issues related to the framework runtime cross-cutting: standalone Issues related to the NgModule-less world target: rc This PR is targeted for the next release-candidate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants