Skip to content

fix(ivy): ensure module scope is rebuild on dependent change - #33522

Closed
JoostK wants to merge 1 commit into
angular:masterfrom
JoostK:ngtsc-fix-incremental-builds
Closed

JoostK wants to merge 1 commit into
angular:masterfrom
JoostK:ngtsc-fix-incremental-builds

Conversation

@JoostK

@JoostK JoostK commented Oct 31, 2019

Copy link
Copy Markdown
Member

During incremental compilations, ngtsc needs to know which metadata
from a previous compilation can be reused, versus which metadata has to
be recomputed as some dependency was updated. Changes to
directives/components should cause the NgModule in which they are
declared to be recompiled, as the NgModule's compilation is dependent
on its directives/components.

When a dependent source file of a directive/component is updated,
however, a more subtle dependency should also cause to NgModule's source
file to be invalidated. During the reconciliation of state from a
previous compilation into the new program, the component's source file
is invalidated because one of its dependency has changed, ergo the
NgModule needs to be invalidated as well. Up until now, this implicit
dependency was not imposed on the NgModule. Additionally, any change to
a dependent file may influence the module scope to change, so all
components within the module must be invalidated as well.

This commit fixes the bug by introducing additional file dependencies,
as to ensure a proper rebuild of the module scope and its components.

Fixes #32416

During incremental compilations, ngtsc needs to know which metadata
from a previous compilation can be reused, versus which metadata has to
be recomputed as some dependency was updated. Changes to
directives/components should cause the NgModule in which they are
declared to be recompiled, as the NgModule's compilation is dependent
on its directives/components.

When a dependent source file of a directive/component is updated,
however, a more subtle dependency should also cause to NgModule's source
file to be invalidated. During the reconciliation of state from a
previous compilation into the new program, the component's source file
is invalidated because one of its dependency has changed, ergo the
NgModule needs to be invalidated as well. Up until now, this implicit
dependency was not imposed on the NgModule. Additionally, any change to
a dependent file may influence the module scope to change, so all
components within the module must be invalidated as well.

This commit fixes the bug by introducing additional file dependencies,
as to ensure a proper rebuild of the module scope and its components.

Fixes angular#32416
@JoostK JoostK added type: bug/fix action: review The PR is still awaiting reviews from at least one requested reviewer effort1: hours workaround1: obvious freq2: medium severity3: broken target: major This PR is targeted for the next major release risk: low area: compiler Issues related to `ngc`, Angular's template compiler labels Oct 31, 2019
@ngbot ngbot Bot modified the milestone: Backlog Oct 31, 2019
@AndrewKushnir AndrewKushnir added target: patch This PR is targeted for the next patch release and removed target: major This PR is targeted for the next major release labels Oct 31, 2019
@JoostK
JoostK marked this pull request as ready for review October 31, 2019 21:41
@JoostK
JoostK requested a review from a team October 31, 2019 21:41
@alxhub

alxhub commented Nov 6, 2019

Copy link
Copy Markdown
Member

Presubmit
No Ivy presubmit needed; incremental rebuild wouldn't be tested correctly anyway.

@alxhub alxhub 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 6, 2019
@atscott atscott removed the action: merge The PR is ready for merge by the caretaker label Nov 6, 2019
@JoostK JoostK added action: merge The PR is ready for merge by the caretaker merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note labels Nov 12, 2019
@ngbot

ngbot Bot commented Nov 12, 2019

Copy link
Copy Markdown

I see that you just added the PR action: merge label, but the following checks are still failing:
    failure status "google3" is failing

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.

@JoostK

JoostK commented Nov 12, 2019

Copy link
Copy Markdown
Member Author

merge-assistance: merge label was removed, I don't know why? It should be good to go from my perspective.

@kara kara added action: review The PR is still awaiting reviews from at least one requested reviewer and removed merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note labels Nov 12, 2019
@kara

kara commented Nov 12, 2019

Copy link
Copy Markdown
Contributor

@JoostK Looks like the PR still needs a review

@JoostK JoostK removed the action: review The PR is still awaiting reviews from at least one requested reviewer label Nov 12, 2019
kara pushed a commit that referenced this pull request Nov 12, 2019
During incremental compilations, ngtsc needs to know which metadata
from a previous compilation can be reused, versus which metadata has to
be recomputed as some dependency was updated. Changes to
directives/components should cause the NgModule in which they are
declared to be recompiled, as the NgModule's compilation is dependent
on its directives/components.

When a dependent source file of a directive/component is updated,
however, a more subtle dependency should also cause to NgModule's source
file to be invalidated. During the reconciliation of state from a
previous compilation into the new program, the component's source file
is invalidated because one of its dependency has changed, ergo the
NgModule needs to be invalidated as well. Up until now, this implicit
dependency was not imposed on the NgModule. Additionally, any change to
a dependent file may influence the module scope to change, so all
components within the module must be invalidated as well.

This commit fixes the bug by introducing additional file dependencies,
as to ensure a proper rebuild of the module scope and its components.

Fixes #32416

PR Close #33522
@kara kara closed this in 15f8638 Nov 12, 2019
@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 Dec 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 area: compiler Issues related to `ngc`, Angular's template compiler cla: yes effort1: hours freq2: medium risk: low target: patch This PR is targeted for the next patch release type: bug/fix workaround1: obvious

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ivy loses query results in abstract @Directive() when CLI rebuilt (file change)

6 participants