bootstrap.native
bootstrap.native copied to clipboard
How to enable tree shaking?
Somehow tree shaking isn't working for me. I end up with a JavaScript file of 40kB when I do:
import { Alert, Collapse } from 'bootstrap.native';
Doing the equivalent in Bootstrap 5 JS will give me a 13kB file:
import { Alert } from 'bootstrap/js/src/alert.js';
import { Collapse } from 'bootstrap/js/src/collapse.js';
WebPack is configured with:
{
mode: 'production',
optimization: {
usedExports: true, // tree shaking
minimize: true,
minimizer: [
new TerserPlugin(),
]
}
}
And my package.json
has "sideEffects": false
in it.
Is there anything I'm still doing wrong, or is this a bug in the package?
As a sidenote, I would have loved to use the old approach of importing from sub files directly. This is no longer possible due to the exports
section in package.json
.