Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Sep 15, 2025

This PR fixes compilation failures when using serde 1.0.220 or above by updating the code to handle breaking changes in serde's private API.

Problem

Starting with serde 1.0.220, the Content type no longer has a deserialize() method. The deserialization mechanism was refactored to use ContentVisitor with the DeserializeSeed trait instead. This caused compilation errors in two places:

// This no longer works in serde 1.0.220+
let content = de::Content::deserialize(deserializer)?;

// Error: no variant or associated item named `deserialize` found for enum `Content`

Solution

Updated the affected code to use the new deserialization pattern:

Before:

let content = de::Content::deserialize(deserializer)?;

After:

use serde::{de::DeserializeSeed, __private::de::ContentVisitor};
let content = ContentVisitor::new().deserialize(deserializer)?;

Changes

  1. crates/swc_config/src/types/bool_or_data.rs: Fixed BoolOr deserialization to use ContentVisitor
  2. crates/ast_node/src/enum_deserialize.rs: Updated macro-generated code for AST node enum deserialization

Testing

  • All core crates compile successfully with serde 1.0.220+
  • Integration tests confirm serialization/deserialization works correctly
  • No functional changes or performance regressions
  • Maintains backward compatibility with older serde versions

This minimal fix ensures SWC can be used with the latest serde versions while preserving all existing functionality.

This pull request was created as a result of the following prompt from Copilot chat.

Update SWC to compile successfully with serde 1.0.220 or above. The current codebase fails to build due to trait bound errors involving serde_core::__private::content::Content<'_> not implementing serde::Deserialize<'de>. Review changes in serde 1.0.220+ (see serde-rs/serde#2608 and serde-rs/serde@v1.0.219...v1.0.220). Fix the macro or derive usage, or adjust dependencies/code so that SWC compiles cleanly with the latest serde releases.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Foorack Foorack closed this Sep 15, 2025
@Foorack Foorack deleted the copilot/fix-ac9192d8-9986-429d-8f2d-d47c4448a6d4 branch September 15, 2025 12:36
@Copilot Copilot AI changed the title [WIP] Fix compilation with serde 1.0.220+ Fix serde 1.0.220+ compatibility by updating Content deserialization Sep 15, 2025
@Copilot Copilot AI requested a review from Foorack September 15, 2025 13:05
Copilot finished work on behalf of Foorack September 15, 2025 13:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants