{"record":{"id":"9f481fe85d9b8c8e","repo":"swc-project/swc","slug":"failed-to-merge-into-module-does-not-exist","errorCode":null,"errorMessage":"failed to merge into {}: module {} does not exist in the map","messagePattern":"failed to merge into (.+?): module (.+?) does not exist in the map","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/swc_bundler/src/bundler/chunk/merge.rs","lineNumber":125,"sourceCode":"\n                {\n                    let helpers = *entry_info.swc_helpers.lock();\n                    let dep_helpers = *dep_info.swc_helpers.lock();\n\n                    let helpers = Helpers::from_data(helpers);\n                    let dep_helpers = Helpers::from_data(dep_helpers);\n\n                    helpers.extend_from(&dep_helpers);\n\n                    *entry_info.swc_helpers.lock() = helpers.data();\n                }\n\n                if *id == entry_id {\n                    return Modules::empty(injected_ctxt);\n                }\n\n                all.remove(id).unwrap_or_else(|| {\n                    unreachable!(\n                        \"failed to merge into {}: module {} does not exist in the map\",\n                        entry_id, id\n                    )\n                })\n            });\n\n            for dep in deps {\n                entry.add_dep(dep);\n            }\n\n            self.replace_import_specifiers(&entry_info, entry);\n            self.finalize_merging_of_entry(ctx, entry_id, entry);\n            self.remove_wrong_exports(ctx, &entry_info, entry);\n        })\n    }\n\n    #[allow(clippy::only_used_in_recursion)]\n    fn collect_all_deps(","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc_bundler/src/bundler/chunk/merge.rs#L107-L143","documentation":"Raised in merge_into_entry (bundler merge.rs:125). While folding dependency modules into the entry module's namespace object, the code removes each dependency from the merged-modules map; the invariant is that every dependency id was inserted earlier. If all.remove(id) returns None, the map is missing an expected module (bookkeeping divergence between chunk selection and merging), and the panic fires naming the missing module id.","triggerScenarios":"Thrown at crates/swc_bundler/src/bundler/chunk/merge.rs:125 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Log the chunk's full dependency list and the map keys before merging to find where the module was dropped","Ensure modules filtered out of merging (e.g. via keepModules or external config) are also excluded from the entry's dependency iteration","Replace the panic with an Error::ModuleNotFound-style diagnostic carrying the module id"],"exampleFix":null,"handlingStrategy":"validation","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"}