-
Notifications
You must be signed in to change notification settings - Fork 355
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
Bug - [react-table] - Using a Table component causes all of PatternFly's CSS to be imported #10618
Comments
In fact we do this a lot in our projects: We never import the full import { Button } from "@patternfly/react-core/dist/esm/components/Button";
import { DropdownItem } from "@patternfly/react-core/dist/esm/components/Dropdown";
import { Tooltip } from "@patternfly/react-core/dist/esm/components/Tooltip"; |
I looked at
In numbers the result is: This would be a small but nice reduction in final bundle size for cockpit-ostree, for cockpit-machines I would need to patch more PF components to get similar results. |
This does not currently make any difference for the dist/ size because of patternfly/patternfly-react#10618. But we do that in all other projects.
This does not currently make any difference for the dist/ size because of patternfly/patternfly-react#10618. But we do that in all other projects.
This does not currently make any difference for the dist/ size because of patternfly/patternfly-react#10618. But we do that in all other projects.
This does not currently make any difference for the dist/ size because of patternfly/patternfly-react#10618. But we do that in all other projects.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
Need to recheck with PF6 but this is still an issue in PF5. |
Describe the problem
We have been using esbuild for a while now with Cockpit, and recently we found that it includes a bundle analyzer. Our bundle is great large (uncompressed) so it would be interesting to see if we can make it smaller.
(If you want to see this in action, upload this meta.json file to the esbuild bundle analyzer).
What stands out is the 1.5 mb of react-styles which are imported, this project (cockpit-machines) does not use a
Masthead
component but the css is still imported.The bundle analyzer can also show why something is imported
So importing
Table/index.js
importsThe problem here is that
@patternfly/react-core
is a barrel file, so importing it this way imports@patternfly/react-core/dist/js/index.js
:So basically it imports all of PatternFly, esbuild seems to be smart enough to not include unused JavaScript but it seems it doesn't handle CSS.
An easy fix would be for
react-table
to import for examplesetTabIndex
fromreact-core/dist/js/helpers/KeyboardHandler.js
directly.The text was updated successfully, but these errors were encountered: