Things work well in local development, but failed in production.
Steps to reproduce:
Install wasmoon by npm install wasmoon in 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 yourself
const factory = new LuaFactory()
// Create a standalone lua environment from the factory
const 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.
Aborted(RuntimeError: Aborted(Error: ENOENT: no such file or directory, open 'https:/unpkg.com/wasmoon/dist/glue.wasm'). Build with -sASSERTIONS for more info.)
I tried using outputFileTracingIncludes to include the wasm file in the output, but the deployment is always failed, then I added the outputFileTracingRoot option, and the deployment succeed, but the file was still not found in the deployment output, and still errors when execute the serverless function.