Closed JNY0606 closed 1 week ago
-- test.lua --
require 'a' function getAA() local aa = aa() return aa end
-- a.lua --
function aa() return 'aa' end
-- test.js --
import { LuaFactory } from 'wasmoon' import fs from 'fs' async function main() { const factory = new LuaFactory() const lua = await factory.createEngine() try { const lua_str = fs.readFileSync('test.lua', 'utf-8') await lua.doString(lua_str) const getAA = lua.global.get('getAA') console.log(getAA()) } finally { lua.global.close() } } main()
-- error report -- Uncaught Error Error: [string "require 'a'..."]:1: module 'a' not found
Wasmoon uses a sandboxed file system. For this to work you have to mount the file into that FS.
-- test.lua --
-- a.lua --
-- test.js --
-- error report -- Uncaught Error Error: [string "require 'a'..."]:1: module 'a' not found