{"record":{"id":"6453cc699693b85e","repo":"swc-project/swc","slug":"module-string-names-unimplemented-6453cc","errorCode":null,"errorMessage":"module string names unimplemented","messagePattern":"module string names unimplemented","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/swc_bundler/src/bundler/export.rs","lineNumber":229,"sourceCode":"                    .info\n                    .items\n                    .entry(named.src.clone().map(|v| *v))\n                    .or_default();\n                for s in &mut named.specifiers {\n                    match s {\n                        ExportSpecifier::Namespace(n) => {\n                            match &mut n.name {\n                                ModuleExportName::Ident(name) => {\n                                    name.ctxt = self.export_ctxt;\n\n                                    need_wrapping = true;\n                                    v.push(Specifier::Namespace {\n                                        local: name.clone().into(),\n                                        all: true,\n                                    })\n                                }\n                                ModuleExportName::Str(..) => {\n                                    unimplemented!(\"module string names unimplemented\")\n                                }\n                                #[cfg(swc_ast_unknown)]\n                                _ => panic!(\"unable to access unknown nodes\"),\n                            };\n                        }\n                        ExportSpecifier::Default(d) => {\n                            v.push(Specifier::Specific {\n                                local: d.exported.clone().into(),\n                                alias: Some(Id::new(atom!(\"default\"), SyntaxContext::empty())),\n                            });\n                        }\n                        ExportSpecifier::Named(n) => {\n                            let orig = match &mut n.orig {\n                                ModuleExportName::Ident(ident) => ident,\n                                ModuleExportName::Str(..) => {\n                                    unimplemented!(\"module string names unimplemented\")\n                                }\n                                #[cfg(swc_ast_unknown)]","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/swc-project/swc/blob/d7d74346665e36e692aa07e13d4ee3ee692ee35c/crates/swc_bundler/src/bundler/export.rs#L211-L247","documentation":"When swc_bundler collects export metadata for a module (crates/swc_bundler/src/bundler/export.rs), it builds internal Specifier records. For `export * as ns from './mod'` it handles only identifier names; a string namespace name (`export * as \"ns\" from './mod'`, ModuleExportName::Str) reaches unimplemented!() at export.rs:229 and panics. This is a known capability gap: the bundler predates ES2022 arbitrary module namespace names.","triggerScenarios":"A module in the bundle graph contains `export * as \"name with spaces\" from './lib'` (or any string alias on a namespace re-export). During export collection ExportSpecifier::Namespace matches n.name = ModuleExportName::Str and the panic fires.","commonSituations":"Index/barrel files re-exporting namespaces under marketing names or names with dashes; code produced by code generators; third-party dependencies shipping ES2022 re-exports. Anything downstream of swc_bundler (spack-style tools, custom Rust pipelines) hits it.","solutions":["Replace the string alias with a valid identifier: `export * as \"my-ns\" from './lib'` -> `export * as myNs from './lib'`.","Grep the graph (including node_modules) for `export * as \"` and patch the offending file or dependency.","Add a pre-bundling SWC pass that rewrites string namespace aliases to identifiers.","Track upstream swc_bundler support for module string names; until then externalize or pre-bundle that module with another tool."],"exampleFix":"// before\nexport * as \"my-ns\" from './lib';\n\n// after\nexport * as myNs from './lib';","handlingStrategy":"validation","validationCode":"// Reject `export * as \"str\" from` before bundling\nuse swc_ecma_ast::{ExportSpecifier, ModuleDecl, ModuleExportName, ModuleItem};\nfor item in &module.body {\n    if let ModuleItem::ModuleDecl(ModuleDecl::ExportNamedDecl(d)) = item {\n        if let Some(specifiers) = d.decl.as_ref().and_then(|_| None).or(match &d.specifiers { s if !s.is_empty() => Some(s), _ => None }) {\n            for s in specifiers {\n                if let ExportSpecifier::Namespace(ns) = s {\n                    if matches!(ns.name, ModuleExportName::Str(_)) {\n                        anyhow::bail!(\"string namespace alias not supported by swc_bundler\");\n                    }\n                }\n            }\n        }\n    }\n}","typeGuard":"fn has_string_namespace_reexport(m: &swc_ecma_ast::Module) -> bool {\n    use swc_ecma_ast::*;\n    m.body.iter().any(|i| matches!(i,\n        ModuleItem::ModuleDecl(ModuleDecl::ExportNamedDecl(d))\n            if d.specifiers.iter().any(|s| matches!(s,\n                ExportSpecifier::Namespace(ns) if matches!(ns.name, ModuleExportName::Str(_))))))\n}","tryCatchPattern":"match std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| bundler.bundle(part)?)) {\n    Ok(r) => r,\n    Err(p) if p.downcast_ref::<&str>().map_or(false, |m| m.contains(\"module string names\")) => {\n        anyhow::bail!(\"rewrite `export * as \\\"ns\\\" from` to an identifier alias before bundling\")\n    }\n    Err(p) => std::panic::resume_unwind(p),\n}","preventionTips":["Normalize all namespace re-export aliases to identifiers in shared style rules/review checklists.","Search vendor code for `export * as \"` when onboarding new dependencies.","Keep a pre-bundle AST normalization pass (string alias -> ident) in the build pipeline.","Test bundling of every barrel file, since re-exports concentrate the risky syntax."],"tags":["swc","bundler","esm","es2022","module-string-names","panic","exports","namespace-reexport"],"backgroundTag":null,"analyzedSha":"d7d74346665e36e692aa07e13d4ee3ee692ee35c","analyzedAt":"2026-08-16T12:41:13.160Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}