gildas-lormeau / zip.js

JavaScript library to zip and unzip files supporting multi-core compression, compression streams, zip64, split files and encryption.
https://gildas-lormeau.github.io/zip.js
BSD 3-Clause "New" or "Revised" License
3.39k stars 510 forks source link

Error in compiled deno executable #519

Closed Mutefish0 closed 2 months ago

Mutefish0 commented 2 months ago

When running deno executable, the following error occurs:

error: Uncaught (in worker "") Module not found: blob:null/d75b07ad-f560-48f7-ad16-ec44df0eaca3
error: Uncaught (in promise) Error: Unhandled error in child worker.
    at Worker.#pollControl (ext:runtime/11_workers.js:204:19)
    at eventLoopTick (ext:core/01_core.js:168:7)

Because Deno's Worker does not support blob URLs after being compiled into an executable file, there is the issue: https://github.com/denoland/deno/issues/23431

As suggested, can we use a base64 encoded data URL instead of a blob URL since both can work?

https://github.com/gildas-lormeau/zip.js/blob/969f6589f3a979a9ed7eb6c6dfa8e32f8c51a62a/lib/z-worker-inline-template.js#L37

for example:

const uri = () => `data:text/javascript;base64,${btoa(__workerCode__)}`;
gildas-lormeau commented 2 months ago

I've just published a new version 2.7.46 which adds the export ./data-uri. So, you just have to import @zip-js/zip-js/data-uri to fix the issue with the compiled code.