Skip to content

Stylesheet visitor with ignored rule causes missing field 'value' error #1104

@justinbeaty

Description

@justinbeaty

Using vite 8 beta with lightningcss set as the transformer, but this doesn't seem specific to vite.

I have a very simple plugin that uses the StyleSheetExit visitor to make some rule modifications. I reduced the plugin so that it simply returns the passed in sheet variable. I get an error due to the type: 'ignored' rules.

// My Plugin:
{
    StyleSheetExit(sheet) {
        console.log(sheet)
        return sheet
    }
}

// Outputs: 
{
  rules: [
    { type: 'layer-statement', value: [Object] },
    { type: 'font-face', value: [Object] },
    { type: 'font-face', value: [Object] },
    { type: 'font-face', value: [Object] },
    { type: 'font-face', value: [Object] },
    { type: 'font-feature-values', value: [Object] },
    { type: 'ignored' },
    { type: 'ignored' }
  ],
  sources: [
    '/path/to/project/apps/website/src/css/index.css',
    '/path/to/project/packages/ui-kit/style.css'   
  ],
  sourceMapUrls: [ null, null ],
  licenseComments: []
}

It looks like it comes from here since there is no value property. Either removing the ignored rules from the array or setting the value property to an empty string prevents the issue.

let content = value.ok_or_else(|| serde::de::Error::missing_field("value"))?;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions