The package now supports esm but tree shaking doesn't work yet when used in webpack. A single import of a predicate will import everything from the package.
I didn't understand why so I started searching and found this: https://webpack.js.org/guides/tree-shaking/
I also looked at a package like lodash-es and found that they have sideEffects: false in their package.json as stated in the guide. The lodash package does proper treeshaking as far as I could see because of that sideEffects property. As a test I added the property to this package as well and it seemed to work the included size went from 13kb to 1kb in my case. I don't know the complete package to know if there are actual side effects. If not then it's just a case of adding that property to the package.json.
The package now supports esm but tree shaking doesn't work yet when used in webpack. A single import of a predicate will import everything from the package.
I didn't understand why so I started searching and found this: https://webpack.js.org/guides/tree-shaking/ I also looked at a package like
lodash-es
and found that they havesideEffects: false
in their package.json as stated in the guide. The lodash package does proper treeshaking as far as I could see because of thatsideEffects
property. As a test I added the property to this package as well and it seemed to work the included size went from 13kb to 1kb in my case. I don't know the complete package to know if there are actual side effects. If not then it's just a case of adding that property to the package.json.