Tree Shaking Not working in Gatsby
Closed this issue · 4 comments
rotexhawk commented
couds commented
Hi @rotexhawk can you share your configuration?and if possible a small repo with a reproducible example
Without more information it's quite difficult to understand what is happening
rotexhawk commented
Hello @couds, thanks for the quick reply. I setup a bare bone repo here. https://github.com/rotexhawk/jameygittings. All you have to do is npm install
and npm run build
.
Thanks
couds commented
Hi @rotexhawk after checking this issue in Gatsby, seems that the tree shaking only works on ES6 Modules, and the default export for this library its commonjs.
We also have es6 export, you need to change the import like this
// CommonJS (Default)
import { Content, Footer, Container } from "react-bulma-components";
// ES6
import { Content, Footer, Container } from "react-bulma-components/esm";
With this the tree shaking works
rotexhawk commented
Great. Thanks for the update. This works :)