Skip to content

refactor(compiler): implement factory declarations - #41231

Closed
petebacondarwin wants to merge 11 commits into
angular:masterfrom
petebacondarwin:linker-factory-declarations
Closed

petebacondarwin wants to merge 11 commits into
angular:masterfrom
petebacondarwin:linker-factory-declarations

Conversation

@petebacondarwin

@petebacondarwin petebacondarwin commented Mar 16, 2021 •

Copy link
Copy Markdown
Contributor

For public API reviewers, the only change is the removal of ɵɵinjectPipeChangeDetectorRef in goldens/public-api/core/core.d.ts

@google-cla google-cla Bot added the cla: yes label Mar 16, 2021
@petebacondarwin
petebacondarwin force-pushed the linker-factory-declarations branch from 088b2dd to e7b1ec9 Compare March 16, 2021 20:13
@jessicajaniuk jessicajaniuk added the area: compiler Issues related to `ngc`, Angular's template compiler label Mar 16, 2021
@ngbot ngbot Bot added this to the Backlog milestone Mar 16, 2021
@petebacondarwin
petebacondarwin force-pushed the linker-factory-declarations branch 8 times, most recently from 27ff7f3 to 7b1a10c Compare March 18, 2021 09:01
@petebacondarwin petebacondarwin added action: review The PR is still awaiting reviews from at least one requested reviewer state: blocked target: major This PR is targeted for the next major release labels Mar 18, 2021
@petebacondarwin
petebacondarwin marked this pull request as ready for review March 18, 2021 12:00
@petebacondarwin
petebacondarwin force-pushed the linker-factory-declarations branch from 7b1a10c to 59fa3a3 Compare March 18, 2021 12:00
@pullapprove
pullapprove Bot requested review from JoostK and mhevery March 18, 2021 12:00

@JoostK JoostK left a comment

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.

Did a semi-quick pass; have not at all looked into everything in detail.

@petebacondarwin
petebacondarwin force-pushed the linker-factory-declarations branch 3 times, most recently from 0e6e321 to b47557a Compare March 19, 2021 12:19
@petebacondarwin petebacondarwin added state: WIP and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Mar 19, 2021
@petebacondarwin
petebacondarwin marked this pull request as draft March 19, 2021 12:23
@JoostK JoostK added the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Mar 25, 2021
The `injectFn` reference can be inferred unamiguously from the `target`
property so it is not needed.
This commit changes the partial compilation so that it outputs declaration
calls rather than compiled factory functions.

The JIT compiler and the linker are updated to be able to handle these
new declarations.
This instruction was created to work around a problem with injecting a
`ChangeDetectorRef` into a pipe. See angular#31438. This fix required special
metadata for when the thing being injected was a `ChangeDetectorRef`.

Now this is handled by adding a flag `InjectorFlags.ForPipe` to the
`ɵɵdirectiveInject()` call, which avoids the need to special test_cases
`ChangeDetectorRef` in the generated code.
…njectability

When `ɵngDeclareInjector()` was implemented, the `factory` was moved
out to the `ɵfac` static property on the class. This check was not updated.
…function

This function is never called by any of the code in Angular and is not publicly exported.
So it can be safely removed.
Now that other values were removed from `R3ResolvedDependencyType`,
its meaning can now be inferred from the other properties in the
`R3DeclareDependencyMetadata` type. This commit removes this enum
and updates the code to work without it.
…etadata.

Each of the annotations had its own function for doing this, and those
methods were generally employing spread operators that could allow
unwanted properties to leak into the factory metadata object.

This commit supplies a shared function `toFactoryMetadata()` that
avoids this spread of properties into the returned function.
This enumeration will now start to appear in publicly facing code,
as part of declarations, so we remove the R3 to make it less specific
to the internal name for the Ivy renderer/compiler.
@petebacondarwin

Copy link
Copy Markdown
Contributor Author

@AndrewKushnir

Copy link
Copy Markdown
Contributor

FYI, presubmits are successful for the changes in this PR.
Note to Caretaker: there were some failures, but I verified that they are pre-existing by running these targets without the changes from this PR.

@AndrewKushnir AndrewKushnir left a comment

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.

Reviewed-for: public-api
Reviewed-for: size-tracking

@atscott atscott left a comment

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.

Reviewed-for: public-api
Reviewed-for: size-tracking

@jessicajaniuk jessicajaniuk left a comment

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.

LGTM 🍪

reviewed-for: public-api

@petebacondarwin

Copy link
Copy Markdown
Contributor Author

Merge-assistance: The four outstanding reviews requests are not needed and I don't seem to be able to de-request them.

@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.

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 merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note 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