Share identical stylesheets between components in the same file #38204
Milestone
Comments
|
The effectiveness of this operation will depend on fixing #38203, as otherwise the first component consuming a stylesheet will not benefit from extraction of a constant. |
AndrewKushnir
added a commit
to AndrewKushnir/angular
that referenced
this issue
Jul 24, 2020
…e constant Prior to this commit, duplicated styles defined in multiple components in the same file were not shared between components, thus causing extra payload size. This commit updates compiler logic to use `ConstantPool` for the styles (while generating the `styles` array on component def), which enables styles sharing when needed (when duplicates styles are present). Resolves angular#38204.
AndrewKushnir
added a commit
to AndrewKushnir/angular
that referenced
this issue
Jul 24, 2020
…same file Prior to this commit, duplicated styles defined in multiple components in the same file were not shared between components, thus causing extra payload size. This commit updates compiler logic to use `ConstantPool` for the styles (while generating the `styles` array on component def), which enables styles sharing when needed (when duplicates styles are present). Resolves angular#38204.
AndrewKushnir
added a commit
to AndrewKushnir/angular
that referenced
this issue
Jul 24, 2020
…same file Prior to this commit, duplicated styles defined in multiple components in the same file were not shared between components, thus causing extra payload size. This commit updates compiler logic to use `ConstantPool` for the styles (while generating the `styles` array on component def), which enables styles sharing when needed (when duplicates styles are present). Resolves angular#38204.
2 tasks
mhevery
added a commit
that referenced
this issue
Jul 27, 2020
…same file (#38213) Prior to this commit, duplicated styles defined in multiple components in the same file were not shared between components, thus causing extra payload size. This commit updates compiler logic to use `ConstantPool` for the styles (while generating the `styles` array on component def), which enables styles sharing when needed (when duplicates styles are present). Resolves #38204. PR Close #38213
Splaktar
added a commit
to angular-hispano/angular
that referenced
this issue
Aug 8, 2020
…same file (angular#38213) Prior to this commit, duplicated styles defined in multiple components in the same file were not shared between components, thus causing extra payload size. This commit updates compiler logic to use `ConstantPool` for the styles (while generating the `styles` array on component def), which enables styles sharing when needed (when duplicates styles are present). Resolves angular#38204. PR Close angular#38213
|
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. |
profanis
added a commit
to profanis/angular
that referenced
this issue
Sep 5, 2020
…same file (angular#38213) Prior to this commit, duplicated styles defined in multiple components in the same file were not shared between components, thus causing extra payload size. This commit updates compiler logic to use `ConstantPool` for the styles (while generating the `styles` array on component def), which enables styles sharing when needed (when duplicates styles are present). Resolves angular#38204. PR Close angular#38213
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.


In rare cases, multiple components can share the same styles. For example, Material does this with
MatButtonandMatAnchor.View Engine had a feature which converted
styleUrlsinto.ngstyle.jsclasses with exported constants, and thus naturally deduplicated reuse of external stylesheets. Ivy does not perform this optimization by design - it was a design goal to remove all additional "shim" files.A limited form of this optimization in Ivy is possible - within a single file, it should be possible to use the
ConstantPoolto deduplicate stylesheet text that is shared between multiple components. This would be useful both for external stylesheets as well as inline style text, as long as it's identical. This optimization is of course conditional onViewEncapsulation- encapsulated and un-encapsulated styles will have different contents, and thus no reuse between them is possible.This optimization would apply to the Material example above, since
MatButtonandMatAnchorare both declared in the same TS file.The text was updated successfully, but these errors were encountered: