-
Notifications
You must be signed in to change notification settings - Fork 0
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
Library imported bundle size #15
Comments
99% sure its because the font files are being base64'd and inlined into the style.css file. Vite should handle this appropriately with files above 4KB by default but i could not get the build process to obey the expected default behavior nor even when i enforced it in the vite config 🤷♀️ Removing the entire |
For starters, i think we should drop For instance we go from:
to something like:
|
Ignore the above, seem to have a solution:
Will make a quick PR and we can test if it reduces the bundle size (and instead adds a http request for the font file) |
- moved the font files to the public folder - changes the typography css rules to point to them so that they can be served as-is without being base64'd and added inline to style.css on build This might solve a large portion of #15 but we should leave the issue open to tackle this a little deeper even if it does
I am by far not an expert on tree-shaking and library optimization, however i suspect (based on import size when using a single component in this library) there is some unintended bloat coming in with imports even when tree-shaking in specific components. Most individual components seem to be ~150k imported by themselves and when you tack on multiple it doesn't really increase much, so i think in general we have large minimum-import size for one reason or another.
As we shift into using this library in place of optimized 3rd party deps we should focus on solving this, for instance, the
react-avatar
import was/is ~59k and we have built a lighter-weight in-house one in the frontend repo, if we migrate it to this component library and import from there instead we will bloat our NET position (for that component) by ~3x vs using the initialreact-avatar
and lose a portion of the advantage to doing things in-houseIm also not very familiar with vite 😂 so this is super 'not-my-wheelhouse', but i suspect some first places to look for optimizing and properly enforcing tree-shaking to its fullest would be:
vite.config.js
public
folder (probably irrelevant if we get config nailed)As a surface level skim of the actual structure of the library appears to be well suited to tree-shaking (in my minimal-experience opinion)
One thing we should be careful with when we get to the 'icon' component is to make sure only the intended icon SVG/s are apart of the bundle when being imported as i remember having trouble with this in the past
The text was updated successfully, but these errors were encountered: