{"record":{"id":"b94201859c47d6f1","repo":"swc-project/swc","slug":"module-item-found-but-is-es6-is-false","errorCode":null,"errorMessage":"module item found but is_es6 is false: {:?}","messagePattern":"module item found but is_es6 is false: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/swc_bundler/src/bundler/chunk/cjs.rs","lineNumber":142,"sourceCode":"                    pat: Pat::Ident(Ident::new(atom!(\"module\"), DUMMY_SP, local_ctxt).into()),\n                },\n                // exports\n                Param {\n                    span: DUMMY_SP,\n                    decorators: Default::default(),\n                    pat: Pat::Ident(Ident::new(atom!(\"exports\"), DUMMY_SP, local_ctxt).into()),\n                },\n            ],\n            decorators: Vec::new(),\n            span: DUMMY_SP,\n            body: Some(FunctionBody {\n                span: dep.span,\n                stmts: dep\n                    .body\n                    .into_iter()\n                    .map(|v| match v {\n                        ModuleItem::ModuleDecl(i) => {\n                            unreachable!(\"module item found but is_es6 is false: {:?}\", i)\n                        }\n                        ModuleItem::Stmt(s) => s,\n                        #[cfg(swc_ast_unknown)]\n                        _ => panic!(\"unable to access unknown nodes\"),\n                    })\n                    .collect(),\n            }),\n            is_generator: false,\n            is_async: false,\n            ..Default::default()\n        }),\n    }\n    .into();\n\n    // var load = __swcpack_require__.bind(void 0, moduleDecl)\n\n    VarDecl {\n        span: DUMMY_SP,","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc_bundler/src/bundler/chunk/cjs.rs#L124-L160","documentation":"A consistency check panic while building the CommonJS wrapper function in the bundler's chunk output (cjs.rs:142). The generated wrapper's body is assembled from module items; the invariant is that items are only emitted into the CJS interop wrapper when the module is treated as ES6 (is_es6). If a module item is present but the is_es6 flag is false, module classification and item collection have diverged, and the panic fires to expose that internal inconsistency.","triggerScenarios":"Thrown at crates/swc_bundler/src/bundler/chunk/cjs.rs:142 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Log the offending module item and its module id to find which module was misclassified","Ensure the module graph classification pass (which sets is_es6) runs before chunk item collection and uses the same criteria","Skip non-ES6 items in the CJS wrapper construction instead of panicking if the item is genuinely irrelevant"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5176682b65416c6b5de6b47379ae1588ea3ecb3f","analyzedAt":"2026-08-17T16:16:52.067Z","contentChangedAt":"2026-08-17T16:16:52.067Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}