Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: partial compilation of directives #39518

Closed
wants to merge 11 commits into from

Conversation

JoostK
Copy link
Member

@JoostK JoostK commented Oct 30, 2020

See individual commits.

@JoostK JoostK added feature Issue that requests a new feature state: WIP area: compiler Issues related to `ngc`, Angular's template compiler target: minor This PR is targeted for the next minor release labels Oct 30, 2020
@ngbot ngbot bot modified the milestone: needsTriage Oct 30, 2020
@google-cla google-cla bot added the cla: yes label Oct 30, 2020
@JoostK JoostK changed the title feat: linker compilation of directives feat: partial compilation of directives Oct 30, 2020
@JoostK JoostK marked this pull request as ready for review November 2, 2020 12:00
@JoostK JoostK added action: review The PR is still awaiting reviews from at least one requested reviewer and removed state: WIP labels Nov 2, 2020
Copy link
Member

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

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

Nice! I love how clean the whole PR feels. It is really easy to follow along with what it does.

// Version number of the metadata format. This is used to evolve the metadata
// interface later - the linker will be able to detect which version a library
// is using and interpret its metadata accordingly.
version: 1;
Copy link
Member

Choose a reason for hiding this comment

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

We talked about using the current framework version number here instead and then doing the checks via semantic version ranges at link time.

Copy link
Member

Choose a reason for hiding this comment

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

If we want to document different interfaces for different version ranges, then we could append something to the name of the interface... for example: R3DeclareDirectiveMetadata_from_11_1_0 or similar.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but doing that now would also require changes to the selector logic etc. which I felt was better left for another PR.

Copy link
Member

Choose a reason for hiding this comment

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

OK

packages/compiler/src/render3/partial/api.ts Outdated Show resolved Hide resolved
packages/compiler/src/render3/partial/api.ts Outdated Show resolved Hide resolved
@petebacondarwin
Copy link
Member

Also, I am not sure whether these commits should be feat or refactor... In any case, I think that the 3rd commit message should probably reworded slightly:

feat(compiler-cli): implement partial directive declaration linking 

This commit implements the logic to compile a partial declaration of a
directive into its full AOT compilation output.

@JoostK JoostK added this to In progress in ng-linker via automation Nov 2, 2020
@JoostK JoostK moved this from In progress to Review in progress in ng-linker Nov 2, 2020
Copy link
Member

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

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

LGTM!

meta.set(
'predicate', Array.isArray(query.predicate) ? asLiteral(query.predicate) : query.predicate);
meta.set('descendants', o.literal(query.descendants));
if (query.descendants) {
Copy link
Member

Choose a reason for hiding this comment

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

It appears that descendants is true for ViewChild, ViewChildren and ContentChild. Only ContentChildren sets it to false. I am not sure which combination of these is the most common. Do you?
If it is not clear-cut, I guess it is simpler to go with the default being false. At least from a position of least surprise.

Copy link
Member Author

Choose a reason for hiding this comment

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

I would guess that ViewChild is most common, but honestly I have no idea what the distribution actually is.

I did consider basically this question but then for the first flag, which I suspect is more often true than false. But it did indeed feel simpler/more consistent to go with false as a default here.

@petebacondarwin petebacondarwin added the action: presubmit The PR is in need of a google3 presubmit label Nov 2, 2020
Copy link
Contributor

@jessicajaniuk jessicajaniuk left a comment

Choose a reason for hiding this comment

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

This looks really clean to me! LGTM!

Copy link
Member

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

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

Reviewed-for: public-api

… prelink target

In PR angular#38938 an additional Bazel target was introduced for the compliance
tests, as preparation to run the compliance tests in partial compilation
mode and then apply the linker transform. The linker plugin itself was
not available at the time but has since been implemented, so this commit
updates the prelink target of the compliance tests to apply the linker
transform using the Babel plugin.

Actually emitting partial compilations to be transformed will be done in
follow-up work.
This commit implements partial code generation for directives, which
will be transformed by the linker plugin to fully AOT compiled code in
follow-up work.
This commit implements the logic to compile a partial declaration of a
directive into its full AOT compilation output.
…nent` to use `ɵɵ` prefix

For consistency with other generated code, the partial declaration
functions are renamed to use the `ɵɵ` prefix which indicates that it is
generated API.

This commit also removes the declaration from the public API golden
file, as it's not yet considered stable at this point. Once the linker
is finalized will these declaration function be included into the golden
file.
@AndrewKushnir
Copy link
Contributor

AndrewKushnir commented Nov 3, 2020

After changing $ng prefix to ɵɵng one it looks like public-api group approval is not needed for this PR.

@JoostK JoostK added 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 labels Nov 3, 2020
packages/compiler/src/render3/partial/api.ts Outdated Show resolved Hide resolved
goldens/public-api/core/core.d.ts Outdated Show resolved Hide resolved
@AndrewKushnir
Copy link
Contributor

Presubmit.

@AndrewKushnir
Copy link
Contributor

FYI, presubmit is successful, I'm removing the "presubmit" label.

@AndrewKushnir AndrewKushnir removed the action: presubmit The PR is in need of a google3 presubmit label Nov 4, 2020
josephperrott pushed a commit that referenced this pull request Nov 4, 2020
… prelink target (#39518)

In PR #38938 an additional Bazel target was introduced for the compliance
tests, as preparation to run the compliance tests in partial compilation
mode and then apply the linker transform. The linker plugin itself was
not available at the time but has since been implemented, so this commit
updates the prelink target of the compliance tests to apply the linker
transform using the Babel plugin.

Actually emitting partial compilations to be transformed will be done in
follow-up work.

PR Close #39518
ng-linker automation moved this from Review in progress to Done Nov 4, 2020
josephperrott pushed a commit that referenced this pull request Nov 4, 2020
This commit implements partial code generation for directives, which
will be transformed by the linker plugin to fully AOT compiled code in
follow-up work.

PR Close #39518
josephperrott pushed a commit that referenced this pull request Nov 4, 2020
…39518)

This commit implements the logic to compile a partial declaration of a
directive into its full AOT compilation output.

PR Close #39518
josephperrott pushed a commit that referenced this pull request Nov 4, 2020
…nent` to use `ɵɵ` prefix (#39518)

For consistency with other generated code, the partial declaration
functions are renamed to use the `ɵɵ` prefix which indicates that it is
generated API.

This commit also removes the declaration from the public API golden
file, as it's not yet considered stable at this point. Once the linker
is finalized will these declaration function be included into the golden
file.

PR Close #39518
@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 Dec 5, 2020
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 cla: yes feature Issue that requests a new feature target: minor This PR is targeted for the next minor release
Projects
No open projects
ng-linker
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

5 participants