swc-project/swc · error
swcify: {:?}
Error message
swcify: {:?} What it means
Converting a Babel/ESTree class body back to SWC AST (swcify) handles only Method, PrivateMethod, Prop, and PrivateProp elements. A class static block (ClassBodyEl::StaticBlock, `static { ... }`) or any other variant falls into the catch-all and panics with `unimplemented!("swcify: ...")`.
Source
Thrown at crates/swc_estree_compat/src/swcify/class.rs:35
impl Swcify for ClassBody {
type Output = Vec<ClassMember>;
fn swcify(self, ctx: &Context) -> Self::Output {
self.body.swcify(ctx)
}
}
impl Swcify for ClassBodyEl {
type Output = ClassMember;
fn swcify(self, ctx: &Context) -> Self::Output {
match self {
ClassBodyEl::Method(v) => v.swcify(ctx),
ClassBodyEl::PrivateMethod(v) => v.swcify(ctx).into(),
ClassBodyEl::Prop(v) => v.swcify(ctx).into(),
ClassBodyEl::PrivateProp(v) => v.swcify(ctx).into(),
_ => {
unimplemented!("swcify: {:?}", self)
}
}
}
}
impl Swcify for swc_estree_ast::ClassMethod {
type Output = swc_ecma_ast::ClassMember;
fn swcify(self, ctx: &Context) -> Self::Output {
match self.kind.unwrap_or(ClassMethodKind::Method) {
ClassMethodKind::Get | ClassMethodKind::Set | ClassMethodKind::Method => {
let SwcifiedFunctionParams { this_param, params } =
swcify_function_params(self.params, ctx);
swc_ecma_ast::ClassMethod {
span: ctx.span(&self.base),
key: self.key.swcify(ctx),
function: Function {View on GitHub (pinned to 5176682b65)
Solutions
- Strip/transform static blocks out of the Babel AST before swcify (e.g. Babel plugin converting them into an IIFE-initialized static private field, or removing them when side-effect free)
- Implement a local conversion that maps ClassBodyEl::StaticBlock to swc_ecma_ast::ClassMember::StaticBlock before calling swcify
- Upgrade swc_estree_compat where the arm may exist
Example fix
// before (input parsed by Babel)
class C { static { init(C); } }
// after (lower the static block before swcify)
class C { static __init = (() => { init(C); })(); } Defensive patterns
Strategy: type-guard
Validate before calling
// JS: detect static blocks in the Babel AST before swcify
function hasStaticBlock(ast) {
return JSON.stringify(ast).includes('"type":"StaticBlock"');
} Type guard
function isSupportedClassBodyEl(el) {
return ['ClassMethod', 'ClassPrivateMethod', 'ClassProperty', 'ClassPrivateProperty']
.includes(el.type);
} Prevention
- Lower class static blocks (Babel plugin) before feeding ASTs to swcify
- Test the Babel->SWC path with an ES2022 fixture corpus
- Version-lock @babel/parser output shapes with the swc_estree_compat version you depend on
When it happens
Trigger: Running swcify on a Babel-parsed class that contains a `static { ... }` initialization block (ES2022), which SWC's ClassMember has as StaticBlock but this conversion path never constructs.
Common situations: Pipelines that parse with Babel and emit via SWC (or run SWC passes on Babel AST) on modern JS containing class static blocks; interop layers between Babel and SWC tooling.
Related errors
- Babel doesn't support this right now.
- module string names unimplemented
- swcify: {:?}
- failed to swcify arguments
- illegal conversion: Cannot convert {:?} to ClassBodyEl
AI-assisted analysis of swc-project/swc@5176682b65 (2026-08-17).
Data as JSON: /api/errors/368c7a671a835e2c.
Report an issue: GitHub.