fix(compiler): non-literal inline templates incorrectly processed in partial compilation by devversion · Pull Request #41583 · angular/angular
petebacondarwin
added
action: cleanup
and removed action: review
The PR is still awaiting reviews from at least one requested reviewerlabels
Apr 14, 2021…compilation With the introduction of the partial compilation, the Angular compiler's existing `parseTemplate` method has been extended to pass through multiple properties purely in favor of the partial compilation. e.g. the `parseTemplate` function now accepts an "option" called `isInline`. This option is just passed through and returned as part of the `ParsedTemplate`. This is not ideal because the `parseTemplate` function doesn't care whether the specified template was inline or not. This commit cleans up the `parseTemplate` compiler function so that nothing needed only for the partial compilation is added to it. We introduce a new struct for additional template information that is specific to the generation of the `declareComponent` function. With that change, we can simplify the component decorator handler and keep logic more local.
…partial compilation
Currently if a component defines a template inline, but not through a
string literal, the partial compilation references the template expression
as is. This is problematic because the component declaration can no longer
be processed by the linker later as there is no static interpretation. e.g.
```js
const myTemplate = `...`;
TestCmp.ɵcmp = i0.ɵɵngDeclareComponent({
version: "0.0.0-PLACEHOLDER",
type: TestCmp,
selector: "test-cmp",
ngImport: i0,
template: myTemplate,
isInline: true
});
```
To fix this, we use the the resolved template in such cases so that
the linker can process the template/component declaration as expected.
AndrewKushnir pushed a commit that referenced this pull request
Apr 16, 2021…compilation (#41583) With the introduction of the partial compilation, the Angular compiler's existing `parseTemplate` method has been extended to pass through multiple properties purely in favor of the partial compilation. e.g. the `parseTemplate` function now accepts an "option" called `isInline`. This option is just passed through and returned as part of the `ParsedTemplate`. This is not ideal because the `parseTemplate` function doesn't care whether the specified template was inline or not. This commit cleans up the `parseTemplate` compiler function so that nothing needed only for the partial compilation is added to it. We introduce a new struct for additional template information that is specific to the generation of the `declareComponent` function. With that change, we can simplify the component decorator handler and keep logic more local. PR Close #41583
AndrewKushnir pushed a commit that referenced this pull request
Apr 16, 2021…partial compilation (#41583) Currently if a component defines a template inline, but not through a string literal, the partial compilation references the template expression as is. This is problematic because the component declaration can no longer be processed by the linker later as there is no static interpretation. e.g. ```js const myTemplate = `...`; TestCmp.ɵcmp = i0.ɵɵngDeclareComponent({ version: "0.0.0-PLACEHOLDER", type: TestCmp, selector: "test-cmp", ngImport: i0, template: myTemplate, isInline: true }); ``` To fix this, we use the the resolved template in such cases so that the linker can process the template/component declaration as expected. PR Close #41583
AndrewKushnir pushed a commit that referenced this pull request
Apr 16, 2021…partial compilation (#41583) Currently if a component defines a template inline, but not through a string literal, the partial compilation references the template expression as is. This is problematic because the component declaration can no longer be processed by the linker later as there is no static interpretation. e.g. ```js const myTemplate = `...`; TestCmp.ɵcmp = i0.ɵɵngDeclareComponent({ version: "0.0.0-PLACEHOLDER", type: TestCmp, selector: "test-cmp", ngImport: i0, template: myTemplate, isInline: true }); ``` To fix this, we use the the resolved template in such cases so that the linker can process the template/component declaration as expected. PR Close #41583
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