Closed davecranwell closed 2 years ago
Hi, I'm running into the same issue. On my side, even when importing the flags individually the whole package is bundled:
import { Gb } from 'react-flags-select';
This is quite annoying and as such is preventing me from including this library in my project.
Perhaps the owners of this repository could try to set the following field in package.json
:
{
...
"sideEffects": false
}
:tada: Good news, I managed to tweak the config to enable proper tree shaking. I'll submit a PR when I have time, but essentially here are the changes that I made:
"sideEffects": ["*.scss"]
in package.json
rollup.config.js
, for the esm
build, added preserveModules: true
and changed file
to dir
(additionally changed the module
field in package.json
to match that)Here is the result after making these changes and importing a single flag in my same project (import { De } from 'react-flags-select'
):
As a comparison, the bundle used to be 850kB
before making these changes (essentially containing all the flags).
I've been evaluating this for use in a project with a really aggressive performance budget, and this library seems to be adding hundreds of KB of flags I'm not using. In fact I really only want a max of 10 flags.
Is there a way I could exclude all the ones I'm not using at build-time, that I'm missing?