robbederks / downzip

NPM library to enable client-side code to stream potentially large files into a zipped download
MIT License
35 stars 12 forks source link

Fix ReadableStream (the lib doesn't work at all without it for me) #15

Closed GProst closed 3 years ago

GProst commented 3 years ago

I don't know how it worked for anyone before, it looks like after building Zip.js file Webpack removes ReadableStream from the code and just uses Node.js's require('stream').Readable. And at least in Chrome 87 this resulted in downloading an empty corrupted zip file for me.

You can search in the dist/downzip-sw.js for ReadableStream, you won't find any.

One solution would be to rename the constant to something other than ReadableStream like this:

const RStream = ReadableStream || require('stream').Readable

But as I understand this library is for in-browser usage hence we don't need this Node.js-related code


Btw, thanks for the library! Should really help us implementing what we want easily.

robbederks commented 3 years ago

Thanks for the fix! Pretty sure it somehow worked for me a while back, but the project I'm using this in was put on hold for the time being, so I haven't really tested it in the field much anymore.