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
{{ message }}
This repository has been archived by the owner on Jun 9, 2023. It is now read-only.
Including the Icon/index.js file encourages importing all icons through a single path:
import{Unknown,Negative}from'@bufferapp/ui/Icon';
Using this approach may feel easier, but bloat the webpack bundle. All Icons account for the biggest contributor of the webpack bundle.
Analyzing one webpack bundle recently, the ui library accounts for 132k, 41k is the Icon directory if it's imported through the path '@bufferapp/ui/Icon'. Comparatively, an individual Icon is between 0.5-1k and the next biggest component is Select at 16k. The average app likely does not use every single Icon. With them all being inline SVGs, this contributes to the bloat.
Idea
Remove the Icon/index.js file to prevent engineers from importing and destructuring.
Reduce the number of nested directories for simpler importing path
// we end up with this:importCheckmarkIconfrom'@bufferapp/ui/Icons/Checkmark';// instead of thisimportCheckmarkIconfrom'@bufferapp/ui/Icon/Icons/Checkmark';// or thisimport{Checkmark}from'@bufferapp/ui/Icons';
Caveats
Dead code webpack plugins could potentially remove the unused Icons, but that requires more processing and instead making this change would remove the work from webpack by encouraging better practices for our team. 😄
The text was updated successfully, but these errors were encountered:
Issue
Including the
Icon/index.js
file encourages importing all icons through a single path:Using this approach may feel easier, but bloat the webpack bundle. All
Icon
s account for the biggest contributor of the webpack bundle.Analyzing one webpack bundle recently, the ui library accounts for 132k, 41k is the Icon directory if it's imported through the path
'@bufferapp/ui/Icon'
. Comparatively, an individual Icon is between 0.5-1k and the next biggest component is Select at 16k. The average app likely does not use every single Icon. With them all being inline SVGs, this contributes to the bloat.Idea
Icon/index.js
file to prevent engineers from importing and destructuring.Caveats
Dead code webpack plugins could potentially remove the unused Icons, but that requires more processing and instead making this change would remove the work from webpack by encouraging better practices for our team. 😄
The text was updated successfully, but these errors were encountered: