Skip to content

ESM Export Error: getImports and finalizeInit not defined in stylua_lib.js #999

@christopher-buss

Description

@christopher-buss

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:

  1. Set up an ESM project ("type": "module" in package.json)
  2. Use Node.js v24.2.0
  3. Try to import anything that uses @johnnymorganz/stylua
  4. 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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions