Templarian / MaterialDesign-React

Dist for Material Design Icons React Component for JS/TypeScript
https://materialdesignicons.com
MIT License
142 stars 20 forks source link

how to tree shake icon? #32

Closed popuguytheparrot closed 4 years ago

popuguytheparrot commented 4 years ago

how to tree shake icon? Now loading all icons from package

Templarian commented 4 years ago

React's toolchain has tree shaking built in, so double check you're importing the icons correctly.

import { mdiAccount } from '@mdi/js'; and not all of them.

popuguytheparrot commented 4 years ago

@Templarian its not working. In bundle i see all of icons

Templarian commented 4 years ago

Yeah, not sure what's going on. Probably something in the specific project you have.

Not something I'm going to be able to fix as its webpack, roll-up, etc handle this.

popuguytheparrot commented 4 years ago

its in production bundle. For example, @material-ui/icons its tree shakes, but it package not.

Templarian commented 4 years ago

That is weird. Search your full project for @mdi/js and double check it's only importing them by name.

Beyond that try and recreate in a new app.

vcardins commented 4 years ago

Still not being able to tree shaking either. Any ideas?

petertenhoor commented 3 years ago

Same issue in 2021 with a next.js application. Full 2MB package @mdi/js package ends up in the bundle eventhough I'm only importing a few icons :')