Ionic React tree-shaking

Is tree-shaking at all possible on Ionic React?

My use case: single codebase PWA and mobile apps

Yes, tree-shaking works out of the box. Ionic React uses CRA (create-react-app) by default, so if you’re searching for resources, search for “CRA tree-shaking” instead of “Ionic React tree-shaking”.

You can also use Vite instead of CRA, which does tree-shaking a bit differently.

@ptmkenny I am using vite. I can see loads of components which I did not import in my bundle

Components often have dependencies, so pulling in one of the more complicated ones (ion-datetime, for example) can pull in a lot of others.

1 Like