mirror of
https://github.com/oxc-project/oxc.git
synced 2026-11-04 10:29:58 +00:00
When an unnamed parent node and a mangled identifier begin at the same source position, codegen deduplicated the identifier mapping. This retained location data but discarded the original identifier name, leaving consumers unable to restore inferred function names in source-mapped Node stack traces.
```mermaid
flowchart LR
A[AssignmentExpression mapping<br/>unnamed] --> B[Token at source position P<br/>name: none]
C[Identifier mapping<br/>name: longName] --> D{Same source position P?}
D -->|before| E[Drop duplicate<br/>names: empty]
D -->|after| F[Enrich existing token<br/>name: longName]
```
### Changes
- Cache whether the last emitted token has a name, keeping duplicate-position handling cheap in the source-map builder hot path.
- Enrich an unnamed duplicate token when a later identifier mapping supplies the original name.
- Add a unit regression test for the builder behavior.
- Extend the existing Node source-map stack-trace snapshot test with a mangled ES module fixture.
The Node fixture verifies:
```text
function longFunctionName(longName) { ... }
↓ mangled
function e(e) { ... }
```
and asserts that the source map includes both original names while Node restores the inferred inner frame as:
```text
at longName (/project/input.js:6:15)
```
52 lines
1.2 KiB
TOML
52 lines
1.2 KiB
TOML
[package]
|
|
name = "oxc_codegen"
|
|
version = "0.157.0"
|
|
authors.workspace = true
|
|
categories.workspace = true
|
|
edition.workspace = true
|
|
homepage.workspace = true
|
|
include = ["/examples", "/src"]
|
|
keywords.workspace = true
|
|
license.workspace = true
|
|
publish = true
|
|
repository.workspace = true
|
|
rust-version.workspace = true
|
|
description.workspace = true
|
|
|
|
[lints]
|
|
workspace = true
|
|
|
|
[lib]
|
|
doctest = true
|
|
|
|
[[example]]
|
|
name = "codegen"
|
|
required-features = ["sourcemap"]
|
|
|
|
[dependencies]
|
|
oxc_allocator = { workspace = true }
|
|
oxc_ast = { workspace = true }
|
|
oxc_data_structures = { workspace = true, features = ["code_buffer", "slice_iter", "stack"] }
|
|
oxc_ecmascript = { workspace = true }
|
|
oxc_index = { workspace = true }
|
|
oxc_semantic = { workspace = true }
|
|
oxc_sourcemap = { workspace = true, optional = true }
|
|
oxc_span = { workspace = true }
|
|
oxc_str = { workspace = true }
|
|
oxc_syntax = { workspace = true }
|
|
|
|
bitflags = { workspace = true }
|
|
cow-utils = { workspace = true }
|
|
rustc-hash = { workspace = true }
|
|
smallvec = { workspace = true }
|
|
|
|
[dev-dependencies]
|
|
insta = { workspace = true }
|
|
oxc_mangler = { workspace = true }
|
|
oxc_parser = { workspace = true }
|
|
pico-args = { workspace = true }
|
|
|
|
[features]
|
|
default = ["sourcemap"]
|
|
sourcemap = ["dep:oxc_sourcemap"]
|