Replies: 4 comments 11 replies
-
For reference, when I create a bundle for a different component library that we're working on that uses PatternFly Elements, if I exclude PatternFly Elements in my component and create a bundle, I get a bundle size like this. But when I include It's over double the size and I know tree shaking isn't happening properly because the chunk file name is |
Beta Was this translation helpful? Give feedback.
-
I don't think there is a downside to going with your recommendation of specifically importing the files instead of relying on general entrypoints like
You're going to get this:
I would need to test it though to see if that is in fact that case. |
Beta Was this translation helpful? Give feedback.
-
We could probably whip up a lint rule to fix this automatically |
Beta Was this translation helpful? Give feedback.
-
Is this something we can apply to all pfe / rhds components? This would help all sites using RHDS/PFE. |
Beta Was this translation helpful? Give feedback.
-
I have a humble request. Can we be more specific when we import other modules into our components?
The reason I ask is because as we try to use the components and I take a look at the network calls to see what is impacting our page loads, I'm seeing a bunch of files that are included that are never used. For example, in this screenshot, all of the
query
decorators are imported even though they aren't being used.In our component files, you'll see this a lot.
And yes, that's nice to be able to do that and it's a convenience. However, what that ends up doing is importing all of the decorators that may not even be used. The
lit/decorators.js
file ends up importing all of these other files.When I try to create an optimized bundle, I end up including a bunch of unused code that increases the payload size. I thought that using something like Rollup would do some tree shaking and eliminate the unused code, but it doesn't seem to do that.
So, can we start writing code like this?
Beta Was this translation helpful? Give feedback.
All reactions