user908853
user908853

Reputation:

Why is importing specific components resulting in the whole library in the bundle?

I'm following the recommendation to import individual components from react-bootstrap, like so import Container from "react-bootstrap/Container";. I've verified the whole codebase and every single import is the same. Yet, when I analyze the bundle, it shows that react-bootstrap has been bundled in its entirety.

Any ideas what I could be missing?

Upvotes: 5

Views: 573

Answers (2)

TrexS.
TrexS.

Reputation: 3

I think that the answer given is correct, but it is not the only way. package-lock.json would be another file, I suggest you use the same one. Hope I helped Thank You :)

Upvotes: 0

4b0
4b0

Reputation: 22323

Upon further investigation, I found that react-bootstrap-dialog was importing the whole of react-bootstrap. If you're here because of this same issue, I suggest you open package-lock.json and search for any libraries that depend on the unshakeable library, that's the one you should potentially replace.

Note: Answer provided by OP

Upvotes: 1

Related Questions