Skip to content

fix(core): update unknown tag error for jit standalone components#45920

Closed
dario-piotrowicz wants to merge 7 commits intoangular:mainfrom
dario-piotrowicz:unknown-tag-in-standalone-component-jit
Closed

fix(core): update unknown tag error for jit standalone components#45920
dario-piotrowicz wants to merge 7 commits intoangular:mainfrom
dario-piotrowicz:unknown-tag-in-standalone-component-jit

Conversation

@dario-piotrowicz
Copy link
Contributor

@dario-piotrowicz dario-piotrowicz commented May 8, 2022

update the error message presented during jit compilation when an unrecognized
tag/element is found in a standalone component so that it does not mention
the ngModule anymore

Note: the aot variant is present in PR #45919

resolves #45818

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature (may be a bugfix)
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

Issue

Issue Number: #45818

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Result:
JIT

@dario-piotrowicz dario-piotrowicz marked this pull request as ready for review May 8, 2022 09:05
@pullapprove pullapprove bot requested a review from atscott May 8, 2022 09:05
@dario-piotrowicz
Copy link
Contributor Author

I wanted to add unit tests for this, but it does not seem like there are any unit tests regarding this sort of functionality, please let me know if I should add some somewhere

(I may be wrong but I imagine that jit is almost deprecated in favour of aot? so maybe that's why unit testing functionalities here is not as important?)

@pkozlowski-opensource pkozlowski-opensource added area: compiler Issues related to `ngc`, Angular's template compiler cross-cutting: standalone Issues related to the NgModule-less world labels May 9, 2022
@ngbot ngbot bot modified the milestone: Backlog May 9, 2022
@atscott atscott requested review from pkozlowski-opensource and removed request for atscott May 9, 2022 19:39
@AndrewKushnir
Copy link
Contributor

AndrewKushnir commented May 10, 2022

@dario-piotrowicz thanks for creating this PR! I think we should try to use the approach proposed by Joost (in #45818 (comment)) vs adding a flag to the TView. Since this information is not needed anywhere other than the error message, we'd be able to tree-shake away that code in prod bundles (unlike the changes in TView, which would not be tree-shakable).

Quick comment: let's update the commit message to say fix(core): ..., since this is the fix to the error message, which looks incorrect in a context of standalone components (the second PR can be marked as a fix as well).

@AndrewKushnir AndrewKushnir added action: review The PR is still awaiting reviews from at least one requested reviewer target: rc This PR is targeted for the next release-candidate labels May 10, 2022
@pkozlowski-opensource
Copy link
Member

@dario-piotrowicz yes, I still believe that we should add relevant tests for the JIT case to exercise changes to packages/core/src/render3/instructions/element.ts. As for the test location I've suggested on in my previous comment #45818 (comment)

@dario-piotrowicz
Copy link
Contributor Author

@AndrewKushnir @pkozlowski-opensource Thank you very much 🙂

I'll address all your comments this coming weekend, sorry that it's been a slow few days 😓

@dario-piotrowicz dario-piotrowicz force-pushed the unknown-tag-in-standalone-component-jit branch 3 times, most recently from 75be8dc to e1e19a3 Compare May 14, 2022 10:35
@dario-piotrowicz dario-piotrowicz changed the title feat(core): update unknown tag error for jit standalone components fix(core): update unknown tag error for jit standalone components May 14, 2022
@dario-piotrowicz dario-piotrowicz force-pushed the unknown-tag-in-standalone-component-jit branch 3 times, most recently from 6687d29 to 61fe62a Compare May 14, 2022 13:45
Comment on lines 63 to 66
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like we may need this logic in other error messages as we start to update them with standalone context more. I'd like to propose that we extract it to a separate function (for ex. isHostComponentStandalone and put it in render3/instructions/shared.ts file) and add a check like this:

!ngDevMode && throwError('Must never be called in production mode');

It should help avoid adding this relatively slow path into the perf-sensitive code (like change detection). If we come across a situation when we need similar detection in the non-dev mode, we'd need to re-consider adding a flag to the TView (as it was implemented originally in this PR).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sounds good! 🙂👍

I actually did think of creating a function for this piece of code but I was afraid of overengineer things 😅

Choose a reason for hiding this comment

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

Agree with @AndrewKushnir - we should have a utility function here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added the isHostComponentStandalone function please have a look 🙂

(by the way, seems like the other functions in the shared file don't have unit tests associated to them, what do you think should I add one for the new function? if so could you suggest a file? 🙏)


Also, would it be worth it to also extract this two lines into another function?

  const declarationLView = lView[DECLARATION_COMPONENT_VIEW] as LView<Type<unknown>>;
  const context = declarationLView[CONTEXT];

(something like getLViewContext or something along those lines), let me know if this is a good idea and in that case if you'd like me to do it here or in a separate PR 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AndrewKushnir , @pkozlowski-opensource any comment on this one? 🙂

@dario-piotrowicz dario-piotrowicz force-pushed the unknown-tag-in-standalone-component-jit branch from 61fe62a to 5804f98 Compare May 16, 2022 22:07
@AndrewKushnir
Copy link
Contributor

Presubmit.

@AndrewKushnir AndrewKushnir added action: merge The PR is ready for merge by the caretaker and removed action: presubmit The PR is in need of a google3 presubmit labels May 21, 2022
AndrewKushnir pushed a commit to dario-piotrowicz/angular that referenced this pull request May 21, 2022
…ents

update the error message presented during aot compilation when an unrecognized
tag/element is found in a standalone component so that it does not mention
the ngModule anymore

Note: the jit variant is present in PR angular#45920

resolves angular#45818
@alxhub
Copy link
Member

alxhub commented May 23, 2022

This PR was merged into the repository by commit b1a4b30.

alxhub pushed a commit that referenced this pull request May 23, 2022
…5920)

update the error message presented during jit compilation when an unrecognized
tag/element is found in a standalone component so that it does not mention
the ngModule anymore

Note: the aot variant is present in PR #45919

resolves #45818

PR Close #45920
@alxhub alxhub closed this in b1a4b30 May 23, 2022
alxhub pushed a commit that referenced this pull request May 23, 2022
…ents (#45919)

update the error message presented during aot compilation when an unrecognized
tag/element is found in a standalone component so that it does not mention
the ngModule anymore

Note: the jit variant is present in PR #45920

resolves #45818

PR Close #45919
alxhub pushed a commit that referenced this pull request May 23, 2022
…ents (#45919)

update the error message presented during aot compilation when an unrecognized
tag/element is found in a standalone component so that it does not mention
the ngModule anymore

Note: the jit variant is present in PR #45920

resolves #45818

PR Close #45919
@dario-piotrowicz dario-piotrowicz deleted the unknown-tag-in-standalone-component-jit branch June 3, 2022 13:32
@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 Jul 4, 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.

Update error message for an unknown tag in standalone components

4 participants