Skip to content

fix: drop keyword-end source map mapping#124

Open
ajhoddinott wants to merge 3 commits into
sveltejs:mainfrom
ajhoddinott:fix/keyword-end-source-map
Open

fix: drop keyword-end source map mapping#124
ajhoddinott wants to merge 3 commits into
sveltejs:mainfrom
ajhoddinott:fix/keyword-end-source-map

Conversation

@ajhoddinott

Copy link
Copy Markdown

The trailing mapping at column + keyword.length introduced in #116 lands on whitespace, causing downstream source-map consumers to resolve adjacent expression positions onto whitespace columns.

For example with single-line return <logical-expression> lines in Svelte 5 .svelte.js rune modules, istanbul branchMap entries from @vitest/coverage-v8 via ast-v8-to-istanbul drift one column left into the keyword's trailing whitespace, and are reported as spurious uncovered branches.

I think the keyword-start mapping in #116 is sufficient for the debugger / stack-frame use cases it targets, so dropping the end mapping is the minimal fix.

The trailing mapping at `column + keyword.length` introduced in sveltejs#116
lands on whitespace, causing downstream source-map consumers to resolve
adjacent expression positions onto whitespace columns.
@changeset-bot

changeset-bot Bot commented May 18, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 02b115e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
esrap Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Rich-Harris

Copy link
Copy Markdown
Member

Thanks — have to admit I'm a bit surprised at this finding, I would have thought that more mappings would always make things more accurate, never less (as long as they're correct of course). What's the simplest way to reproduce this?

@manuel3108

Copy link
Copy Markdown
Member

Also seems like your local setup has a different formatting setup, could you please reduce the diff as much as possible?

@ajhoddinott

Copy link
Copy Markdown
Author

What's the simplest way to reproduce this?

I've made a reduced case here:
https://github.com/ajhoddinott/esrap-coverage-reproduction

pnpm test

-----------------|---------|----------|---------|---------|-------------------
File             | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
-----------------|---------|----------|---------|---------|-------------------
All files        |    87.5 |      100 |     100 |     100 |
 state.svelte.js |    87.5 |      100 |     100 |     100 |
-----------------|---------|----------|---------|---------|-------------------

Add to pnpm-workspace.yaml

overrides:
  esrap: 2.2.6

to downgrade then pnpm test again

-----------------|---------|----------|---------|---------|-------------------
File             | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
-----------------|---------|----------|---------|---------|-------------------
All files        |     100 |      100 |     100 |     100 |
 state.svelte.js |     100 |      100 |     100 |     100 |
-----------------|---------|----------|---------|---------|-------------------

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants