parcel-bundler / parcel-bundler/lightningcss
Can't get doc examples for custom transforms to work
Open
Nobody has claimed this yet.
documentation
- Dominant language
- Rust
- Stars
- 7.7k
- Forks
- 302
- PR merge metrics
- No merged PRs in 30d
Description
Replicating the examples from the documentation, for example:
let res = transform({
filename: 'test.css',
minify: true,
code: Buffer.from(`
.foo {
overflow: auto;
}
`),
visitor: {
Property: {
overflow(property) {
return [{
property: 'custom',
value: {
name: '-webkit-overflow-scrolling',
value: [{
type: 'token',
value: {
type: 'ident',
value: 'touch'
}
}]
}
}, property];
},
}
}
});
or
let res = transform({
minify: true,
code: Buffer.from(`
.foo {
size: 12px;
}
`),
visitor: {
Property: {
custom: {
size(property) {
// Handle the size property when the value is a length.
if (property.value[0].type === 'length') {
let value = {
type: 'length-percentage',
value: { type: 'dimension', value: property.value[0].value }
};
return [
{ property: 'width', value },
{ property: 'height', value }
];
}
}
}
}
}
});
none of them is working as expected, no value is being replaced.
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
Start by reproducing the two documentation examples through the transform API and compare the visitor input and output, focusing on why custom properties are not replaced. Trace the transform entry point into the visitor handling and update the relevant behavior or documentation so both examples produce their described replacements; verify with equivalent transform runs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, rust
- Domain
- compilers, web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100