Unverified Commit a7c56a5b authored by Benjamin Woodruff's avatar Benjamin Woodruff Committed by GitHub

fix(turbopack-ecmascript-plugins): Accept a partial object for…

fix(turbopack-ecmascript-plugins): Accept a partial object for StyledComponentsTransformConfig (#69474)

`StyledComponentsTransformConfig` should've used `#[serde(default)]` to
allow the user to provide a partial object with only some of the fields.

https://serde.rs/container-attrs.html#default

> When deserializing, any missing fields should be filled in from the
struct's implementation of `Default`. Only allowed on structs.

Without that, when serde tries to deserialize, it is expecting that the
object has all of it's fields filled in, and breaks because you've only
got two of them. The test suite only ever tested `styledComponents:
true` (not using an object), so it missed this.

## Test Plan

```
pnpm swc-build-native
TURBOPACK=1 TURBOPACK_DEV=1 pnpm test test/development/basic/styled-components
```
parent dc6408f5
module.exports = {
compiler: {
styledComponents: true,
styledComponents: {
displayName: true,
},
},
}
......@@ -14,7 +14,7 @@ pub struct OptionStyledComponentsTransformConfig(Option<Vc<StyledComponentsTrans
#[turbo_tasks::value(shared)]
#[derive(Clone, Debug)]
#[serde(rename_all = "camelCase")]
#[serde(default, rename_all = "camelCase")]
pub struct StyledComponentsTransformConfig {
pub display_name: bool,
pub ssr: bool,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment