Skip to content

feat(ast): normalize swc_ecma_ast serde output for ts-estree#11771

Draft
kdy1 wants to merge 1 commit intoswc-project:mainfrom
kdy1:kdy1/ts-estree-serde-output
Draft

feat(ast): normalize swc_ecma_ast serde output for ts-estree#11771
kdy1 wants to merge 1 commit intoswc-project:mainfrom
kdy1:kdy1/ts-estree-serde-output

Conversation

@kdy1
Copy link
Copy Markdown
Member

@kdy1 kdy1 commented Apr 7, 2026

Summary

  • normalize swc_ecma_ast serde-impl output at the Program entrypoint to a TypeScript-ESTree / typescript-eslint-oriented shape
  • remove internal serialization details like span and ctxt, and normalize representative node shapes including Program, ChainExpression, MemberExpression for super, PrivateIdentifier, PropertyDefinition, MethodDefinition, and TS* node names
  • add parser-driven serialization tests covering program roots, class/private fields, constructor parameter properties, optional chaining, and key TypeScript declaration/signature nodes

Details

  • keep deserialization on the existing SWC-facing format while making serialization intentionally asymmetric
  • add a normalization layer in swc_ecma_ast::serde_impl and wire Program to use it for serialization
  • make SyntaxContext-backed ctxt fields deserialize with defaults so older JSON inputs without ctxt continue to parse

Testing

  • git submodule update --init --recursive
  • cargo fmt --all
  • cargo test -p swc_ecma_ast
  • cargo test -p swc_ecma_ast --features serde-impl
  • cargo clippy --all --all-targets -- -D warnings
  • cargo clippy -p swc_ecma_ast --features serde-impl --all-targets -- -D warnings

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 7, 2026

⚠️ No Changeset found

Latest commit: 44232e9

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

@socket-security
Copy link
Copy Markdown

Warning

Review the following alerts detected in dependencies.

According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.

Action Severity Alert  (click "▶" to expand/collapse)
Warn High
Obfuscated code: npm js-beautify is 100.0% likely obfuscated

Confidence: 1.00

Location: Package overview

From: package.jsonnpm/js-beautify@1.14.7

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/js-beautify@1.14.7. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

Binary Sizes

File Size
swc.linux-x64-gnu.node 28M (29142984 bytes)

Commit: dedaba9

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 7, 2026

Merging this PR will not alter performance

✅ 219 untouched benchmarks


Comparing kdy1:kdy1/ts-estree-serde-output (44232e9) with main (236eff0)1

Open in CodSpeed

Footnotes

  1. 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