Skip to content

Regression in v1.30.2? "Error: failed to deserialize; expected an object-like struct named Specifier, found ()" #1081

Description

@gossi

I'm switching from postcss/CSS Modules to lightningcss. To do so, I need to replace composes feature.

Luckily the trick is on the website itself using custom At-Rules with @mixin.

I copied the code over to my config, it worked hooray 🎉

... until it suddenly stopped with the error:

Error: failed to deserialize; expected an object-like struct named Specifier, found ()

The code in question was this:

@mixin --base {
  color: red;

  & > header {
    color: red;
  }

  &:has(header) {
    padding-block-start: var(--spacing-container0);
  }
}

.page {
  @apply --base;
}

Particularly this caused the error:

  &:not(:has(header)) {
    padding-block-start: var(--spacing-container0);
  }

I searched for the error message and found this issue: nativewind/nativewind#1605 and yeah, once I pinned lightningcss to v1.30.1 it worked.

The error was showing up in v1.30.2.

Here is my config:

const { code, map } = bundle({
  filename: config.input,
  minify: false,
  exclude: Features.Nesting,
  customAtRules: {
    mixin: {
      prelude: '<custom-ident>',
      body: 'style-block'
    },
    apply: {
      prelude: '<custom-ident>'
    }
  },
  visitor: {
    Rule: {
      custom: {
        mixin(rule) {
          mixins.set(rule.prelude.value, rule.body.value);

          return [];
        },
        apply(rule) {
          if (mixins.has(rule.prelude.value)) {
            return mixins.get(rule.prelude.value);
          }

          return [];
        }
      }
    }
  }
});

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions