ESM Export Error: getImports and finalizeInit not defined in stylua_lib.js
Environment:
- Node.js: v24.2.0
- Package: @johnnymorganz/stylua (latest)
- Module type: ESM ("type": "module")
- Build tool: tsup with format: ["esm"]
What's happening:
I'm getting a build error because stylua_lib.js is trying to export functions that don't actually exist:
// Line 789 in node_modules/@johnnymorganz/stylua/stylua.web/stylua_lib.js export { getImports as __getImports, finalizeInit as __finalizeInit }
The error: SyntaxError: Export 'getImports' is not defined in module at compileSourceTextModule (node:internal/modules/esm/utils:351:16)
What I found: Looking through the file, there's no getImports or finalizeInit function anywhere. The actual functions seem to be named __wbg_finalize_init and __wbg_get_imports.
It looks like the wasm-bindgen build process is generating the wrong export names - maybe there's a mismatch between what gets generated and what the export statement expects?
How to reproduce:
- Set up an ESM project ("type": "module" in package.json)
- Use Node.js v24.2.0
- Try to import anything that uses @johnnymorganz/stylua
- Run the build process
The problem: This completely breaks any ESM project that tries to use stylua (directly or through other packages like eslint-plugin-format-lua).