parcel-bundler / parcel-bundler/lightningcss

Line numbers in source map incorrect

Open
#780 13 comments 0 reactions 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

The line number sometimes are a bit off. I tried to get to the bottom of this and reduce as much styles as possible. See attached ZIP. I'm using the NodeJS API and basically this code (excerpt):

let { code, map } = transform({
  filename: 'style.css',
  code: Buffer.from(codeBuffer),
  inputSourceMap: Buffer.from(mapBuffer),
  minify: true,
  sourceMap: true
});

code+="\n\/\*# sourceMappingURL="+path.basename(outfile)+".map */\n";

If included the input code (index_unminified.css) and input source map (index_unminified.css.map) in the ZIP. Now for this selector: ".paragraph-stage .body .field-body h1.text-align-center strong" the line number shown in the browser's developer console is 63. Correct would be 76. If I remove anyform_errors.scss, it works. So the problem must be caused by the styles in this file. I couldn't narrow it down further unfortunately. Hope it helps.

sass.zip

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 NodeJS API transform call and the attached sass.zip, especially index_unminified.css, index_unminified.css.map, and anyform_errors.scss. Reproduce the mapping for the selector ".paragraph-stage .body .field-body h1.text-align-center strong" and compare the reported line 63 with the expected line 76. Done means the generated source map reports the correct line while minifying with the input source map.

Written by the indexing model from the issue text.

Assessment

Tech stack
css, nodejs, rust
Domain
build-system, compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.