Does a component index file bundle every component if a single one is imported on a page?
Unanswered
Silver Fox posted this in #help-forum
![Avatar](https://cdn.discordapp.com/embed/avatars/1.png)
Silver FoxOP
import Avatar from './Avatar/Avatar';
import Button from './Button/Button';
// ...
export {
Avatar,
Button,
// ...
}
When i tried to import avatar in one page I just noticed the other component imported as well therefore it increases the page size. Any help is appreciated.
import Button from './Button/Button';
// ...
export {
Avatar,
Button,
// ...
}
When i tried to import avatar in one page I just noticed the other component imported as well therefore it increases the page size. Any help is appreciated.
5 Replies
![Avatar](https://cdn.discordapp.com/avatars/769111741098622976/a00ea6fb13337fd9ef76154f8e3cb990.webp?size=256)
Eric Burel
Just so you can find more answer this is called a barrel file
(this name gave nothing in Google the first time I discovered it and suddently it's everywhere, you should find more info)
in an ideal world barrel files are automatically cut but there maybe 1) bug 2) improper setups either on Next side or the lib size
I think even 14.1 includes a fix for mui and lodash, some versions may have regressions when it comes to that
and the package must be friendly to such cuts (I don't remember exactly but basically it must not have side-effects so that the cut doesn't alter the package behaviour, maybe it should use ES modules, stuff like that...)