swc-project/swc · error

Targets

Error message

Targets: {:?}

What it means

A todo!() in targets_to_versions (preset_env_base query.rs:211). While folding a browserlist targets map into a Versions struct, the loop expects every entry to be handled by the Query/Version arms; the todo fires for a targets map entry that reaches an unhandled spot in the iteration (an unexpected map shape/entry). The {:?} dump of the Targets value identifies the exact configuration that hit the stub.

Solutions

  1. Inspect the dumped Targets value and fix the configuration to use supported forms (version strings or browserlist queries)
  2. Add the missing arm for the entry kind that reached the todo
  3. Validate the targets input against the supported schema before running the query
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at crates/preset_env_base/src/query.rs:211 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/6b95984059b77bdb. Report an issue: GitHub.

Appendix: source

Thrown at crates/preset_env_base/src/query.rs:211

            let mut result = Versions::default();
            for (k, v) in map.iter() {
                match v {
                    QueryOrVersion::Query(q) => {
                        let (versions, is_unknown) = q.exec().context("failed to run query")?;
                        unknown_version = unknown_version || is_unknown;

                        for (k, v) in versions.iter() {
                            result.insert(k, *v);
                        }
                    }
                    QueryOrVersion::Version(v) => {
                        result.insert(k, Some(*v));
                    }
                }
            }

            unimplemented!("Targets: {:?}", map)
        }
        _ => unimplemented!("Option<Targets>: {:?}", v),
    }
}

#[cfg(test)]
mod tests {
    use super::Query;

    #[test]
    fn test_empty() {
        let (res, unknown_version) = Query::Single("".into()).exec().unwrap();
        assert!(
            !res.is_any_target(),
            "empty query should return non-empty result"
        );
        assert!(
            !unknown_version,

View on GitHub (pinned to 5176682b65)