Doesn't seem to work when module re-exporting is involved
Opened this issue · 1 comments
I forked your repo, and changed the layout a bit.
You can see it here
https://github.com/priyajeet/babel-webpack-tree-shaking
Essentially added index.js
to both app
folder and at the root level that now serves as the main entry. Hopefully I didn't configure it incorrectly. Module re-exporting I think is a norm when dealing with lots of components being distributed as a library. Realistically, index.js
at the root level will again re-export like export * from './app'
when the whole project is being distributed as an npm bundle so that the host project does import {SportsCar} from 'babel-webpack-tree-shaking'
and then this host project will end up including everything. For the sake of this example, it serves as the main entry point.
I do notice that once the babel-loader is removed from the webpack rules, then tree shaking happens fine. But unfortunately you need that loader, for say React etc.