parcel-bundler / parcel-bundler/lightningcss

`RuleExit` doesn't work for custom at-rules

Open
#480 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

This pretty much summarizes it:

@global {
  h1 {
    color: red;
  }
}
let inGlobal = 0;


lightningcss.transform({
  code: Buffer.from(content),
  filename: ctx.ns,
  minify: true,
  targets: lightningcss.browserslistToTargets(browserslist(ctx.opts.browserslist || 'defaults')),
  drafts: {
    nesting: true,
    customMedia: true,
  },
  customAtRules: {
    global: {
      body: 'rule-list',
    },
  },
  visitor: {
    Rule: {
      custom: {
        global() {
          inGlobal += 1;
        },
      },
    },
    RuleExit: {
      custom: {
        global() {
          inGlobal -= 1;
        },
      },
    },
  },
});

console.log(inGlobal); // 1

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 with the lightningcss.transform visitor API shown in the report, especially the Rule and RuleExit handlers for custom at-rules and the customAtRules global configuration. Reproduce the example and trace why RuleExit does not run for the custom rule; done means the displayed input balances the callbacks and produces inGlobal as 0.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, rust
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.