npm install @wasm-fmt/lua_fmtnpx jsr add @fmt/lua-fmtimport init, { format } from "@wasm-fmt/lua_fmt";
await init();
const input = `print "Hello World"`;
const formatted = format(input, "main.lua");
console.log(formatted);For Vite users:
Add "@wasm-fmt/lua_fmt" to optimizeDeps.exclude in your vite config:
{
"optimizeDeps": {
"exclude": ["@wasm-fmt/lua_fmt"]
}
}If you cannot change the vite config, you can use another import entry
import init, { format } from "@wasm-fmt/lua_fmt/vite";
// ...Thanks to:
- The StyLua project created by @JohnnyMorganz