{"record":{"id":"1d924cd321a8eaeb","repo":"zellij-org/zellij","slug":"dynamic-import-is-not-supported-at","errorCode":null,"errorMessage":"dynamic import is not supported at {}","messagePattern":"dynamic import is not supported at (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"xtask/src/assets.rs","lineNumber":157,"sourceCode":"        }\n        bundle.push_str(&chunk);\n        if !bundle.ends_with('\\n') {\n            bundle.push('\\n');\n        }\n    }\n\n    Ok(bundle)\n}\n\nfn flatten_module(module: &str, source: &str) -> anyhow::Result<String> {\n    let mut out = String::new();\n    let mut lines = source.lines().enumerate().peekable();\n\n    while let Some((index, line)) = lines.next() {\n        let location = || format!(\"{}.js:{}\", module, index + 1);\n\n        if line.contains(\"import(\") {\n            return Err(anyhow!(\"dynamic import is not supported at {}\", location()));\n        }\n\n        if let Some(rest) = line.strip_prefix(\"import \") {\n            if is_terminated_import(rest) {\n                validate_module_specifier(rest, &location())?;\n                continue;\n            }\n            let mut terminated = false;\n            for (_, continuation) in lines.by_ref() {\n                let trimmed = continuation.trim_start();\n                if trimmed.starts_with(\"} from \") && trimmed.ends_with(';') {\n                    validate_module_specifier(trimmed, &location())?;\n                    terminated = true;\n                    break;\n                }\n                if !is_import_binding_line(trimmed) {\n                    return Err(anyhow!(\"unrecognised import syntax at {}\", location()));\n                }","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/zellij-org/zellij/blob/98a0837077492d53dd252ab30bc3e43e41e504f4/xtask/src/assets.rs#L139-L175","documentation":"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.","triggerScenarios":"Writing `const mod = await import('./utils.js')` or `import('./x.js').then(...)` in any module under zellij-client/assets.","commonSituations":"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.","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"],"exampleFix":"// before\nconst { openLink } = await import('./links.js');\n\n// after\nimport { openLink } from './links.js';","handlingStrategy":"validation","validationCode":"# fail before bundling if any module mentions a dynamic import\nif grep -n 'import(' zellij-client/assets/*.js; then\n  echo \"dynamic import() found; convert to static imports\"; exit 1\nfi","typeGuard":"fn uses_dynamic_import(source: &str) -> bool {\n    source.lines().any(|line| line.contains(\"import(\"))\n}","tryCatchPattern":null,"preventionTips":["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"],"tags":["javascript","bundler","dynamic-import","assets"],"backgroundTag":null,"analyzedSha":"98a0837077492d53dd252ab30bc3e43e41e504f4","analyzedAt":"2026-08-16T13:02:01.396Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}