fix(compiler-cli): do not persist component analysis if template/styles are missing#49184
Closed
devversion wants to merge 1 commit intoangular:mainfrom
Closed
fix(compiler-cli): do not persist component analysis if template/styles are missing#49184devversion wants to merge 1 commit intoangular:mainfrom
devversion wants to merge 1 commit intoangular:mainfrom
Conversation
…es are missing Consider the following scenario: 1. A TS file with a component and templateUrl exists 2. The template file does not exist. 3. First build: ngtsc will properly report the error, via a FatalDiagnosticError 4. The template file is now created 5. Second build: ngtsc still reports the same errror. ngtsc persists the analysis data of the component and never invalidates it when the template/style file becomes available later. This breaks incremental builds and potentially common workflows where resource files are added later after the TS file is created. This did surface as an issue in the Angular CLI yet because Webpack requires users to re-start the process when a new file is added. With ESBuild this will change and this also breaks incremental builds with Bazel/Blaze workers. To fix this, we have a few options: * Invalidate the analysis when e.g. the template file is missing. Never caching it means that it will be re-analyzed on every build iteration. * Add the resource dependency to ngtsc's incremental file graph. ngtsc will then know via `host.getModifiedResources` when the file becomes available- and fresh analysis of component would occur. The first approach is straightforward to implement and was chosen here. The second approach would allow ngtsc to re-use more of the analysis when we know that e.g. the template file still not there, but it increases complexity unnecessarily because there is no **single** obvious resource path for e.g. a `templateUrl`. The URL is attempted to be resolved using multiple strategies, such as TS program root dirs, or there is support for a custom resolution through `host.resourceNameToFileName`. It would be possible to determine some candidate paths and add them to the dependency tracker, but it seems incomplete given possible external resolvers like `resourceNameToFileName` and also would likely not have a sufficient-enough impact given that a broken component decorator is not expected to remain for too long between N incremental build iterations.
01774df to
41f1a0a
Compare
alxhub
approved these changes
Feb 23, 2023
Contributor
|
@devversion it looks like presubmit info is missing, could you please update the status or leave a comment about the presubmit state, so that we can proceed with the merge? |
Member
Author
|
@AndrewKushnir started presubmit now. The caretaker queue filter should only show it when all statuses are green, but feel free to remove the label if you prefer that. |
Contributor
|
This PR was merged into the repository by commit b6c6dfd. |
AndrewKushnir
pushed a commit
that referenced
this pull request
Feb 24, 2023
…es are missing (#49184) Consider the following scenario: 1. A TS file with a component and templateUrl exists 2. The template file does not exist. 3. First build: ngtsc will properly report the error, via a FatalDiagnosticError 4. The template file is now created 5. Second build: ngtsc still reports the same errror. ngtsc persists the analysis data of the component and never invalidates it when the template/style file becomes available later. This breaks incremental builds and potentially common workflows where resource files are added later after the TS file is created. This did surface as an issue in the Angular CLI yet because Webpack requires users to re-start the process when a new file is added. With ESBuild this will change and this also breaks incremental builds with Bazel/Blaze workers. To fix this, we have a few options: * Invalidate the analysis when e.g. the template file is missing. Never caching it means that it will be re-analyzed on every build iteration. * Add the resource dependency to ngtsc's incremental file graph. ngtsc will then know via `host.getModifiedResources` when the file becomes available- and fresh analysis of component would occur. The first approach is straightforward to implement and was chosen here. The second approach would allow ngtsc to re-use more of the analysis when we know that e.g. the template file still not there, but it increases complexity unnecessarily because there is no **single** obvious resource path for e.g. a `templateUrl`. The URL is attempted to be resolved using multiple strategies, such as TS program root dirs, or there is support for a custom resolution through `host.resourceNameToFileName`. It would be possible to determine some candidate paths and add them to the dependency tracker, but it seems incomplete given possible external resolvers like `resourceNameToFileName` and also would likely not have a sufficient-enough impact given that a broken component decorator is not expected to remain for too long between N incremental build iterations. PR Close #49184
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Consider the following scenario:
Ngtsc persists the analysis data of the component and never invalidates it when the template/style
file becomes available later.
This breaks incremental builds and potentially common workflows where resource files are added
later after the TS file is created. This did not surface as an issue in the Angular CLI yet because Webpack
requires users to re-start the process when a new file is added. With ESBuild this will change and this
also breaks incremental builds with Bazel/Blaze workers.
To fix this, we have a few options:
re-analyzed on every build iteration.
host.getModifiedResourceswhen the file becomes available- and fresh analysis of component would occur.The first approach is straightforward to implement and was chosen here. The second approach would
allow ngtsc to re-use more of the analysis when we know that e.g. the template file still not there, but it
ncreases complexity unnecessarily because there is no single obvious resource path for e.g. a
templateUrl.The URL is attempted to be resolved using multiple strategies, such as TS program root dirs, or there is support
for a custom resolution through
host.resourceNameToFileName.It would be possible to determine some candidate paths and add them to the dependency tracker, but it
seems incomplete given possible external resolvers like
resourceNameToFileNameand also would likelynot have a sufficient-enough impact given that a broken component decorator is not expected to remain
for too long between N incremental build iterations.