parcel-bundler / parcel-bundler/lightningcss

CSS Modules pattern crashes using [name]

Open
#516 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
7.7k
Forks
302
PR merge metrics
No merged PRs in 30d

Description

Specifying any pattern in the cssModules option which includes [name] crashes for me with the following message:

thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', /Users/runner/work/lightningcss/lightningcss/src/css_modules.rs:119:39
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

For example with the code from the docs:

const {code, map, exports} = transform({
  cssModules: {
    pattern: 'my-company-[name]-[hash]-[local]'
  },
  code: Buffer.from(`
    .logo {
      background: skyblue;
    }
  `)
})

Removing the [name] segment builds as expected

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at src/css_modules.rs:119 and reproduce the crash with the CSS Modules pattern from the issue body, including [name]. Confirm the fix by rerunning that example and checking that the transformation completes without a panic and produces the expected class name.

Written by the indexing model from the issue text.

Assessment

Tech stack
css, rust
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.