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
fix(compiler-cli): Allow analysis to continue with invalid style url #41403
Conversation
Currently, we throw a FatalDiagnosticError when we fail to load a resource (`templateUrl` or `styleUrl`) at various stages in the compiler. This prevents analysis of the component from completing. This will result in in users not being able to get any information in the component template when there is a missing `styleUrl`, for example. This commit simply tracks the diagnostic, marks the component as poisoned, and continues merrily along. Environments configured to use poisoned data (like the language service) will then be able to use other information from the analysis. Fixes angular/vscode-ng-language-service#1241
styleUrl.url, containingFile, styleUrl.nodeForError, resourceType); | ||
const resourceStr = this.resourceLoader.load(resourceUrl); | ||
try { | ||
const resourceUrl = this._resolveResourceOrThrow( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than this try
/catch
, we should make _resolveResourceOrThrow
not throw, and instead return some kind of error that we can choose to deal with (or ignore) as we see fit. Possibly this means its return value will be some kind of union between a success type and a failure type that also includes a diagnostic.
diagnostics = []; | ||
} | ||
diagnostics.push(makeDiagnostic(e.code, e.node, e.message, e.relatedInformation)); | ||
isPoisoned = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isPoisoned
means "cannot be relied upon by consuming components" - a component shouldn't be poisoned because its own template or stylesheets are unavailable as they're not a part of its public API.
64aa114
to
26fac59
Compare
…ngular#41403) Currently, we throw a FatalDiagnosticError when we fail to load a resource (`templateUrl` or `styleUrl`) at various stages in the compiler. This prevents analysis of the component from completing. This will result in in users not being able to get any information in the component template when there is a missing `styleUrl`, for example. This commit simply tracks the diagnostic, marks the component as poisoned, and continues merrily along. Environments configured to use poisoned data (like the language service) will then be able to use other information from the analysis. Fixes angular/vscode-ng-language-service#1241 PR Close angular#41403
…ngular#41403) Currently, we throw a FatalDiagnosticError when we fail to load a resource (`templateUrl` or `styleUrl`) at various stages in the compiler. This prevents analysis of the component from completing. This will result in in users not being able to get any information in the component template when there is a missing `styleUrl`, for example. This commit simply tracks the diagnostic, marks the component as poisoned, and continues merrily along. Environments configured to use poisoned data (like the language service) will then be able to use other information from the analysis. Fixes angular/vscode-ng-language-service#1241 PR Close angular#41403
…ngular#41403) Currently, we throw a FatalDiagnosticError when we fail to load a resource (`templateUrl` or `styleUrl`) at various stages in the compiler. This prevents analysis of the component from completing. This will result in in users not being able to get any information in the component template when there is a missing `styleUrl`, for example. This commit simply tracks the diagnostic, marks the component as poisoned, and continues merrily along. Environments configured to use poisoned data (like the language service) will then be able to use other information from the analysis. Fixes angular/vscode-ng-language-service#1241 PR Close angular#41403
…41403) (#41489) Currently, we throw a FatalDiagnosticError when we fail to load a resource (`templateUrl` or `styleUrl`) at various stages in the compiler. This prevents analysis of the component from completing. This will result in in users not being able to get any information in the component template when there is a missing `styleUrl`, for example. This commit simply tracks the diagnostic, marks the component as poisoned, and continues merrily along. Environments configured to use poisoned data (like the language service) will then be able to use other information from the analysis. Fixes angular/vscode-ng-language-service#1241 PR Close #41403 PR Close #41489
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. |
Currently, we throw a FatalDiagnosticError when we fail to load a resource
(
templateUrl
orstyleUrl
) at various stages in the compiler. This preventsanalysis of the component from completing. This will result in in users not being
able to get any information in the component template when there is a missing
styleUrl
, for example.This commit simply tracks the diagnostic, marks the component as poisoned, and
continues merrily along. Environments configured to use poisoned data
(like the language service) will then be able to use other information from the analysis.
Fixes angular/vscode-ng-language-service#1241