Skip to content

fix(native-tools): honor ctx.sourceMaps in createSwcExtractor - #287

Merged
andrii-bodnar merged 2 commits into
mainfrom
fix/native-tools-extractor-source-maps
Oct 19, 2026
Merged

andrii-bodnar merged 2 commits into
mainfrom
fix/native-tools-extractor-source-maps

Conversation

@andrii-bodnar

Copy link
Copy Markdown
Contributor

createSwcExtractor() ignored ctx.sourceMaps. When another extractor wraps it and passes the source map of its compiled code there, as @lingui/extractor-vue does, message origins pointed to the compiled code instead of the original file and line. The Babel extractor reads ctx.sourceMaps first, so the two extractors gave different origins.

The extractor now appends that map as an inline source map comment before extraction. The native side reads the last such comment, so ctx.sourceMaps takes precedence over an inline map already in the code, the same as in the Babel extractor. This is a JS-only change, and the Rust side is unchanged.

Found while reviewing lingui/js-lingui#2729, which adds an inline map in the Vue extractor to work around this.

Wrapper extractors (e.g. @lingui/extractor-vue) pass the map of the
compiled code in ctx.sourceMaps, as the Babel extractor expects. The
native extractor ignored it and reported positions in the compiled code.

Append the map as an inline source map comment before extraction. The
native side reads the last such comment, so ctx.sourceMaps takes
precedence over an inline map already in the code, as in the Babel
extractor.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.42%. Comparing base (c78373a) to head (6124fb2).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #287   +/-   ##
=======================================
  Coverage   94.42%   94.42%           
=======================================
  Files          11       11           
  Lines        2530     2530           
=======================================
  Hits         2389     2389           
  Misses        141      141           
Flag Coverage Δ
unittests 94.42% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread packages/native-tools/src-js/index.ts Outdated
…eMaps

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@andrii-bodnar
andrii-bodnar merged commit c538858 into main Oct 19, 2026
28 checks passed
@andrii-bodnar
andrii-bodnar deleted the fix/native-tools-extractor-source-maps branch October 19, 2026 08:57
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.

2 participants