swc-project/swc · error
Multiple entries with same input path detected: {v:?}
Error message
Multiple entries with same input path detected: {v:?} What it means
Bundler::determine_entries inserts each entry into the plan keyed by ModuleId (resolved absolute path). If a second entry maps to an id already present, the insert returns the previous BundleKind and swc bails with 'Multiple entries with same input path detected'. Entry display names may differ, but each resolved input path must be unique.
Source
Thrown at crates/swc_bundler/src/bundler/chunk/plan/mod.rs:56
.collect()
}
}
impl<L, R> Bundler<'_, L, R>
where
L: Load,
R: Resolve,
{
pub(super) fn determine_entries(
&self,
entries: FxHashMap<String, TransformedModule>,
) -> Result<(Plan, ModuleGraph, Vec<Vec<ModuleId>>), Error> {
let mut builder = PlanBuilder::default();
let mut analyzer = GraphAnalyzer::new(&self.scope);
for (name, module) in entries {
if let Some(v) = builder.kinds.insert(module.id, BundleKind::Named { name }) {
bail!("Multiple entries with same input path detected: {v:?}")
}
analyzer.load(module.id);
}
let res = analyzer.into_result();
// dbg!(&builder.cycles);
Ok((
Plan {
entries: builder.kinds,
all: res.all,
},
res.graph,
res.cycles,
))
}
}View on GitHub (pinned to 5176682b65)
Solutions
- Deduplicate entry paths before calling bundle()
- If you need multiple output bundles sharing a source, run separate bundle invocations
- Verify symlink/resolver canonicalization when you believe two paths are distinct
Example fix
// before (Rust)
let entries = vec![
("app".into(), "./mod.js".into()),
("lib".into(), "./mod.js".into()),
];
// after (Rust)
let entries = vec![("app".into(), "./mod.js".into())]; Defensive patterns
Strategy: validation
Validate before calling
// Rust - canonicalize and dedupe entries before bundling
use std::collections::HashSet;
let mut seen = HashSet::new();
let entries: Vec<(String, PathBuf)> = raw_entries
.into_iter()
.filter(|(_, path)| seen.insert(path.canonicalize().unwrap_or_else(|_| path.clone())))
.collect(); Prevention
- Deduplicate entry paths (after canonicalization) before calling bundle
- Run separate bundle invocations when one source must feed multiple outputs
- Validate generated entry lists in tests
When it happens
Trigger: Calling Bundler::bundle with entries like [("a", "./mod.js"), ("b", "./mod.js")] - two names for one file; also entries that differ textually but resolve (symlinks, resolver canonicalization) to the same path.
Common situations: Generated entry lists that concatenate globs; monorepos referencing the same file via different specifiers; config-driven bundlers merging entry maps without dedup.
Related errors
- Modules reexported with `export * as foo from './foo'` shoul
- Plan does not contain bundle kind for {:?}
- Decl in ExportDecl: {:?}
- internal error: entered unreachable code
- Non-computed member expression with property other than iden
AI-assisted analysis of swc-project/swc@5176682b65 (2026-08-17).
Data as JSON: /api/errors/747bd240514d4dc7.
Report an issue: GitHub.