Skip to content

feat(estree)!: ESTree config use methods not consts#23573

Merged
graphite-app[bot] merged 1 commit into
mainfrom
om/06-17-feat_estree_estree_config_use_methods_not_consts
Jun 17, 2026
Merged

feat(estree)!: ESTree config use methods not consts#23573
graphite-app[bot] merged 1 commit into
mainfrom
om/06-17-feat_estree_estree_config_use_methods_not_consts

Conversation

@overlookmotel

@overlookmotel overlookmotel commented Jun 17, 2026

Copy link
Copy Markdown
Member

Previously Config passed to ESTree serializers inclused INCLUDE_TS_FIELDS and FIXES consts. Allow these options to be set either as compile time or at runtime by instead implementing them as methods.

This PR defines all these methods on all configs as returning static values, so it does not change behavior. Next PR (#23574) uses this to alter configs to make whether TS fields are included in output a runtime option instead of a compile time one.

overlookmotel commented Jun 17, 2026

Copy link
Copy Markdown
Member Author

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent changes, fast-track this PR to the front of 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.

@codspeed-hq

codspeed-hq Bot commented Jun 17, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 62 untouched benchmarks
⏩ 9 skipped benchmarks1


Comparing om/06-17-feat_estree_estree_config_use_methods_not_consts (e7b6b68) with main (053b0c1)2

Open in CodSpeed

Footnotes

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

@overlookmotel overlookmotel marked this pull request as ready for review June 17, 2026 22:06
Copilot AI review requested due to automatic review settings June 17, 2026 22:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors ESTree serialization configuration from associated consts to instance methods, enabling options like “include TS fields” and “record fixes” to be chosen either at compile time or (in follow-up work) at runtime, while keeping current behavior unchanged via method implementations that return static values.

Changes:

  • Replaced Config::{INCLUDE_TS_FIELDS, FIXES} with Config::{include_ts_fields(), fixes()} and updated serializer logic accordingly.
  • Replaced Serializer::INCLUDE_TS_FIELDS with Serializer::include_ts_fields() and added StructSerializer::include_ts_fields() to support checks after serialize_struct().
  • Updated downstream serializers (AST + tokens) to use the new methods instead of constants.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
crates/oxc_estree/src/serialize/structs.rs Adds include_ts_fields() to StructSerializer and switches TS/JS field gating to method calls.
crates/oxc_estree/src/serialize/sequences.rs Switches FIXES checks to config.fixes() for trace-path tracking.
crates/oxc_estree/src/serialize/mod.rs Updates Serializer trait API, delegates to config.include_ts_fields(), and changes serialize_with_fixes guard to a runtime assert!.
crates/oxc_estree/src/serialize/config.rs Replaces config consts with methods on Config and updates built-in configs to return static values.
crates/oxc_estree_tokens/src/json/mod.rs Updates token serializer config to implement the new Config methods (all statically false).
crates/oxc_ast/src/serialize/mod.rs Switches TS span adjustment logic for Program to consult state.include_ts_fields().
crates/oxc_ast/src/serialize/literal.rs Switches template element span adjustment to use state.include_ts_fields().
crates/oxc_ast/src/serialize/js.rs Switches TS-conditional serialization paths to use serializer.include_ts_fields().

Comment thread crates/oxc_estree/src/serialize/mod.rs Outdated
@overlookmotel overlookmotel self-assigned this Jun 17, 2026
@graphite-app graphite-app Bot changed the base branch from om/06-17-perf_estree_remove_pointless_mem_take_ to graphite-base/23573 June 17, 2026 22:41
@graphite-app graphite-app Bot force-pushed the graphite-base/23573 branch from c53d98c to 053b0c1 Compare June 17, 2026 22:48
@graphite-app graphite-app Bot force-pushed the om/06-17-feat_estree_estree_config_use_methods_not_consts branch from b94cea3 to 88b88e0 Compare June 17, 2026 22:48
@graphite-app graphite-app Bot changed the base branch from graphite-base/23573 to main June 17, 2026 22:48
@graphite-app graphite-app Bot force-pushed the om/06-17-feat_estree_estree_config_use_methods_not_consts branch from 88b88e0 to 4749b17 Compare June 17, 2026 22:48
@overlookmotel overlookmotel changed the base branch from main to graphite-base/23573 June 17, 2026 23:03
@overlookmotel overlookmotel force-pushed the om/06-17-feat_estree_estree_config_use_methods_not_consts branch from 4749b17 to 3373a77 Compare June 17, 2026 23:03
@overlookmotel overlookmotel changed the base branch from graphite-base/23573 to om/06-17-docs_data_structures_improve_docs_on_safety_contract June 17, 2026 23:03
@overlookmotel overlookmotel force-pushed the om/06-17-docs_data_structures_improve_docs_on_safety_contract branch from 1dc6e62 to 7cd8b45 Compare June 17, 2026 23:13
@overlookmotel overlookmotel force-pushed the om/06-17-feat_estree_estree_config_use_methods_not_consts branch from 3373a77 to 5f62541 Compare June 17, 2026 23:13
@graphite-app

graphite-app Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Merge activity

Previously `Config` passed to ESTree serializers inclused `INCLUDE_TS_FIELDS` and `FIXES` consts. Allow these options to be set either as compile time or at runtime by instead implementing them as methods.

This PR defines all these methods on all configs as returning static values, so it does not change behavior. Next PR (#23574) uses this to alter configs to make whether TS fields are included in output a runtime option instead of a compile time one.
@graphite-app graphite-app Bot force-pushed the om/06-17-docs_data_structures_improve_docs_on_safety_contract branch from 7cd8b45 to f68641e Compare June 17, 2026 23:22
@graphite-app graphite-app Bot force-pushed the om/06-17-feat_estree_estree_config_use_methods_not_consts branch from 5f62541 to e7b6b68 Compare June 17, 2026 23:23
Base automatically changed from om/06-17-docs_data_structures_improve_docs_on_safety_contract to main June 17, 2026 23:26
@graphite-app graphite-app Bot merged commit e7b6b68 into main Jun 17, 2026
40 checks passed
@graphite-app graphite-app Bot deleted the om/06-17-feat_estree_estree_config_use_methods_not_consts branch June 17, 2026 23:27
Boshen added a commit that referenced this pull request Jun 18, 2026
### 💥 BREAKING CHANGES

- 7a76cd3 estree: [**BREAKING**] Make whether to include TS fields a
runtime option (#23574) (overlookmotel)
- e7b6b68 estree: [**BREAKING**] `ESTree` config use methods not consts
(#23573) (overlookmotel)

### 🚀 Features

- 556cc6d data_structures: Add `CodeBuffer::as_str` method (#23571)
(overlookmotel)
- 38c4b06 parser: Add friendly error for adjacent JSX elements (#23378)
(sapphi-red)
- 53509a8 minifier: Treeshake pure typed arrays and Set/Map array
literals (#23469) (Dunqing)
- 09762d9 minifier: Inline const value for read-only vars (#22593)
(Dunqing)

### 🐛 Bug Fixes

- 20375f9 react_compiler: Keep imports referenced only by a computed key
(#23586) (Boshen)
- 31bfd9b minifier: Keep Object introspection calls on a possible Proxy
(#23483) (Dunqing)
- 837a395 parser: Treat a line comment after ':' as leading, not
trailing (#23515) (Dunqing)
- e409fe0 minifier: Keep `new Map`/`WeakSet`/`WeakMap` with a string
argument (#23470) (Dunqing)
- ae02b4e ci/parser: Use `minimal` for vitest reporter (#23457)
(camc314)

### ⚡ Performance

- cf24329 mangler: Compile slot sort once instead of per CAPACITY
(#23577) (Boshen)
- 4058a6a parser: Reduce code bloat from verify_modifiers
monomorphization (#23576) (Boshen)
- 053b0c1 estree: Remove pointless `mem::take` (#23572) (overlookmotel)
- dfb52b6 transformer: Pre-size statement vecs in TS enum & namespace
lowering (#23516) (Yunfei He)
- 970e09a minifier: Compute template-literal inline checks in a single
pass (#23467) (Yunfei He)
- 3170c0e semantic,mangler,minifier: Fix `Semantic::stats` node count
and reuse stats in mangler builds (#23352) (Boshen)
- d1fa6e0 minifier: Evaluate ternary branches once in
minimize_conditional_expression (#23479) (Yunfei He)
- 3fa8051 transformer: Pre-size JSX props vec to attribute count
(#23466) (Yunfei He)
- 488b382 react_compiler: Borrow binding names in prefilter instead of
allocating (#23471) (Yunfei He)
- bcb3894 minifier: Incremental scoping refresh, delete
LiveUsageCollector (#23197) (Dunqing)

### 📚 Documentation

- f68641e data_structures: Improve docs on safety contract (#23575)
(overlookmotel)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
camc314 pushed a commit that referenced this pull request Jul 3, 2026
Previously `Config` passed to ESTree serializers inclused `INCLUDE_TS_FIELDS` and `FIXES` consts. Allow these options to be set either as compile time or at runtime by instead implementing them as methods.

This PR defines all these methods on all configs as returning static values, so it does not change behavior. Next PR (#23574) uses this to alter configs to make whether TS fields are included in output a runtime option instead of a compile time one.
camc314 pushed a commit that referenced this pull request Jul 3, 2026
### 💥 BREAKING CHANGES

- 7a76cd3 estree: [**BREAKING**] Make whether to include TS fields a
runtime option (#23574) (overlookmotel)
- e7b6b68 estree: [**BREAKING**] `ESTree` config use methods not consts
(#23573) (overlookmotel)

### 🚀 Features

- 556cc6d data_structures: Add `CodeBuffer::as_str` method (#23571)
(overlookmotel)
- 38c4b06 parser: Add friendly error for adjacent JSX elements (#23378)
(sapphi-red)
- 53509a8 minifier: Treeshake pure typed arrays and Set/Map array
literals (#23469) (Dunqing)
- 09762d9 minifier: Inline const value for read-only vars (#22593)
(Dunqing)

### 🐛 Bug Fixes

- 20375f9 react_compiler: Keep imports referenced only by a computed key
(#23586) (Boshen)
- 31bfd9b minifier: Keep Object introspection calls on a possible Proxy
(#23483) (Dunqing)
- 837a395 parser: Treat a line comment after ':' as leading, not
trailing (#23515) (Dunqing)
- e409fe0 minifier: Keep `new Map`/`WeakSet`/`WeakMap` with a string
argument (#23470) (Dunqing)
- ae02b4e ci/parser: Use `minimal` for vitest reporter (#23457)
(camc314)

### ⚡ Performance

- cf24329 mangler: Compile slot sort once instead of per CAPACITY
(#23577) (Boshen)
- 4058a6a parser: Reduce code bloat from verify_modifiers
monomorphization (#23576) (Boshen)
- 053b0c1 estree: Remove pointless `mem::take` (#23572) (overlookmotel)
- dfb52b6 transformer: Pre-size statement vecs in TS enum & namespace
lowering (#23516) (Yunfei He)
- 970e09a minifier: Compute template-literal inline checks in a single
pass (#23467) (Yunfei He)
- 3170c0e semantic,mangler,minifier: Fix `Semantic::stats` node count
and reuse stats in mangler builds (#23352) (Boshen)
- d1fa6e0 minifier: Evaluate ternary branches once in
minimize_conditional_expression (#23479) (Yunfei He)
- 3fa8051 transformer: Pre-size JSX props vec to attribute count
(#23466) (Yunfei He)
- 488b382 react_compiler: Borrow binding names in prefilter instead of
allocating (#23471) (Yunfei He)
- bcb3894 minifier: Incremental scoping refresh, delete
LiveUsageCollector (#23197) (Dunqing)

### 📚 Documentation

- f68641e data_structures: Improve docs on safety contract (#23575)
(overlookmotel)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-ast Area - AST

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants