Skip to content

[codex] add node and scope ids#11843

Draft
kdy1 wants to merge 1 commit into
mainfrom
kdy1/node-scope-ids
Draft

[codex] add node and scope ids#11843
kdy1 wants to merge 1 commit into
mainfrom
kdy1/node-scope-ids

Conversation

@kdy1

@kdy1 kdy1 commented May 4, 2026

Copy link
Copy Markdown
Member

Description:

Adds public NodeId, ScopeId, and BindingId types to swc_ecma_ast, adds node_id fields to scope-owning AST nodes, and adds scope_id to Ident. The resolver now assigns deterministic node/scope ids and records binding/reference scope ids while preserving the existing SyntaxContext projection for downstream compatibility.

This also updates serde defaults and camelCase schema output, rkyv/encoding coverage, generated visit/hooks code, TypeScript public types, parser/transformer construction sites, and focused node/scope id tests.

Validation:

  • git submodule update --init --recursive
  • cargo test -p generate-code test_ecmascript -- --nocapture
  • cargo check --all --all-targets
  • cargo test -p swc_ecma_ast --features serde-impl
  • cargo test -p swc_ecma_visit
  • cargo test -p swc_ecma_transforms_base
  • cargo test -p swc_ecma_minifier
  • cargo fmt --all
  • cargo clippy --all --all-targets -- -D warnings
  • cargo check -p swc_ecma_ast --features rkyv-impl
  • cargo check -p swc_ecma_ast --features encoding-impl

BREAKING CHANGE:

Direct construction or exhaustive pattern matching of the affected AST structs must account for the new node_id and scope_id fields. Existing serde JSON without these fields continues to deserialize with default ids.

Related issue (if exists):

N/A

@changeset-bot

changeset-bot Bot commented May 4, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: eaac5da

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions

github-actions Bot commented May 4, 2026

Copy link
Copy Markdown
Contributor

Binary Sizes

File Size
swc.linux-x64-gnu.node 27M (27814344 bytes)

Commit: fa42879

@codspeed-hq

codspeed-hq Bot commented May 4, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 3.72%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
✅ 218 untouched benchmarks
⏩ 31 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
es2015_destructuring 366.5 µs 353.4 µs +3.72%

Comparing kdy1/node-scope-ids (eaac5da) with main (21873b0)2

Open in CodSpeed

Footnotes

  1. 31 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 (0d8e651) during the generation of this report, so 21873b0 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@kdy1

kdy1 commented May 4, 2026

Copy link
Copy Markdown
Member Author

So this improves the performance, but not very impactful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant