parcel-bundler / parcel-bundler/lightningcss
How to convert raw `TokenList(Vec<TokenOrValue>)` into a rule?
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7.7k
- Forks
- 302
- PR merge metrics
- No merged PRs in 30d
Description
I am implementing a custom pseudo function transform which changes :deep from
.test :deep(.deep-test) { /**/ }
to
.test[data-v-smth] .deep-test { /**/ }
To visit the custom pseudo function I use
fn visit_selector(&mut self, selector: &mut Selector<'i>) -> Result<(), Self::Error> {
selector.iter().any(|part| match part {
Component::NonTSPseudoClass(pseudo_class) => {
match pseudo_class {
lightningcss::selector::PseudoClass::CustomFunction { name, arguments } => {
println!("{:?}", arguments);
true
},
_ => false
}
},
_ => false
});
Ok(())
}
Now pseudo function has a TokenList inside.
TokenList([Token(Delim('.')), Token(Ident("deep-test"))])
How can I run it through lightningcss to parse as a selector? All the implementations on TokenList are either private or pub(crate) and require some hacking. This also includes .to_css()
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The entry point shown is visit_selector, where PseudoClass::CustomFunction exposes a TokenList. Start by tracing the public selector and TokenList APIs around this visitor and the existing visibility boundaries. Done means establishing a supported way to parse the shown .deep-test tokens as a selector, with the result usable for the :deep transform.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- web-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100