nika-begiashvili / libarchivejs

Archive library for browsers
MIT License
285 stars 35 forks source link

wasm streaming compile failed: TypeError: WebAssembly: Response has unsupported MIME type #61

Closed Edwardl256 closed 9 months ago

Edwardl256 commented 10 months ago

Hello. Trying out this lib for the first time and I'm getting errors. At first I tried linking through some CDN but the workerUrl did not like loading remote content. I then downloaded "Latest Release" and unpacked everything into a folder (edwardleuf.org/js/libarchivejs...) and tried again, but I get this compile error. Searching around tells me I need to add the wasm mime type to a server config file, but I don't have that access. I also don't have npm access so that is why I did not install it in that way.

Current error message:

"wasm streaming compile failed: TypeError: WebAssembly: Response has unsupported MIME type '' expected 'application/wasm'"        [worker-bundle.js:1:69897]
"falling back to ArrayBuffer instantiation"                                                                                       [worker-bundle.js:1:69897]
message: "FileReader.readAsArrayBuffer: Argument 1 is not an object."
stack: "open@https://edwardleuf.org/js/libarchivejs/dist/worker-bundle.js:1:493
self.onmessage@https://edwardleuf.org/js/libarchivejs/dist/worker-bundle.js:1:71325
EventHandlerNonNull*@https://edwardleuf.org/js/libarchivejs/dist/worker-bundle.js:1:71172
@https://edwardleuf.org/js/libarchivejs/dist/worker-bundle.js:1:72016"

Quick implementation for testing purposes:

<html>
<body>
<script type="importmap">
{
    "imports":
    {
        "ARC": "/js/libarchivejs/main.js"
    }
}
</script>
<script type="module">

import { Archive } from "ARC";
Archive.init({workerUrl: "/js/libarchivejs/dist/worker-bundle.js"});

const arc = await Archive.open("ponedward.7z");

</script>
</body>
</html>
nika-begiashvili commented 9 months ago

Your server should return correct mime type 'application/wasm'