forwardRef for component scopes (#46139)
Angular generally supports cycles between components in the same NgModule. We have a mechanism of moving the component scope declaration into the NgModule file in this case. This ensures that Angular never itself introduces an import which creates a cycle. What happens if the cycle already exists in the user's program, though, is a bit different. In these cases, the "correct" emit for Angular is to generate the component scope (whether direct or remote) inside of a closure, to prevent evaluating the scope's references until module evaluation is complete and all cyclic imports have been resolved. We don't want to do this for *all* scopes because the code size cost of emitting a function wrapper is non-zero. In this fix, we take the presence of a `forwardRef` in a component's `imports` or in an NgModule `declarations` or `imports` as a sign that component scopes emitted into those files need to be protected against cyclic references. In a future commit, we may introduce a warning or error if cyclic imports are not protected behind `forwardRef` in these cases, but this will take some time to implement. PR Close #46139
Angular - The modern web developer's platform.
Angular is a development platform for building mobile and desktop web applications
using Typescript/JavaScript and other languages.
Contributing Guidelines
·
Submit an Issue
·
Blog
Documentation
Get started with Angular, learn the fundamentals and explore advanced topics on our documentation website.
Advanced
Development Setup
Prerequisites
- Install Node.js which includes Node Package Manager
Setting Up a Project
Install the Angular CLI globally:
npm install -g @angular/cli
Create workspace:
ng new [PROJECT NAME]
Run the application:
cd [PROJECT NAME]
ng serve
Angular is cross-platform, fast, scalable, has incredible tooling, and is loved by millions.
Quickstart
Ecosystem
Changelog
Learn about the latest improvements.
Upgrading
Check out our upgrade guide to find out the best way to upgrade your project.
Contributing
Contributing Guidelines
Read through our contributing guidelines to learn about our submission process, coding rules and more.
Want to Help?
Want to report a bug, contribute some code, or improve documentation? Excellent! Read up on our guidelines for contributing and then check out one of our issues labeled as help wanted or good first issue.
Code of Conduct
Help us keep Angular open and inclusive. Please read and follow our Code of Conduct.
Community
Join the conversation and help the community.
Love Angular? Give our repo a star ⭐ ⬆️.
