zellij-org/zellij · error

unrecognised import syntax at {}

Error message

unrecognised import syntax at {}

What it means

Raised while flattening a multi-line import: after a line starting with `import ` that is not a terminated single-line import, every continuation line must be a plain binding list (only [A-Za-z0-9_$ ,] characters) until a line starting with `} from ` and ending with `;`. Any other continuation line is rejected as unrecognised syntax.

Source

Thrown at xtask/src/assets.rs:174

        if line.contains("import(") {
            return Err(anyhow!("dynamic import is not supported at {}", location()));
        }

        if let Some(rest) = line.strip_prefix("import ") {
            if is_terminated_import(rest) {
                validate_module_specifier(rest, &location())?;
                continue;
            }
            let mut terminated = false;
            for (_, continuation) in lines.by_ref() {
                let trimmed = continuation.trim_start();
                if trimmed.starts_with("} from ") && trimmed.ends_with(';') {
                    validate_module_specifier(trimmed, &location())?;
                    terminated = true;
                    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()));

View on GitHub (pinned to 98a0837077)

Solutions

  1. Collapse the import to a single line: `import { a, b } from './utils.js';`
  2. Keep multi-line imports to plain comma-separated names, with the closing line exactly `} from './name.js';` (space after `}`, trailing semicolon)
  3. Remove comments and aliases from import blocks

Example fix

// before (rejected)
import {
  // core helpers
  a as alpha,
} from './utils.js'

// after
import { a } from './utils.js';
Defensive patterns

Strategy: validation

Validate before calling

# reject multi-line imports that are not plain binding lists
awk '/^import / && !/;$/ {in_import=1; next} in_import {
  if ($0 !~ /^[[:space:]]*[A-Za-z0-9_$ ,]+[[:space:]]*$/ && $0 !~ /^[[:space:]]*} from \.\/.*\.js;$/) {
    print FILENAME ":" NR ": suspicious import continuation: " $0
  }
  /;$/ {in_import=0}
}' zellij-client/assets/*.js

Type guard

fn is_import_binding_line(line: &str) -> bool {
    line.trim_end_matches(',')
        .chars()
        .all(|c| c.is_alphanumeric() || c == '_' || c == '$' || c == ' ')
}

Prevention

When it happens

Trigger: A multi-line import with a default binding (`import d, {`), a comment inside the binding block, `as` aliasing with unusual characters, or a closing line like `}from './x.js'` (missing space after `}` or missing trailing semicolon).

Common situations: Copy-pasted prettier-formatted imports containing aliases or comments; hand-edited import blocks; minified imports without spaces; merge-conflict residue inside imports.

Related errors


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