Commit b8a76a2
feat: sourcemap generation support (#18)
## Summary
- Propagate original source spans through HIR to codegen AST nodes,
enabling accurate source position tracking through the compilation
pipeline
- Generate sourcemaps via OXC codegen with post-processing line
adjustment to handle wrapper code (imports, function signatures) that
shifts compiled output
- Add `source_map` option to `PluginOptions`, NAPI bindings, and Vite
plugin
- Position-aware sourcemap adjustment with virtual source routing for
compiler-generated code (e.g. `useMemoCache` import, cache declarations)
- Support `debugId` (UUID v4) and `x_google_ignoreList` in sourcemap
output
- Remove 6 Category C cosmetic post-processing transforms that
interfered with sourcemap accuracy
- Strip comments inside compiled function bodies from codegen output
## Test plan
- [x] Unit tests for `adjust_sourcemap_positional` and
`collect_line_edits`
- [x] End-to-end sourcemap verification with full token dump
- [x] Identity mapping, HOC, monotonicity, and manual token verification
tests
- [x] 15 comprehensive sourcemap verification tests
- [x] Round-trip sourcemap tests for custom and shadcn fixtures
- [x] Sourcemap invariant tests for threshold, identity mapping,
columns, monotonicity
- [x] `cargo test --package oxc_react_compiler` passes
- [x] `cargo clippy` clean
- [x] `cargo fmt` clean
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 25eeca3 commit b8a76a2
14 files changed
Lines changed: 2504 additions & 403 deletions
File tree
- .github/workflows
- crates
- oxc_react_compiler_napi/src
- oxc_react_compiler
- src
- codegen_backend
- module_emitter
- hir
- napi/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
| |||
49 | 51 | | |
50 | 52 | | |
51 | 53 | | |
| 54 | + | |
| 55 | + | |
52 | 56 | | |
53 | 57 | | |
54 | 58 | | |
| |||
148 | 152 | | |
149 | 153 | | |
150 | 154 | | |
| 155 | + | |
| 156 | + | |
151 | 157 | | |
152 | 158 | | |
153 | 159 | | |
| |||
0 commit comments