swc-project/swc · error · anyhow::Error
failed to deserialize .swcrc (json) file: {msg}: {line}:{col
Error message
failed to deserialize .swcrc (json) file: {msg}: {line}:{column} What it means
parse_swcrc could not deserialize the .swcrc file as JSON; convert_json_err classifies the serde_json failure (io, syntax, data, eof) and embeds line:column. Raised while loading configuration, before any file is compiled — the config file itself is broken.
Source
Thrown at crates/swc/src/lib.rs:1429
#[cfg_attr(debug_assertions, tracing::instrument(skip_all))]
fn load_swcrc(path: &Path) -> Result<Rc, Error> {
let content = read_to_string(path).context("failed to read config (.swcrc) file")?;
parse_swcrc(&content)
}
fn parse_swcrc(s: &str) -> Result<Rc, Error> {
fn convert_json_err(e: serde_json::Error) -> Error {
let line = e.line();
let column = e.column();
let msg = match e.classify() {
Category::Io => "io error",
Category::Syntax => "syntax error",
Category::Data => "unmatched data",
Category::Eof => "unexpected eof",
};
Error::new(e).context(format!(
"failed to deserialize .swcrc (json) file: {msg}: {line}:{column}"
))
}
let v = parse_to_serde_value(
s.trim_start_matches('\u{feff}'),
&ParseOptions {
allow_comments: true,
allow_trailing_commas: true,
allow_loose_object_property_names: false,
},
)?
.ok_or_else(|| Error::msg("failed to deserialize empty .swcrc (json) file"))?;
if let Ok(rc) = serde_json::from_value(v.clone()) {
return Ok(rc);
}
View on GitHub (pinned to 5176682b65)
Solutions
- Fix the JSON at the reported line:column in .swcrc
- Ensure the file matches the expected Rc config schema
- Remove comments/trailing commas or use the JSONC-aware loading path
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/swc/src/lib.rs:1429 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/320d0955834f1de6.
Report an issue: GitHub.