You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
...MyComponent2 won't be treeshaken with for example Rollup, since the calls to "___registerElement" may have side effects.
This is unfortunate since this may lead to scenarios with files exporting many components none of which will be treeshaken.
Solution
[WIP]
Rather than declare the static helper calls inside the top-level scope of files declaring components, the helper calls should be embedded within the class-scope of the components.
One way to do so is to place all of them inside the already-defined static bootstrap method of components.
One last thing that is then needed is to avoid calling ___bootstrap from the top-level scope, but instead have the component itself do that somehow.
The text was updated successfully, but these errors were encountered:
wessberg
changed the title
Improve treeshaking of multi-component files
Improve treeshaking of compiled/published multi-component files
Sep 27, 2018
Problem
If we have a file like this:
...And we make an import like this:
...
MyComponent2
won't be treeshaken with for example Rollup, since the calls to "___registerElement" may have side effects.This is unfortunate since this may lead to scenarios with files exporting many components none of which will be treeshaken.
Solution
[WIP]
Rather than declare the static helper calls inside the top-level scope of files declaring components, the helper calls should be embedded within the class-scope of the components.
One way to do so is to place all of them inside the already-defined static
bootstrap
method of components.One last thing that is then needed is to avoid calling
___bootstrap
from the top-level scope, but instead have the component itself do that somehow.The text was updated successfully, but these errors were encountered: