jbrowse-components: zlib error using `@jbrowse/react-linear-genome-view` with vite
I made a small test example of @jbrowse/react-linear-genome-vew in an app build with vite. Basically I copied over the app code from here. I had to use the solution described here to polyfill stream (for @gmod/gff) and zlib (for @gmod/cram) (I left out all the other polyfills in that example).
The app builds, but encounters an error trying to display a CRAM track:
serverSideRenderedBlock.ts:135 TypeError: Cannot read properties of undefined (reading '-5')
at Zlib2._binding.onerror (node-modules-polyfills:zlib:357:26)
at Zlib._error (binding.js:264:8)
at Zlib._write (binding.js:222:10)
at Zlib.writeSync (binding.js:171:15)
at Gunzip.Zlib2._processChunk (node-modules-polyfills:zlib:510:31)
at zlibBufferSync (node-modules-polyfills:zlib:229:17)
at Object.gunzipSync (node-modules-polyfills:zlib:173:10)
at CramFile._uncompress (file.js:247:27)
at CramFile.readBlock (file.js:298:12)
at async CramSlice.getBlocks (index.js:208:19)

This also could be a bug in the zlib polyfill, but I’m not really sure.
Code for a repro is here: https://codesandbox.io/s/ylt4t with the app running here: https://ylt4t.sse.codesandbox.io/.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15
we could possibly also improve docs related to vite in our readme’s…will consider what can be done
a new version of @gmod/cram is published (v1.6.1) that switches to pako for browser bundles, so does not require a zlib polyfill
a similar thing was also added to @gmod/bbi which also used zlib and was published as v1.0.32 so it is possible you can use the code without a zlib polyfill now, but I haven’t confirmed that