Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): collect providers from NgModules while rendering @defer block #52881

Closed
wants to merge 2 commits into from

Conversation

AndrewKushnir
Copy link
Contributor

Currently, when a @defer block contains standalone components that import NgModules with providers, those providers are not available to components declared within the same NgModule. The problem is that the standalone injector is not created for the host component (that hosts this @defer block), since dependencies become defer-loaded, thus no information is available at host component creation time.

This commit updates the logic to collect all providers from all NgModules used as a dependency for standalone components used within a @defer block. When an instance of a defer block is created, a new environment injector instance with those providers is created.

Resolves #52876.

PR Type

What kind of change does this PR introduce?

  • Bugfix

Does this PR introduce a breaking change?

  • Yes
  • No

@AndrewKushnir AndrewKushnir added area: core Issues related to the framework runtime target: patch This PR is targeted for the next patch release core: defer Issues related to @defer blocks. labels Nov 14, 2023
@ngbot ngbot bot modified the milestone: Backlog Nov 14, 2023
@AndrewKushnir AndrewKushnir force-pushed the defer_fix_52876 branch 2 times, most recently from 473d4e6 to da5e81f Compare November 15, 2023 02:02
@AndrewKushnir AndrewKushnir added the action: review The PR is still awaiting reviews from at least one requested reviewer label Feb 2, 2024
@AndrewKushnir AndrewKushnir marked this pull request as ready for review February 2, 2024 17:46
@AndrewKushnir AndrewKushnir force-pushed the defer_fix_52876 branch 2 times, most recently from a36117e to 3138f09 Compare February 2, 2024 23:52
@AndrewKushnir
Copy link
Contributor Author

Presubmit.

packages/core/src/defer/instructions.ts Outdated Show resolved Hide resolved
packages/core/src/defer/interfaces.ts Outdated Show resolved Hide resolved
packages/core/test/acceptance/defer_spec.ts Show resolved Hide resolved
…block

Currently, when a `@defer` block contains standalone components that import NgModules with providers, those providers are not available to components declared within the same NgModule. The problem is that the standalone injector is not created for the host component (that hosts this `@defer` block), since dependencies become defer-loaded, thus no information is available at host component creation time.

This commit updates the logic to collect all providers from all NgModules used as a dependency for standalone components used within a `@defer` block. When an instance of a defer block is created, a new environment injector instance with those providers is created.

Resolves angular#52876.
@AndrewKushnir AndrewKushnir added action: presubmit The PR is in need of a google3 presubmit and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Feb 23, 2024
@AndrewKushnir
Copy link
Contributor Author

Presubmit #2.

@AndrewKushnir AndrewKushnir added action: merge The PR is ready for merge by the caretaker action: presubmit The PR is in need of a google3 presubmit and removed action: presubmit The PR is in need of a google3 presubmit labels Feb 23, 2024
@dylhunn
Copy link
Contributor

dylhunn commented Feb 23, 2024

This PR was merged into the repository by commit dcb9deb.

@dylhunn dylhunn closed this in dcb9deb Feb 23, 2024
dylhunn pushed a commit that referenced this pull request Feb 23, 2024
…block (#52881)

Currently, when a `@defer` block contains standalone components that import NgModules with providers, those providers are not available to components declared within the same NgModule. The problem is that the standalone injector is not created for the host component (that hosts this `@defer` block), since dependencies become defer-loaded, thus no information is available at host component creation time.

This commit updates the logic to collect all providers from all NgModules used as a dependency for standalone components used within a `@defer` block. When an instance of a defer block is created, a new environment injector instance with those providers is created.

Resolves #52876.

PR Close #52881
@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 Mar 25, 2024
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 core: defer Issues related to @defer blocks. target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

defer loading a component with NgModule with providers throws error
3 participants