-
Notifications
You must be signed in to change notification settings - Fork 23
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
How to reduce bundle size | Import cost #161
Comments
I think it's import-cost does not consider tree-shaking, not sure what can do in the dts? |
I'm not sure myself whether it makes performance slower or not. But it feels like a bad practice, where we only need part of the library but when we import it, all the things in the library got imported |
Not true. All the modern bundlers support tree-shaking, so you are not importing all the things. ofc, you can also use something like
but the sounds a bad DX. ╮( ̄▽ ̄)╭ |
Import cost is just a fancy plugin that helps you analyze your package statically. It neither reflects the true bundle size nor tree shaking. When you make your production build you should see the actual size for each page depending on which framework you are using. If you don't understand it maybe just remove the plug-in, it only makes you feel bad I guess. |
Yes, I'm still new to this package management system. I thought that But I'm curious. It (import cost) works great with other deps hosted in npm for example I use import { Box, Stack } from "@mui/material" // the size number of import cost will grow as we add more component. and when we only import one component the number would relative small but in my package import { FAButton } from "@hzn-one/flex-hzn" // importing only one component bring all the bundle size number of `import cost`,
// as we added more component
import { FAButton, FAAvatar } from "@hzn-one/flex-hzn" // the size number doesn't change |
Current Behavior
The import cost is very expensive, and the size is still the same as the amount of components imported reduced
Expected behavior
The import cost only takes on what component is being used
Suggested solution(s)
I have tried few things such as reducing reexporting components, but it doesn't work
Additional context
N / A
Your environment
The text was updated successfully, but these errors were encountered: