Skip to content

fix(compiler-cli): report invalid imports in standalone components during resolve phase#45827

Closed
JoostK wants to merge 2 commits intoangular:mainfrom
JoostK:standalone-diagnostics
Closed

fix(compiler-cli): report invalid imports in standalone components during resolve phase#45827
JoostK wants to merge 2 commits intoangular:mainfrom
JoostK:standalone-diagnostics

Conversation

@JoostK
Copy link
Member

@JoostK JoostK commented Apr 30, 2022

The analysis phase of the compiler should operate on individual classes, independently
of other the analysis of other classes. The validation that Component.imports only
contains standalone entities or NgModules however did happen during the analysis phase,
introducing a dependency on other classes and causing inconsistencies due to ordering
and/or asynchronous timing differences.

This commit fixes the issue by moving the validation to the resolve phase, which occurs
after all classes have been analyzed.

Fixes #45819

@JoostK JoostK added area: compiler Issues related to `ngc`, Angular's template compiler target: minor This PR is targeted for the next minor release cross-cutting: standalone Issues related to the NgModule-less world labels Apr 30, 2022
@ngbot ngbot bot modified the milestone: Backlog Apr 30, 2022
@JoostK JoostK marked this pull request as ready for review April 30, 2022 11:18
@JoostK JoostK added the action: review The PR is still awaiting reviews from at least one requested reviewer label Apr 30, 2022
JoostK added 2 commits April 30, 2022 17:35
…ring resolve phase

The analysis phase of the compiler should operate on individual classes, independently
of the analysis of other classes. The validation that `Component.imports` only
contains standalone entities or NgModules however did happen during the analysis phase,
introducing a dependency on other classes and causing inconsistencies due to ordering
and/or asynchronous timing differences.

This commit fixes the issue by moving the validation to the resolve phase, which occurs
after all classes have been analyzed.

Fixes angular#45819
Changes the message from:

```
The component 'HelloComponent' appears in 'imports', but is not standalone
and cannot be imported directly It must be imported via an NgModule.
```
to

```
The component 'HelloComponent' appears in 'imports', but is not standalone
and cannot be imported directly. It must be imported via an NgModule.
```
@JoostK JoostK force-pushed the standalone-diagnostics branch from 0bc2af5 to 03b24e4 Compare April 30, 2022 15:35
@JoostK JoostK 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: review The PR is still awaiting reviews from at least one requested reviewer labels May 2, 2022
@ngbot
Copy link

ngbot bot commented May 2, 2022

I see that you just added the action: merge label, but the following checks are still failing:
    failure status "google3" is failing

If you want your PR to be merged, it has to pass all the CI checks.

If you can't get the PR to a green state due to flakes or broken master, please try rebasing to master and/or restarting the CI job. If that fails and you believe that the issue is not due to your change, please contact the caretaker and ask for help.

@AndrewKushnir
Copy link
Contributor

Presubmit.

@AndrewKushnir AndrewKushnir modified the milestones: Backlog, v14-candidates May 2, 2022
@AndrewKushnir AndrewKushnir removed the action: presubmit The PR is in need of a google3 presubmit label May 2, 2022
@dylhunn
Copy link
Contributor

dylhunn commented May 2, 2022

This PR was merged into the repository by commit 3ebf9e7.

@dylhunn dylhunn closed this in 9cfea3d May 2, 2022
dylhunn pushed a commit that referenced this pull request May 2, 2022
Changes the message from:

```
The component 'HelloComponent' appears in 'imports', but is not standalone
and cannot be imported directly It must be imported via an NgModule.
```
to

```
The component 'HelloComponent' appears in 'imports', but is not standalone
and cannot be imported directly. It must be imported via an NgModule.
```

PR Close #45827
@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 2, 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: compiler Issues related to `ngc`, Angular's template compiler cross-cutting: standalone Issues related to the NgModule-less world target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

standalone components: rebuild needed to avoid false positive NG2012

4 participants