parcel-bundler / parcel-bundler/lightningcss
Comments are removed even with `minify: false`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7.7k
- Forks
- 302
- PR merge metrics
- No merged PRs in 30d
Description
I have seen that any input with comment is output without comments even when minification is disabled :
const css = require("@parcel/css");
const inputs = [
"/* before */ rule { c: 1 } /*! after */",
`/* before */
rule { d: 1 }
/*! after */`
];
inputs.forEach((input) => {
const { code } = css.transform({
filename: "",
code: Buffer.from(input),
minify: false
});
console.log({
input,
output: code.toString()
});
});
Results in
{
input: '/* before */ rule { c: 1 } /*! after */',
output: 'rule {\n c: 1;\n}\n'
}
{
input: '/* before */\n rule { d: 1 }\n /*! after */',
output: 'rule {\n d: 1;\n}\n'
}
For most comments that shouldn't be a problem, but if the comment starts with /*! in general it should be preserved as it is used for licenses or other content that was specifically marked to remain in the code.
Is there a way to keep those comments ?
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
Reproduce the JavaScript transform example with minify: false and inspect the Rust parser or minifier code responsible for comment handling. Confirm the expected behavior for ordinary comments and /*! comments, then add regression coverage showing that marked comments are preserved when minification is disabled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, rust
- Domain
- compilers, frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100