I'd really like to use this module in browsers but the bundle size ends up being very large, just importing the CuckooFilter adds over 50KB of minified code to the bundle.
Using esbuild to bundle just this script:
import { CuckooFilter } from 'bloom-filters'
const filter = new CuckooFilter(1, 2, 3, 4)
console.info(filter.has('hello world'))
Creates a 216KB bundle (63KB minified), and I have to shim some node internals (e.g. the Buffer class) for it to work:
The CuckooFilter implementation itself is 8.4KB un-minified so there's a lot of unused code here.
Would you be open to some PRs that make this module more browser friendly?
Some low hanging fruit I can see immediately:
- Switch tsc to output ESM for better tree shaking
- Replace use of node
Buffers with built-in Uint8Arrays
- Remove, replace or optimise use of lodash
- Remove
long dependency and use built-in BigInts
The first is a breaking change but will yield the biggest benefit - the breaking change is that consumers will no longer be able to require the module, they must import it via static or dynamic imports.
The second is breaking where Buffers are used as return values which from what I can see only appears to be in the Invertible Bloom Lookup Table implementation.
The rest are just internal changes so are non-breaking.
I'd really like to use this module in browsers but the bundle size ends up being very large, just importing the
CuckooFilteradds over 50KB of minified code to the bundle.Using
esbuildto bundle just this script:Creates a 216KB bundle (63KB minified), and I have to shim some node internals (e.g. the
Bufferclass) for it to work:The
CuckooFilterimplementation itself is 8.4KB un-minified so there's a lot of unused code here.Would you be open to some PRs that make this module more browser friendly?
Some low hanging fruit I can see immediately:
Buffers with built-inUint8Arrayslongdependency and use built-inBigIntsThe first is a breaking change but will yield the biggest benefit - the breaking change is that consumers will no longer be able to
requirethe module, they mustimportit via static or dynamic imports.The second is breaking where
Buffers are used as return values which from what I can see only appears to be in the Invertible Bloom Lookup Table implementation.The rest are just internal changes so are non-breaking.