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.4k stars 510 forks source link

"Module not found" in Deno Complied Binary #464

Closed 7flash closed 10 months ago

7flash commented 10 months ago

1) save minimal example to repoduce to second-nov24.ts https://github.com/gildas-lormeau/zip.js#hello-world

import {
  ZipWriter,
} from "https://deno.land/x/zipjs/index.js";

const zipFileStream = new TransformStream();
const zipFileBlobPromise = new Response(zipFileStream.readable).blob();
const helloWorldReadable = new Blob(["Hello world!"]).stream();

const zipWriter = new ZipWriter(zipFileStream.writable);
await zipWriter.add("hello.txt", helloWorldReadable);

2) it works as expected

deno run --allow-all second-nov24.ts
Hello world!

3) it fails in runtime when compiled binary

deno compile second-nov24.ts  && ./second-nov24

Compile file:///Users/gur/Documents/galaxy-browser/desktop/second-nov24.ts to second-nov24
error: Uncaught (in worker "") Module not found: blob:null/7da990cf-8732-409b-9f16-273562636bca
error: Uncaught (in promise) Error: Unhandled error in child worker.
    at Worker.#pollControl (ext:runtime/11_workers.js:159:19)
    at eventLoopTick (ext:core/01_core.js:183:11)
gildas-lormeau commented 10 months ago

I guess web workers or blob URIs are not supported within compiled binaries. I need to check the documentation. Meanwhile, you can disable the usage of web workers by calling zip.configure({ useWebWorkers: false }) in order to circumvent this issue.

7flash commented 10 months ago

I guess web workers or blob URIs are not supported within compiled binaries. I need to check the documentation. Meanwhile, you can disable the usage of web workers by calling zip.configure({ useWebWorkers: false }) in order to circumvent this issue.

Thanks it works https://github.com/7flash/deno-webui/commit/aacd9ab694c199c987982d2565a83d468687653d

gildas-lormeau commented 10 months ago

Actually, you might be able to use workers by using --include, as documented here: https://docs.deno.com/runtime/manual/tools/compiler#workers. The filename to pass as parameter is dist/z-worker.js.