Skip to content

fix(transformer): propagate source spans for sourcemap correctness#19258

Merged
graphite-app[bot] merged 1 commit intomainfrom
fix/transformer-sourcemap-spans
Feb 11, 2026
Merged

fix(transformer): propagate source spans for sourcemap correctness#19258
graphite-app[bot] merged 1 commit intomainfrom
fix/transformer-sourcemap-spans

Conversation

@Boshen
Copy link
Member

@Boshen Boshen commented Feb 11, 2026

Summary

  • Propagate original source node spans to their outermost transformed replacements across all transformer plugins
  • Codegen skips sourcemap entries for nodes with empty spans (SPAN), so transformed nodes previously produced no sourcemap mappings
  • Updated 20 files across typescript, jsx, es2016-es2026, class properties, and shared utility functions
  • Added span: Span parameters to shared helpers (create_assignment, create_member_callee, create_prototype_member) and threaded spans through call chains
  • Kept SPAN for truly synthetic nodes (generated temps, helper function internals, protocol boilerplate)

🤖 Generated with Claude Code

@github-actions github-actions bot added A-transformer Area - Transformer / Transpiler C-bug Category - Bug labels Feb 11, 2026
@codspeed-hq
Copy link

codspeed-hq bot commented Feb 11, 2026

Merging this PR will not alter performance

✅ 47 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing fix/transformer-sourcemap-spans (941bc03) with main (740a009)2

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on main (9195430) during the generation of this report, so 740a009 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@Boshen Boshen marked this pull request as ready for review February 11, 2026 11:33
Copilot AI review requested due to automatic review settings February 11, 2026 11:33
@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Feb 11, 2026
Copy link
Member Author

Boshen commented Feb 11, 2026

Merge activity

…19258)

## Summary

- Propagate original source node spans to their outermost transformed replacements across all transformer plugins
- Codegen skips sourcemap entries for nodes with empty spans (`SPAN`), so transformed nodes previously produced no sourcemap mappings
- Updated 20 files across typescript, jsx, es2016-es2026, class properties, and shared utility functions
- Added `span: Span` parameters to shared helpers (`create_assignment`, `create_member_callee`, `create_prototype_member`) and threaded spans through call chains
- Kept `SPAN` for truly synthetic nodes (generated temps, helper function internals, protocol boilerplate)

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@graphite-app graphite-app bot force-pushed the fix/transformer-sourcemap-spans branch from 941bc03 to 5bdaacc Compare February 11, 2026 11:34
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves sourcemap correctness by propagating original source spans onto transformed AST nodes (instead of leaving SPAN), so codegen emits mappings for transformed output across multiple transformer passes.

Changes:

  • Thread Span through shared AST builder helpers (e.g. member callee/prototype member/assignment) and update call sites.
  • Update several transformers (TypeScript namespace/enum, JSX refresh/runtime, optional chaining, object rest/spread, async transforms, etc.) to stamp transformed nodes with the originating span.
  • Preserve SPAN for intentionally synthetic nodes while ensuring outermost replacements carry real spans.

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
crates/oxc_transformer/src/utils/ast_builder.rs Adds span plumbing to shared AST construction helpers so callers can preserve source mappings.
crates/oxc_transformer/src/typescript/namespace.rs Uses namespace node spans for generated declarations/exports and function wrappers.
crates/oxc_transformer/src/typescript/enum.rs Propagates enum/enum-member spans into generated IIFE/calls/assignments.
crates/oxc_transformer/src/jsx/refresh.rs Uses original expression/function spans for inserted refresh calls/statements.
crates/oxc_transformer/src/jsx/jsx_impl.rs Uses JSX element span for generated props object/children array nodes.
crates/oxc_transformer/src/es2026/explicit_resource_management.rs Threads statement spans into generated try/catch/finally scaffolding.
crates/oxc_transformer/src/es2022/class_properties/super_converter.rs Updates helper calls to match new span-threaded builder signatures.
crates/oxc_transformer/src/es2022/class_properties/prop_decl.rs Propagates PropertyDefinition spans into generated helper calls/assignments.
crates/oxc_transformer/src/es2022/class_properties/private_field.rs Updates helper calls to match new span-threaded builder signatures.
crates/oxc_transformer/src/es2022/class_properties/constructor.rs Updates helper calls to match new span-threaded builder signatures.
crates/oxc_transformer/src/es2022/class_properties/class.rs Updates helper calls to match new span-threaded builder signatures.
crates/oxc_transformer/src/es2021/logical_assignment_operators.rs Uses original assignment span for the rewritten logical expression node.
crates/oxc_transformer/src/es2020/optional_chaining.rs Uses original chain-expression span for the rewritten conditional expression node.
crates/oxc_transformer/src/es2018/object_rest_spread.rs Ensures the final rewritten call expression retains the original object expression span.
crates/oxc_transformer/src/es2018/async_generator_functions/for_await.rs Propagates for await statement span through generated for/try scaffolding.
crates/oxc_transformer/src/es2017/async_to_generator.rs Uses original await/arrow/function spans for rewritten yield/IIFE call nodes.
crates/oxc_transformer/src/es2016/exponentiation_operator.rs Propagates original expression span through rewritten Math.pow/sequence nodes.
crates/oxc_transformer/src/decorator/legacy/mod.rs Updates helper calls to match new span-threaded builder signatures.
crates/oxc_transformer/src/common/computed_key.rs Updates computed-key temp-var assignment generation to use new span-threaded builder signature.
crates/oxc_transformer/src/common/arrow_function_converter.rs Uses original spans for newly generated call expressions in super transforms.

Comment on lines 69 to 72
ctx.state.var_declarations.insert_let(&binding, None, ctx.ast);

let assignment = create_assignment(&binding, key, ctx);
let assignment = create_assignment(&binding, key, SPAN, ctx);
let ident = binding.create_read_expression(ctx);
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

create_computed_key_temp_var passes SPAN into create_assignment, so the generated _tmp = <key> assignment will have an empty span and be skipped by sourcemap generation. Since this assignment corresponds to evaluating the original computed key expression, capture the original key span before moving it and pass that span instead.

Copilot uses AI. Check for mistakes.
@graphite-app graphite-app bot merged commit 5bdaacc into main Feb 11, 2026
21 checks passed
@graphite-app graphite-app bot deleted the fix/transformer-sourcemap-spans branch February 11, 2026 11:40
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Feb 11, 2026
camc314 pushed a commit that referenced this pull request Feb 16, 2026
### 🚀 Features

- 429d876 semantic: Assign ast node ids during semantic build (#19263)
(Boshen)
- ebb80b3 ast: Add `node_id` field to all AST struct nodes (#18138)
(Boshen)

### 🐛 Bug Fixes

- bfb15a3 semantic: Make multi_index_vec clone panic-safe (#19299)
(Boshen)
- 41c50a5 transformer: Ignore invalid JSX pragma identifiers (#19296)
(Boshen)
- deed3d8 transformer: Remove unnecessary trailing expression in object
rest spread assignment (#19259) (Boshen)
- 5bdaacc transformer: Propagate source spans for sourcemap correctness
(#19258) (Boshen)
- 3e0e5ba isolated-declarations: Align readonly class array initializer
diagnostics with tsc (#19218) (camc314)

### ⚡ Performance

- c169c77 syntax: Optimize `is_identifier_name_patched` (#19386)
(sapphi-red)
- aa1e1a8 allocator: Inline BitSet accessors (#19331) (Boshen)
- 5b90d46 semantic: Improve SoA with multi index vec (#19138) (Boshen)
- 99ce2a6 isolated_declarations: Mark all diagnostic functions as
`#[cold]` (#19279) (camc314)
- dd0220f transformer: Remove TS-only nodes earlier in
`enter_statements` (#19166) (Dunqing)
- e5baf60 isolated-declarations: Replace hash collections with
index-based Vec (#19221) (Dunqing)

### 📚 Documentation

- 569aa61 rust: Add missing rustdocs and remove missing_docs lint attrs
(#19306) (Boshen)
OskarLebuda pushed a commit to OskarLebuda/oxc that referenced this pull request Feb 17, 2026
…xc-project#19258)

## Summary

- Propagate original source node spans to their outermost transformed replacements across all transformer plugins
- Codegen skips sourcemap entries for nodes with empty spans (`SPAN`), so transformed nodes previously produced no sourcemap mappings
- Updated 20 files across typescript, jsx, es2016-es2026, class properties, and shared utility functions
- Added `span: Span` parameters to shared helpers (`create_assignment`, `create_member_callee`, `create_prototype_member`) and threaded spans through call chains
- Kept `SPAN` for truly synthetic nodes (generated temps, helper function internals, protocol boilerplate)

🤖 Generated with [Claude Code](https://claude.com/claude-code)
OskarLebuda pushed a commit to OskarLebuda/oxc that referenced this pull request Feb 17, 2026
### 🚀 Features

- 429d876 semantic: Assign ast node ids during semantic build (oxc-project#19263)
(Boshen)
- ebb80b3 ast: Add `node_id` field to all AST struct nodes (oxc-project#18138)
(Boshen)

### 🐛 Bug Fixes

- bfb15a3 semantic: Make multi_index_vec clone panic-safe (oxc-project#19299)
(Boshen)
- 41c50a5 transformer: Ignore invalid JSX pragma identifiers (oxc-project#19296)
(Boshen)
- deed3d8 transformer: Remove unnecessary trailing expression in object
rest spread assignment (oxc-project#19259) (Boshen)
- 5bdaacc transformer: Propagate source spans for sourcemap correctness
(oxc-project#19258) (Boshen)
- 3e0e5ba isolated-declarations: Align readonly class array initializer
diagnostics with tsc (oxc-project#19218) (camc314)

### ⚡ Performance

- c169c77 syntax: Optimize `is_identifier_name_patched` (oxc-project#19386)
(sapphi-red)
- aa1e1a8 allocator: Inline BitSet accessors (oxc-project#19331) (Boshen)
- 5b90d46 semantic: Improve SoA with multi index vec (oxc-project#19138) (Boshen)
- 99ce2a6 isolated_declarations: Mark all diagnostic functions as
`#[cold]` (oxc-project#19279) (camc314)
- dd0220f transformer: Remove TS-only nodes earlier in
`enter_statements` (oxc-project#19166) (Dunqing)
- e5baf60 isolated-declarations: Replace hash collections with
index-based Vec (oxc-project#19221) (Dunqing)

### 📚 Documentation

- 569aa61 rust: Add missing rustdocs and remove missing_docs lint attrs
(oxc-project#19306) (Boshen)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-transformer Area - Transformer / Transpiler C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments