refactor(ast): simplify ESTree serialization of Ident#20932
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
Pull request overview
Refactors ESTree serialization to treat Ident as JSON-safe at the type level, removing per-field #[estree(json_safe)] annotations and relying on Ident’s ESTree impl for the optimization.
Changes:
- Update
Ident’sESTreeimplementation to serialize viaJsonSafeString. - Remove
#[estree(json_safe)]fromIdentfields in JS identifier AST node types. - Update generated ESTree serializers to serialize identifier
namefields viaIdentdirectly (instead of wrappingas_str()inJsonSafeStringat call sites).
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| crates/oxc_str/src/ident.rs | Moves JSON-safe serialization optimization into Ident’s ESTree impl via JsonSafeString. |
| crates/oxc_ast/src/generated/derive_estree.rs | Switches identifier name field serialization to &self.name (delegating to Ident’s ESTree). |
| crates/oxc_ast/src/ast/js.rs | Removes #[estree(json_safe)] from Ident-typed name fields now that Ident handles it. |
Merge activity
|
`Ident` is always JSON-safe (cannot contain characters which require escaping in JSON). Remove `#[estree(json_safe)]` from fields containing `Ident`, and apply the JSON-safe optimization as part of `Ident`'s `ESTree` impl. This also fixes one `Ident` we'd missed flagging as JSON-safe previously - the `Ident` in `PrivateIdentifier` - which will be a small perf boost.
a718529 to
2a28e4c
Compare
2fb1808 to
a04f405
Compare

Identis always JSON-safe (cannot contain characters which require escaping in JSON). Remove#[estree(json_safe)]from fields containingIdent, and apply the JSON-safe optimization as part ofIdent'sESTreeimpl.This also fixes one
Identwe'd missed flagging as JSON-safe previously - theIdentinPrivateIdentifier- which will be a small perf boost.