Skip to content

fix: add locations to keywords - #116

Merged
dummdidumm merged 5 commits into
mainfrom
keyword-sourcemaps
May 11, 2026
Merged

dummdidumm merged 5 commits into
mainfrom
keyword-sourcemaps

Conversation

@dummdidumm

Copy link
Copy Markdown
Member

This adds location info to keywords of the ts transform, where possible. This is necessary for more accurate sourcemaps, which in turn are important for debugging, Vite(st) error diagnostics, etc, as they often anchor on keywords, and if they don't exist you'll get a null mapping, and then you'll no longer have a correct break point / error stack / etc.

Helps with sveltejs/svelte#9961

This adds location info to keywords of the ts transform, where possible. This is necessary for more accurate sourcemaps, which in turn are important for debugging, Vite(st) error diagnostics, etc, as they often anchor on keywords, and if they don't exist you'll get a null mapping, and then you'll no longer have a correct break point / error stack / etc.

Helps with sveltejs/svelte#9961
@changeset-bot

changeset-bot Bot commented May 8, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2242e7f

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

@pkg-pr-new

pkg-pr-new Bot commented May 8, 2026 •

Copy link
Copy Markdown
npm i https://pkg.pr.new/esrap@116

commit: 2242e7f

@jycouet

jycouet commented May 9, 2026 •

Copy link
Copy Markdown
Contributor

Looks great already @dummdidumm
After a few iteration I managed with my friend claude #117 (targeting this PR to reduce diff)

@trueadm trueadm left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Big improvements!

jycouet and others added 3 commits May 11, 2026 08:10
* fix: map while/else/catch/finally/case/default keywords to source

* tweak

* update tests

---------

Co-authored-by: Simon Holthausen <[email protected]>
@dummdidumm
dummdidumm merged commit 02b140b into main May 11, 2026
9 checks passed
@dummdidumm
dummdidumm deleted the keyword-sourcemaps branch May 11, 2026 06:40
Rich-Harris added a commit that referenced this pull request Sep 22, 2026
* fix: drop keyword-end source map mapping
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.

* style: revert whitespace changes

* prettier

* update comment

---------

Co-authored-by: Rich Harris <[email protected]>
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