parcel-bundler / parcel-bundler/lightningcss

unusedSymbols should also remove unused selectors when combined with a used selector

Open
#628 0 comments 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

Hi, I've been trying to reduce the size of my minified CSS bundle via the unusedSymbols option, and I've noticed that lightningcss won't remove classes in the unusedSymbols list, if they are combined with a selector that is used.

If I set unusedSymbols to ["foo"] And then run lightningcss on this css file:

.foo, .bar {
  color: red
}

I would assume the output would be:

.bar {
  color: red
}

Instead, the output still contains the .foo class:

.foo, .bar {
  color: red
}

here's a repro using the playgound

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 by reproducing the unusedSymbols case with a comma-separated selector containing one unused and one used class. Add a regression test showing that the unused selector is removed while the used selector and declaration remain, then verify the existing test suite passes.

Written by the indexing model from the issue text.

Assessment

Tech stack
css, rust
Domain
build-system, compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.