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

  1. Deduplicate entry paths before calling bundle()
  2. If you need multiple output bundles sharing a source, run separate bundle invocations
  3. 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

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


AI-assisted analysis of swc-project/swc@5176682b65 (2026-08-17). Data as JSON: /api/errors/747bd240514d4dc7. Report an issue: GitHub.