Skip to content

fix: drop keyword-end source map mapping - #124

Merged
Rich-Harris merged 6 commits into
sveltejs:mainfrom
ajhoddinott:fix/keyword-end-source-map
Sep 22, 2026
Merged

Rich-Harris merged 6 commits into
sveltejs:mainfrom
ajhoddinott:fix/keyword-end-source-map

Conversation

@ajhoddinott

Copy link
Copy Markdown
Contributor

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: 80884d0

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
Contributor 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 |
-----------------|---------|----------|---------|---------|-------------------

@pkg-svelte-dev

pkg-svelte-dev Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Install the latest version of esrap from 80884d0:

pnpm add https://pkg.svelte.dev/esrap/c/80884d091d5eedb1d237a7d794e90df76866ee1c

Open in pkg.svelte.dev: https://pkg.svelte.dev/repos/esrap/pr/124

Note

This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed.

@Rich-Harris Rich-Harris left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you!

@Rich-Harris
Rich-Harris merged commit 29d855d into sveltejs:main Sep 22, 2026
7 checks passed
Rich-Harris added a commit that referenced this pull request Sep 22, 2026
dummdidumm pushed a commit to sveltejs/svelte that referenced this pull request Sep 28, 2026
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