Skip to content

verify standalone component imports and declarations in JiT#45777

Closed
pkozlowski-opensource wants to merge 2 commits intoangular:masterfrom
pkozlowski-opensource:standalone_jit_verifications
Closed

verify standalone component imports and declarations in JiT#45777
pkozlowski-opensource wants to merge 2 commits intoangular:masterfrom
pkozlowski-opensource:standalone_jit_verifications

Conversation

@pkozlowski-opensource
Copy link
Member

@pkozlowski-opensource pkozlowski-opensource commented Apr 27, 2022

2 commits with JiT verifications:

  • what can be imported into a standalone component;
  • standalone entities are not declared in any NgModule.

@pkozlowski-opensource pkozlowski-opensource added target: minor This PR is targeted for the next minor release action: review The PR is still awaiting reviews from at least one requested reviewer area: core Issues related to the framework runtime labels Apr 27, 2022
@ngbot ngbot bot added this to the Backlog milestone Apr 27, 2022
@pkozlowski-opensource pkozlowski-opensource changed the title fix(core): verify standalone component imports in JiT verify standalone component imports and declarations in JiT Apr 27, 2022
Copy link
Member

@JoostK JoostK left a comment

Choose a reason for hiding this comment

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

LGTM; I do wonder though if we've got the same error checking in the AOT compiler.

This commits adds verifications assuring that items imported into
standalone components are one of:
- standalone component / directive / pipe;
- NgModule;
- forwardRef resolving to one of the above.
It explicitly disallows modules with providers.
…gModule

This commits adds JiT checks to verify that a standalone component, directive,
pipe are not declared in any NgModule.
@pkozlowski-opensource pkozlowski-opensource force-pushed the standalone_jit_verifications branch from 261ac4c to 74a3ccc Compare April 27, 2022 18:09
Copy link
Contributor

@AndrewKushnir AndrewKushnir left a comment

Choose a reason for hiding this comment

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

👍

Comment on lines +202 to +203
stringifyForError(importingType)}", to return a standalone entity or NgModule but got "${
stringifyForError(depType) || depType}".`);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
stringifyForError(importingType)}", to return a standalone entity or NgModule but got "${
stringifyForError(depType) || depType}".`);
stringifyForError(importingType)}", to return a standalone entity or an NgModule but got "${
stringifyForError(depType) || depType}".`);

Quick question: do we need the || depType here?

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't strictly need it but I did it for cases where something funky (null / undefined or '') ends up there. So yeh, not necessary but shouldn't do any harm either.

Copy link
Contributor

@AndrewKushnir AndrewKushnir Apr 27, 2022

Choose a reason for hiding this comment

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

False-y values will be handled by the underlying renderStringify function, so we should not need it (I'm ok to keep it as well :)).

Copy link
Member Author

Choose a reason for hiding this comment

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

yeh, but renderStringify would convert, say undefined to an empty string and we wouldn't see it in the error message. I think that it would be preferable to see undefined in the error message.

Again, those are minor details.

@AndrewKushnir
Copy link
Contributor

Presubmit.

@AndrewKushnir AndrewKushnir added action: presubmit The PR is in need of a google3 presubmit 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 action: presubmit The PR is in need of a google3 presubmit labels Apr 27, 2022
@dylhunn
Copy link
Contributor

dylhunn commented Apr 27, 2022

This PR was merged into the repository by commit 2f5fd41.

@dylhunn dylhunn closed this in aafac72 Apr 27, 2022
dylhunn pushed a commit that referenced this pull request Apr 27, 2022
…gModule (#45777)

This commits adds JiT checks to verify that a standalone component, directive,
pipe are not declared in any NgModule.

PR Close #45777
@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 May 29, 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 target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants