zellij-org/zellij · error

unrecognised export syntax at {}

Error message

unrecognised export syntax at {}

What it means

`export {` without a `from` clause (a bottom-of-file list re-exporting local bindings) is rejected. The flattener only supports two export forms: re-exports `export { x } from './mod.js';` (dropped, since imports vanish) and `export <declaration>` (keyword stripped).

Source

Thrown at xtask/src/assets.rs:189

                    break;
                }
                if !is_import_binding_line(trimmed) {
                    return Err(anyhow!("unrecognised import syntax at {}", location()));
                }
            }
            if !terminated {
                return Err(anyhow!("unterminated import statement at {}", location()));
            }
            continue;
        }

        if line.starts_with("export ") || line.starts_with("export{") {
            if line.starts_with("export {") {
                if line.contains(" from ") {
                    validate_module_specifier(line, &location())?;
                    continue;
                }
                return Err(anyhow!("unrecognised export syntax at {}", location()));
            }
            if line.starts_with("export default") || line.starts_with("export *") {
                return Err(anyhow!("unsupported export form at {}", location()));
            }
            let stripped = &line["export ".len()..];
            if !DECLARATION_PREFIXES
                .iter()
                .any(|prefix| stripped.starts_with(prefix))
            {
                return Err(anyhow!("unrecognised export syntax at {}", location()));
            }
            out.push_str(stripped);
            out.push('\n');
            continue;
        }

        out.push_str(line);
        out.push('\n');

View on GitHub (pinned to 98a0837077)

Solutions

  1. Move the export keyword onto the declaration: `export function doThing() {...}`
  2. If the intent is re-exporting another module's binding, add the from clause: `export { doThing } from './utils.js';`

Example fix

// before (rejected)
function doThing() {}
export { doThing };

// after
export function doThing() {}
Defensive patterns

Strategy: validation

Validate before calling

# bottom-of-file export lists without 'from' are unsupported
grep -nE '^export \{[^}]*\};?[[:space:]]*$' zellij-client/assets/*.js && { echo 'use export on the declaration itself'; exit 1; } || true

Type guard

fn is_bare_export_list(line: &str) -> bool {
    line.starts_with("export {") && !line.contains(" from ")
}

Prevention

When it happens

Trigger: Ending a module with `export { doThing };` to expose an already-declared function instead of marking the declaration itself as exported.

Common situations: Refactoring a module from per-function `export function` declarations to a CommonJS-style bottom export list; copying Node-style module patterns into the web client.

Related errors


AI-assisted analysis of zellij-org/zellij@98a0837077 (2026-08-16). Data as JSON: /api/errors/9f853694fd30aaf0. Report an issue: GitHub.