swc-project/swc · error
Module {} is not registered
Error message
Module {} is not registered What it means
Raised via unreachable!() in get_for_merging (bundler merge.rs:72). Before merging a chunk, the bundler looks up the module by ModuleId in its scope; the invariant is that every module scheduled for merging was already registered during load/analyze. If scope.get_module(id) returns None, the chunk's module list references a module the bundler never stored, and this panic reports that broken invariant, naming the unregistered ModuleId.
Source
Thrown at crates/swc_bundler/src/bundler/chunk/merge.rs:72
}
}
impl<L, R> Bundler<'_, L, R>
where
L: Load,
R: Resolve,
{
pub(super) fn get_for_merging(
&self,
ctx: &Ctx,
id: ModuleId,
is_entry: bool,
) -> Result<Modules, Error> {
self.run(|| {
let info = self
.scope
.get_module(id)
.unwrap_or_else(|| unreachable!("Module {} is not registered", id));
let mut module = self.apply_hooks(id, is_entry)?;
module = self.prepare_for_merging(ctx, &info, module)?;
if !is_entry {
module = self.wrap_cjs_module(ctx, &info, module)?;
}
self.replace_cjs_require_calls(&info, &mut module, is_entry);
Ok(module)
})
}
/// This method sort modules.
pub(super) fn merge_into_entry(
&self,
ctx: &Ctx,
entry_id: ModuleId,
entry: &mut Modules,View on GitHub (pinned to 5176682b65)
Solutions
- Check for and surface load/analyze errors that prevented the module from being registered before chunking
- Ensure all dependency modules are resolved and registered before modules are assigned to chunks
- Convert the unreachable! into a proper bundler Error including the ModuleId so callers can report it
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/swc_bundler/src/bundler/chunk/merge.rs:72 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of swc-project/swc@5176682b65 (2026-08-17).
Data as JSON: /api/errors/511b7f882375b8da.
Report an issue: GitHub.