Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to initialize LuaFactory in Vercel with custom wasm file path. #118

Open
pureliumy opened this issue Jun 12, 2024 · 1 comment
Open

Comments

@pureliumy
Copy link

Problem
Failed to initialize LuaFactory in Vercel with custom wasm file path.

Demo code

// This way we could load the wasm file in Vercel production environment.
const luaWasmFile = path.resolve('public/lib/glue.wasm');
const factory = new LuaFactory(luaWasmFile);

Error output

failed to asynchronously prepare wasm: TypeError: WebAssembly.instantiate(): Import #0 module="env" error: module is not an object or function

Remarks
I don't know whether it is related to the file import method or not, but I have tried many ways, only the above way worked in Vercel production environment.

/**
 * These didn't work in Vercel production environment, luaWasmFile will be not found.
 * 
 * 1. https://vercel.com/docs/functions/wasm
 * 2. https://github.com/Drumsin/aoe4-generated-map-debugger/pull/6/files
 */

import luaWasmFile from 'wasmoon/dist/glue.wasm';
const factory = new LuaFactory(luaWasmFile);
@pureliumy
Copy link
Author

I tried using a custom build wasmoon dist/index.js and glue.wasm, this error disappeared, but there was a new error when executed await factory.createEngine() - e is not a function.

I have no idea with what e is as the code was minified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant