Get rid of react-icons
luisherranz opened this issue · comments
The package react-icons
is adding 624Kb to the whole bundle:
As you can see, it is almost as big as the rest of the app, react included.
You can see it yourself by inspecting the build/analyze/module-production.html
file after running npx frontity dev --production
. Don't forget the --production
flag.
Normally, you can avoid this problem:
- Using modules with tree-shaking support. They have
sideEffects: false
in their package jsons: https://webpack.js.org/guides/tree-shaking/ - Picking directly the file from the bundle, like what we do for react-spinners in mars-theme:
import Loader from "react-spinners/ScaleLoader";
// instead of
import { Loader } from "react-spinners";
https://github.com/frontity/frontity/blob/dev/packages/mars-theme/src/components/loading.js#L3
But in the case of react-icons
, even though it uses "sideEffects": false,
it is breaking it for the way it imports the ionicons internally. And also, for the weird way it imports those icons, there's no direct pick either, so this library should be avoided at all costs, at least the ionicons part.
I have changed for react-icons-kit
Awesome :)
Let me know once you push the code and I'll take a look.
All is pushed now :-)
Looks great 👍
For context, this was solved in b5c39bb.