Skip to content

feat(ecma): add node ids and node-based scope analysis#11774

Draft
kdy1 wants to merge 1 commit intoswc-project:mainfrom
kdy1:kdy1/node-id-scope-analysis
Draft

feat(ecma): add node ids and node-based scope analysis#11774
kdy1 wants to merge 1 commit intoswc-project:mainfrom
kdy1:kdy1/node-id-scope-analysis

Conversation

@kdy1
Copy link
Copy Markdown
Member

@kdy1 kdy1 commented Apr 7, 2026

Summary

  • add swc_ecma_ast::NodeId and propagate node_id across concrete AST nodes with backward-compatible serde defaults
  • add assign_node_ids in swc_ecma_visit and run it from parser entry points
  • add NodeId-based scope data and canonical binding analysis, and wire resolver internals to use it
  • regenerate visit/hooks outputs and propagate node_id through touched parser, utils, transformer, and compatibility code paths

Testing

  • cargo fmt --all
  • cargo test -p swc_ecma_ast
  • cargo test -p swc_ecma_visit
  • cargo test -p swc_ecma_hooks
  • cargo test -p swc_ecma_codegen
  • cargo test -p swc_ecma_utils
  • cargo test -p swc_ecma_parser
  • cargo test -p swc_ecma_transforms_base
  • cargo test -p swc_typescript
  • cargo test -p swc_ecma_lints
  • cargo test -p swc_ecma_lexer
  • cargo test -p swc_ecma_quote_macros
  • cargo test -p swc_ecma_transformer
  • cargo test -p swc_ecma_transforms_classes
  • cargo check -p swc_estree_compat --message-format short
  • cargo check -p swc_ecma_transforms_optimization --message-format short

Known follow-ups

  • cargo clippy --all --all-targets -- -D warnings is still red because node_id propagation is incomplete in downstream transform crates that were not updated in this diff, primarily swc_ecma_transforms_react, swc_ecma_transforms_module, swc_ecma_transforms_proposal, and swc_ecma_transforms_testing
  • cargo test -p swc_ecma_transforms_optimization still fails for the same downstream reason because it compiles those crates as dependencies
  • this PR is intentionally opened as draft until the remaining downstream fallout is cleaned up

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 7, 2026

⚠️ No Changeset found

Latest commit: e0410f7

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

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 7, 2026

Merging this PR will not alter performance

✅ 4 untouched benchmarks
⏩ 216 skipped benchmarks1


Comparing kdy1:kdy1/node-id-scope-analysis (e0410f7) with main (236eff0)2

Open in CodSpeed

Footnotes

  1. 216 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 (87dee57) during the generation of this report, so 236eff0 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

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