Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to enable tree shaking? #476

Open
vdboor opened this issue Mar 30, 2024 · 2 comments
Open

How to enable tree shaking? #476

vdboor opened this issue Mar 30, 2024 · 2 comments

Comments

@vdboor
Copy link

vdboor commented Mar 30, 2024

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.

@thednp
Copy link
Owner

thednp commented Mar 31, 2024

Yes, this happened during the Rollup => Vite migration. If I could find a solution, will let you know.

thednp added a commit that referenced this issue Mar 31, 2024
* update dependencies
* update Bootstrap CSS to 5.3.3
* attempt to fix tree shaking #476
@thednp
Copy link
Owner

thednp commented Mar 31, 2024

Please test @5.0.12 and let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants