{"record":{"id":"3b6779dd29815ffd","repo":"swc-project/swc","slug":"corejs-version-other-than-2-3","errorCode":null,"errorMessage":"corejs version other than 2 / 3","messagePattern":"corejs version other than 2 / 3","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/swc_ecma_preset_env/src/lib.rs","lineNumber":458,"sourceCode":"            Some(Mode::Usage) => {\n                let mut r = match self.corejs {\n                    Version { major: 2, .. } => {\n                        let mut v = corejs2::UsageVisitor::new(self.targets.clone());\n                        m.visit_with(&mut v);\n\n                        v.required\n                    }\n                    Version { major: 3, .. } => {\n                        let mut v = corejs3::UsageVisitor::new(\n                            self.targets.clone(),\n                            self.shipped_proposals,\n                            self.corejs,\n                        );\n                        m.visit_with(&mut v);\n                        v.required\n                    }\n\n                    _ => unimplemented!(\"corejs version other than 2 / 3\"),\n                };\n\n                if regenerator::is_required(m) {\n                    r.insert(\"regenerator-runtime/runtime.js\");\n                }\n\n                r\n            }\n            Some(Mode::Entry) => match self.corejs {\n                Version { major: 2, .. } => {\n                    let mut v = corejs2::Entry::new(self.targets.clone(), self.regenerator);\n                    m.visit_mut_with(&mut v);\n                    v.imports\n                }\n\n                Version { major: 3, .. } => {\n                    let mut v =\n                        corejs3::Entry::new(self.targets.clone(), self.corejs, !self.regenerator);","sourceCodeStart":440,"sourceCodeEnd":476,"githubUrl":"https://github.com/swc-project/swc/blob/d7d74346665e36e692aa07e13d4ee3ee692ee35c/crates/swc_ecma_preset_env/src/lib.rs#L440-L476","documentation":"`swc_ecma_preset_env` injects core-js polyfill imports and only implements usage-mode visitors for core-js major 2 and major 3. The `env.coreJs` config value is parsed into a semver `Version`; any other major reaches `_ => unimplemented!(\"corejs version other than 2 / 3\")` — this site is the `Mode::Usage` branch at lib.rs:458.","triggerScenarios":"Set `env.coreJs` to a version whose major is neither 2 nor 3 (e.g. \"4\") while `env.mode` is `usage` and polyfills are enabled.","commonSituations":"Copying config from Babel projects already on core-js 4; adopting a new core-js major before swc supports it; typos like `coreJs: \"30\"`.","solutions":["Set `env.coreJs` to \"3\" (or \"2\" only if you must match an old dependency tree)","Verify the installed core-js package version matches the configured string","Upgrade swc once support for the new core-js major lands; track the upstream issue"],"exampleFix":"// .swcrc before\n{ \"env\": { \"mode\": \"usage\", \"coreJs\": \"4\" } }\n\n// after\n{ \"env\": { \"mode\": \"usage\", \"coreJs\": \"3\" } }","handlingStrategy":"validation","validationCode":"// Validate coreJs config before invoking swc\nconst major = Number(String(config.env?.coreJs ?? '3').split('.')[0]);\nif (major !== 2 && major !== 3) throw new Error(`coreJs ${config.env.coreJs} unsupported; use \"2\" or \"3\"`);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin `env.coreJs` to the exact installed core-js major (usually \"3\")","Add a startup assertion on the parsed major version in tools that wrap swc config"],"tags":["preset-env","core-js","polyfill","config"],"backgroundTag":null,"analyzedSha":"d7d74346665e36e692aa07e13d4ee3ee692ee35c","analyzedAt":"2026-08-16T12:41:13.160Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}