Things work well in local development, but failed in production.
Steps to reproduce:
- Install
wasmoonbynpm install wasmoonin a Nextjs 14 project. - Create an engine according to its documentation.
const { LuaFactory } = require('wasmoon')
// Initialize a new lua environment factory// You can pass the wasm location as the first argument, useful if you are using wasmoon on a web environment and want to host the file by yourselfconst factory = new LuaFactory()// Create a standalone lua environment from the factoryconst lua = await factory.createEngine()- Create a route file whether using page or app directory.
- Using the engine to execute some lua strings in the route handler.
- Deploy it to Vercel production.
- Request the api, you will see the error.
Wasmoon uses emscripten to generate the wasm file, and there's a glue.js file to load and Instantiate the wasm module. In Vercel production environment, it couldn't find the wasm file. I tried to provide a http resource of that wasm file(This is supported by wasmoon), its instantiation failed too.
I really appreciated if anyone could help with this.