ceifa/wasmoon

Ability to be used offline

TechStudent10 opened this issue · 10 comments

I'm building an Electron app that utilizes Wasmoon. When I went off the grid and attempt to use my app, I see that wasmoon fetches a file called glue.wasm. Is there anyway for me to download this file and provide it to wasmoon.

Thanks.

image

ceifa commented

There is no need to be online to use wasmoon. You can use the local copy of the wasm file if you want.
Example of this using webpack: Drumsin/aoe4-generated-map-debugger#6

There is no need to be online to use wasmoon. You can use the local copy of the wasm file if you want. Example of this using webpack: Drumsin/aoe4-generated-map-debugger#6

Thank you!

Apparently you cannot use this import statement in TypeScript...

image

@ceifa should note that I'm not using webpack, but rather Vite.

@ceifa please get back to me. Once again, I'm using Vite (TypeScript) and I've moved to Tauri. When building it, the app fails to fetch because glue.wasm is being served over http. I can't build my application without removing wasmoon.

ceifa commented

This will be fixed on the next release, for now you can just pass the url as parameter to the factory:

new LuaFactory("https://unpkg.com/wasmoon/dist/glue.wasm")

This will be fixed on the next release, for now you can just pass the url as parameter to the factory:

new LuaFactory("https://unpkg.com/wasmoon/dist/glue.wasm")

You misunderstood me. While this is a temporary fix, I want to be able to serve it offline.

Finally found a fix. If you are using Vite, you need to copy the glue.wasm file from node_modules/wasmoon/dist/ to your assets/public folder. Then, you can instantiate LuaFactory like so:

new LuaFactory("/glue.wasm")
gsw945 commented

below is working for me:

import wasmoonGlueUrl from "wasmoon/dist/glue.wasm?url"

const factory = new LuaFactory(wasmoonGlueUrl)

ref: