Skip to content

feat(ivy): Add AOT handling for bare classes with Input and Output de…#25367

Closed
benlesh wants to merge 3 commits into
angular:masterfrom
benlesh:ivy-aot-basedef
Closed

feat(ivy): Add AOT handling for bare classes with Input and Output de…#25367
benlesh wants to merge 3 commits into
angular:masterfrom
benlesh:ivy-aot-basedef

Conversation

@benlesh
Copy link
Copy Markdown
Contributor

@benlesh benlesh commented Aug 7, 2018

…corators

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x] Feature
[ ] 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:

What is the current behavior?

Currently, ivy does not handle inheritance properly via AOt in situations where a base class has @Input or @Output properties, but no @Component or @Directive decorator on the class.

Issue Number: N/A

What is the new behavior?

The AOT compiler will add ngBaseDef static property, but only when appropriate.

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

Related to #25129

@benlesh benlesh added target: major This PR is targeted for the next major release action: review The PR is still awaiting reviews from at least one requested reviewer labels Aug 7, 2018
@mary-poppins
Copy link
Copy Markdown

You can preview 093ce73 at https://pr25367-093ce73.ngbuilds.io/.

@benlesh benlesh removed the action: review The PR is still awaiting reviews from at least one requested reviewer label Aug 7, 2018
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we really break here, wouldn't that mean any remaining inputs/outputs won't be collected?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oops, thanks, that was left over from a previous pass. Adding an additional test as well.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should test their imported module is angular core.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yep

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How about HostBinding/HostListener? Shouldn't they be included in the base definition just as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That work is separate.

@mary-poppins
Copy link
Copy Markdown

You can preview 1d6e431 at https://pr25367-1d6e431.ngbuilds.io/.

@mary-poppins
Copy link
Copy Markdown

You can preview 7c7a5dd at https://pr25367-7c7a5dd.ngbuilds.io/.

@mary-poppins
Copy link
Copy Markdown

You can preview ea4c153 at https://pr25367-ea4c153.ngbuilds.io/.

@mary-poppins
Copy link
Copy Markdown

You can preview 2f18bb5 at https://pr25367-2f18bb5.ngbuilds.io/.

@mary-poppins
Copy link
Copy Markdown

You can preview 462358c at https://pr25367-462358c.ngbuilds.io/.

@benlesh
Copy link
Copy Markdown
Contributor Author

benlesh commented Aug 8, 2018

@benlesh benlesh added the action: review The PR is still awaiting reviews from at least one requested reviewer label Aug 8, 2018
@benlesh benlesh requested a review from alxhub August 8, 2018 22:29
@trotyl
Copy link
Copy Markdown
Contributor

trotyl commented Aug 9, 2018

if (!constructor.hasOwnProperty('ngBaseDef')) {

Possibly fix this as well? ngBaseDef is minifiable.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Import should not be deep. It can be added to the ../../ngtsc/annotations import above.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you convince the auto-formatter to format this in a more readable way?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I believe this field should become match: M.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

"let that DecoratorHandler handle this."

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Don't cast it to a string, check if it is a string and throw if it isn't.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Rename decorator to metadata - it should also be of type M.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Remove.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oops. :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

expect(result.source).not.toContain('ngBaseDef')

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

@alxhub
Copy link
Copy Markdown
Member

alxhub commented Aug 9, 2018

Nice work, this looks generally good. Just a few comments to address and then I'll approve it.

@mary-poppins
Copy link
Copy Markdown

You can preview c9015dc at https://pr25367-c9015dc.ngbuilds.io/.

@mary-poppins
Copy link
Copy Markdown

You can preview 70b1b83 at https://pr25367-70b1b83.ngbuilds.io/.

/**
* Used to get the minified alias of ngBaseDef
*/
const NG_BASE_DEF = Object.keys({ngBaseDef: true})[0];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not const NG_BASE_DEF = 'ngBaseDef' directly?

Copy link
Copy Markdown
Member

@JoostK JoostK Aug 12, 2018

Choose a reason for hiding this comment

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

@alan-agius4 For Closure Compiler, which may minify the ngBaseDef property to something else. Literal strings however won't be affected by this minification step, so it is actually used as a property here for it to undergo the same minification procedure.

In other parts of the code base a function getClosureSafeProperty is used for the same purpose. That makes this more explicit, but I actually like what @benlesh has done here as it's much shorter.

Copy link
Copy Markdown
Contributor

@alan-agius4 alan-agius4 Aug 12, 2018

Choose a reason for hiding this comment

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

@JoostK, I see, interesting :) Thanks for the explanation.

@mary-poppins
Copy link
Copy Markdown

You can preview 0abdcbd at https://pr25367-0abdcbd.ngbuilds.io/.

@mary-poppins
Copy link
Copy Markdown

You can preview f1cbae0 at https://pr25367-f1cbae0.ngbuilds.io/.

@benlesh benlesh added the action: merge The PR is ready for merge by the caretaker label Aug 14, 2018
@ngbot
Copy link
Copy Markdown

ngbot Bot commented Aug 14, 2018

I see that you just added the PR action: merge label, but the following checks are still failing:
    failure forbidden label detected: PR action: review
    pending status "code-review/pullapprove" is pending

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.

@benlesh benlesh closed this in a0a29fd Aug 14, 2018
@angular-automatic-lock-bot
Copy link
Copy Markdown

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 Sep 13, 2019
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 action: review The PR is still awaiting reviews from at least one requested reviewer cla: yes target: major This PR is targeted for the next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants