zellij-org/zellij · error
dynamic import is not supported at {}
Error message
dynamic import is not supported at {} What it means
flatten_module is a line-based bundler that only understands static `import ... from './sibling.js';` statements. Any line containing the substring `import(` is rejected because a dynamic import cannot be stripped or inlined and would try to fetch a module at runtime in a single-file bundle.
Source
Thrown at xtask/src/assets.rs:157
}
bundle.push_str(&chunk);
if !bundle.ends_with('\n') {
bundle.push('\n');
}
}
Ok(bundle)
}
fn flatten_module(module: &str, source: &str) -> anyhow::Result<String> {
let mut out = String::new();
let mut lines = source.lines().enumerate().peekable();
while let Some((index, line)) = lines.next() {
let location = || format!("{}.js:{}", module, index + 1);
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()));
}View on GitHub (pinned to 98a0837077)
Solutions
- Replace the dynamic import with a static `import { x } from './utils.js';` at the top of the module
- Drop lazy-loading entirely: the bundle is one file, so a static import has identical effect
- If `import(` occurs in a string or comment, reword it so the substring disappears
Example fix
// before
const { openLink } = await import('./links.js');
// after
import { openLink } from './links.js'; Defensive patterns
Strategy: validation
Validate before calling
# fail before bundling if any module mentions a dynamic import
if grep -n 'import(' zellij-client/assets/*.js; then
echo "dynamic import() found; convert to static imports"; exit 1
fi Type guard
fn uses_dynamic_import(source: &str) -> bool {
source.lines().any(|line| line.contains("import("))
} Prevention
- Treat the web client as a no-bundler, single-scope codebase: static imports only
- Do not copy lazy-load patterns from bundler docs into these modules
- Add the grep pre-flight above to a pre-commit hook for zellij-client/assets
When it happens
Trigger: Writing `const mod = await import('./utils.js')` or `import('./x.js').then(...)` in any module under zellij-client/assets.
Common situations: Copying code from tutorials that lazy-load modules; attempting code-splitting (pointless here: everything is concatenated into app.js); even a string or comment containing `import(` triggers the check because it is a plain substring match per line.
Related errors
- duplicate top-level identifier '{}' declared in both '{}.js'
- unrecognised import syntax at {}
- unterminated import statement at {}
- unrecognised export syntax at {}
- unsupported export form at {}
AI-assisted analysis of zellij-org/zellij@98a0837077 (2026-08-16).
Data as JSON: /api/errors/1d924cd321a8eaeb.
Report an issue: GitHub.