Callidon/bloom-filters

Error in Browser Chrome 105

kabapy opened this issue · 2 comments

environment is a quasar+vite+vue3

vue-router.mjs:3428 ReferenceError: Buffer is not defined
at cell.js:178:76
at node_modules/bloom-filters/dist/iblt/cell.js (cell.js:200:1)
at __require (chunk-OL3AADLO.js?v=aca5486d:9:50)
at node_modules/bloom-filters/dist/iblt/invertible-bloom-lookup-tables.js (invertible-bloom-lookup-tables.js:84:30)
at __require (chunk-OL3AADLO.js?v=aca5486d:9:50)
at node_modules/bloom-filters/dist/api.js (api.js:54:40)
at __require (chunk-OL3AADLO.js?v=aca5486d:9:50)
at dep:bloom-filters:1:16

Found a fix
https://github.com/feross/buffer

you have to install a polyfill for Buffer
npm install buffer

then import it in main.js and make it global using
import { Buffer } from "buffer"; window.Buffer = window.Buffer || Buffer;

Yes this is the fix. You cannot actually import all the modules in a browser but you can import some without polyfills. For the Invertible Bloom filter yes you need to install this package for a browser usage. See the warning https://github.com/Callidon/bloom-filters#invertible-bloom-filters