lightningcss icon indicating copy to clipboard operation
lightningcss copied to clipboard

Unable to compose class named `default`

Open mrginglymus opened this issue 11 months ago • 1 comments

input:

.default {
  color: blue;
}

.foo {
  composes: default;
  color: red;
}

expected output:

{
  "default": {
    "name": "EgL3uq_default",
    "composes": [],
    "isReferenced": false
  },
  "foo": {
    "name": "EgL3uq_foo",
    "composes": [
      {
        "type": "local",
        "name": "EgL3uq_default"
      }
    ],
    "isReferenced": false
  }
}

actual output:

{
  "default": {
    "name": "EgL3uq_default",
    "composes": [],
    "isReferenced": false
  },
  "foo": {
    "name": "EgL3uq_foo",
    "composes": [],
    "isReferenced": false
  }
}

Playground Reproduction

mrginglymus avatar Feb 04 '25 11:02 mrginglymus

Ah, it appears the problem is that https://github.com/parcel-bundler/lightningcss/blob/fc7f350e5b26188941778514a1f0c0ae48282e72/src/values/ident.rs#L34-L37 disallows idents with these reserved names. However, I'm not sure that that is required by the css modules spec; it's certainly not explicitly mentioned, and the class references aren't really custom idents.

mrginglymus avatar Feb 04 '25 13:02 mrginglymus