feat(minifier): local traverse ctx and generated minifier traverse#19106
Merged
graphite-app[bot] merged 1 commit intomainfrom Feb 9, 2026
Merged
feat(minifier): local traverse ctx and generated minifier traverse#19106graphite-app[bot] merged 1 commit intomainfrom
graphite-app[bot] merged 1 commit intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR moves the minifier’s traversal runtime to be minifier-local by introducing a dedicated TraverseCtx/MinifierTraverse + generated walker inside oxc_minifier, avoiding orphan-rule constraints and keeping traversal concerns scoped to the minifier.
Changes:
- Add an
ast_toolsgenerator to produceoxc_minifier’sgenerated/{traverse,walk}.rsfor traversal. - Introduce a new minifier-local traversal context (
traverse_context) including ancestry + scoping helpers and UID generation. - Rewire minifier passes (peephole/normalize/compressor) to use the local traversal + reuse
Ancestorvia#[path]fromoxc_traverse.
Reviewed changes
Copilot reviewed 41 out of 45 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tasks/ast_tools/src/main.rs | Adds oxc_minifier crate path and wires in the new generator. |
| tasks/ast_tools/src/generators/mod.rs | Registers the new MinifierTraverseGenerator. |
| tasks/ast_tools/src/generators/minifier_traverse/mod.rs | Generates oxc_minifier’s traverse.rs and walk.rs outputs. |
| tasks/ast_tools/src/generators/minifier_traverse/walk.rs | Implements codegen for the unsafe walker functions (minifier-local). |
| tasks/ast_tools/src/generators/minifier_traverse/ancestor.rs | Shared helper logic for “visited fields” / AST filtering (used by minifier traversal generator). |
| crates/oxc_minifier/src/lib.rs | Switches minifier to use new local traversal modules and generated code. |
| crates/oxc_minifier/src/generated/mod.rs | Reuses Ancestor from oxc_traverse and exposes generated traverse/walk. |
| crates/oxc_minifier/src/minifier_traverse.rs | Adds traverse_mut_with_ctx entry point that enforces ancestry invariants. |
| crates/oxc_minifier/src/compressor.rs | Uses ReusableMinifierTraverseCtx for compression passes. |
| crates/oxc_minifier/src/traverse_context/mod.rs | Introduces minifier-local TraverseCtx with ancestry/scoping/AST builder APIs. |
| crates/oxc_minifier/src/traverse_context/ancestry.rs | Implements ancestry stack with safe public reads + internal mutation hooks. |
| crates/oxc_minifier/src/traverse_context/scoping.rs | Adds traversal-time scoping utilities and UID name generation entry point. |
| crates/oxc_minifier/src/traverse_context/uid.rs | Implements UID generation logic and adds test coverage. |
| crates/oxc_minifier/src/traverse_context/reusable.rs | Wraps TraverseCtx to allow safe reuse across traversals. |
| crates/oxc_minifier/src/traverse_context/bound_identifier.rs | Adds ergonomic APIs for creating bound identifiers/references. |
| crates/oxc_minifier/src/traverse_context/maybe_bound_identifier.rs | Adds ergonomic APIs for possibly-bound identifiers/references. |
| crates/oxc_minifier/src/traverse_context/ecma_context.rs | Implements required ecmascript context traits directly on minifier-local ctx. |
| crates/oxc_minifier/src/traverse_ast_operations/mod.rs | Introduces helper module for traversal-related AST operations. |
| crates/oxc_minifier/src/traverse_ast_operations/identifier.rs | Adds to_identifier helper with tests. |
| crates/oxc_minifier/src/traverse_ast_operations/gather_node_parts.rs | Adds Babel-inspired node-name gathering utilities with tests. |
| crates/oxc_minifier/src/symbol_value.rs | Minor cleanup related to field annotation. |
| crates/oxc_minifier/src/peephole/mod.rs | Migrates peephole pass to MinifierTraverse + local ctx. |
| crates/oxc_minifier/src/peephole/normalize.rs | Migrates normalize pass to MinifierTraverse + local ctx. |
| crates/oxc_minifier/src/peephole/substitute_alternate_syntax.rs | Updates signatures/imports to use minifier-local ctx + ancestor. |
| crates/oxc_minifier/src/peephole/replace_known_methods.rs | Updates signatures/imports to use minifier-local ctx + ancestor. |
| crates/oxc_minifier/src/peephole/remove_unused_private_members.rs | Updates signatures/imports to use minifier-local ctx. |
| crates/oxc_minifier/src/peephole/remove_unused_expression.rs | Updates signatures/imports to use minifier-local ctx. |
| crates/oxc_minifier/src/peephole/remove_unused_declaration.rs | Updates signatures/imports to use minifier-local ctx. |
| crates/oxc_minifier/src/peephole/remove_dead_code.rs | Updates signatures/imports to use minifier-local ctx + ancestor. |
| crates/oxc_minifier/src/peephole/minimize_statements.rs | Updates signatures/imports to use minifier-local ctx + ancestor. |
| crates/oxc_minifier/src/peephole/minimize_not_expression.rs | Updates signatures/imports to use minifier-local ctx. |
| crates/oxc_minifier/src/peephole/minimize_logical_expression.rs | Updates signatures/imports to use minifier-local ctx. |
| crates/oxc_minifier/src/peephole/minimize_if_statement.rs | Updates signatures/imports to use minifier-local ctx. |
| crates/oxc_minifier/src/peephole/minimize_for_statement.rs | Updates signatures/imports to use minifier-local ctx. |
| crates/oxc_minifier/src/peephole/minimize_expression_in_boolean_context.rs | Updates signatures/imports to use minifier-local ctx. |
| crates/oxc_minifier/src/peephole/minimize_conditions.rs | Updates signatures/imports to use minifier-local ctx. |
| crates/oxc_minifier/src/peephole/minimize_conditional_expression.rs | Updates signatures/imports to use minifier-local ctx. |
| crates/oxc_minifier/src/peephole/inline.rs | Updates signatures/imports to use minifier-local ctx + ancestor. |
| crates/oxc_minifier/src/peephole/fold_constants.rs | Updates signatures/imports to use minifier-local ctx. |
| crates/oxc_minifier/src/peephole/convert_to_dotted_properties.rs | Updates signatures/imports to use minifier-local ctx. |
| crates/oxc_minifier/Cargo.toml | Adds deps needed by new traversal context/utilities (oxc_str, itoa). |
| Cargo.lock | Locks new dependencies for oxc_minifier. |
CodSpeed Performance ReportMerging this PR will not alter performanceComparing Summary
Footnotes
|
Member
Author
Merge activity
|
…19106) ## Summary - generate a minifier-local traverse runtime in `oxc_minifier` - introduce handwritten `MinifierTraverseCtx` and move prior `Ctx` functionality into it - remove old `Ctx` usage and implement the needed traits on `MinifierTraverseCtx` - wire minifier passes/compressor to use local traverse - reuse `ancestor.rs` from `oxc_traverse` via path module in `oxc_minifier` ## Why - avoids orphan-rule friction around implementing traits on the prior context type - keeps minifier traversal concerns local to `oxc_minifier` ## Validation - `just fmt` - `cargo check -p oxc_ast_tools` - `cargo check -p oxc_minifier` - `cargo test -p oxc_minifier` - `just lint`
fbf4af9 to
500d071
Compare
camc314
added a commit
that referenced
this pull request
Feb 10, 2026
### 💥 BREAKING CHANGES - 2bf7293 mangler: [**BREAKING**] Enable `top_level` by default for modules and commonjs (#18278) (sapphi-red) - 48b0542 span: [**BREAKING**] SourceType::ts should set module to unambigious (#18873) (Boshen) ### 🚀 Features - 500d071 minifier: Local traverse ctx and generated minifier traverse (#19106) (Boshen) - 142a1be parser: Detect binary files with TS1490 error (#19047) (Boshen) - e316857 allocator/bitset: Add `Ones` iterator to `BitSet` (#19027) (sapphi-red) - 742ad3f minifier: Default `invalid_import_side_effects` to `false` (#18916) (sapphi-red) - 0eff6be parser: Error JSX-like type assertions and generics in `.mts`/`.cts` (#18910) (Boshen) - 18320c6 span: Store file extension in `SourceType` (#18893) (Boshen) ### 🐛 Bug Fixes - a7514e4 isolated-declarations: Preserve const context in literal type inference (#19178) (camc314) - 312e756 isolated-declarations: Preserve readonly literal initializers (#19177) (camc314) - d0ca8d0 isolated-declarations: Skip parenthesis when inferring type (#19176) (camc314) - 110c300 oxc_ecmascript: `+[false]` and `+[true]` should evaluate to `NaN` (#19174) (copilot-swe-agent) - f32ea19 semantic: Report redeclaration error for import bindings conflicting with value declarations (#19068) (Boshen) - 3aeba7a semantic: Report redeclaration error for `function a() {} var a` in module mode (#19041) (Boshen) - 35e32c6 coverage: Match Babel's options.json inheritance for test fixtures (#19002) (Boshen) - 463d60d semantic: Skip TS2391 for standalone computed-name class methods (#19025) (Boshen) - 56c086b parser: Add modifier ordering validation (TS1029) (#19024) (Boshen) - 6067a49 linter/jsdoc: False positive in `check-tag-names` for `@` in email addresses and npm scopes (#19021) (Boshen) - b13bb70 semantic/jsdoc: Inline tags like `{@link}` break jsdoc parsing (#19019) (Boshen) - e3609e3 regular_expression: Preserve UnicodeEscape CharacterKind in string literals (#18998) (Boshen) - 57917ee parser: Parse decorators on rest parameters (#18938) (Boshen) - 487601b napi: Disable mimalloc on Windows to fix worker_threads crash (#18923) (Boshen) - 1f6b193 parser: Validate TypeScript import type options (#18889) (Boshen) - 1663184 parser: Allow conditional types in function type parameters (#18886) (Boshen) - 5758046 parser: Error on property access after instantiation expression (#18887) (Boshen) - 5eb4a94 parser: Handle `<<` as two `<` tokens in type argument contexts (#18885) (Boshen) ### ⚡ Performance - ed8c054 oxc_str: Add precomputed hash to Ident for fast HashMap lookups (#19143) (Boshen) - d4a0867 transformer_plugins: Switch ReplaceGlobalDefines from Traverse to VisitMut (#19146) (Boshen) - 9eb16b3 syntax: Pack ASCII identifier tables into single bitflag table (#19088) (Boshen) - e7595d1 mangler: Use BitSet for exported symbols set (#19023) (sapphi-red) - 2537924 semantic: Optimize scope resolution with fast paths and inlining (#19029) (Boshen) - 69a8d85 mangler: Use BitSet for keep_names symbols set (#19028) (sapphi-red) - f78c525 parser: Try hybrid parsing for jsx children and closing element/fragments (#18789) (camchenry) Co-authored-by: camc314 <[email protected]>
owjs3901
pushed a commit
to owjs3901/oxc
that referenced
this pull request
Feb 11, 2026
### 💥 BREAKING CHANGES - 2bf7293 mangler: [**BREAKING**] Enable `top_level` by default for modules and commonjs (oxc-project#18278) (sapphi-red) - 48b0542 span: [**BREAKING**] SourceType::ts should set module to unambigious (oxc-project#18873) (Boshen) ### 🚀 Features - 500d071 minifier: Local traverse ctx and generated minifier traverse (oxc-project#19106) (Boshen) - 142a1be parser: Detect binary files with TS1490 error (oxc-project#19047) (Boshen) - e316857 allocator/bitset: Add `Ones` iterator to `BitSet` (oxc-project#19027) (sapphi-red) - 742ad3f minifier: Default `invalid_import_side_effects` to `false` (oxc-project#18916) (sapphi-red) - 0eff6be parser: Error JSX-like type assertions and generics in `.mts`/`.cts` (oxc-project#18910) (Boshen) - 18320c6 span: Store file extension in `SourceType` (oxc-project#18893) (Boshen) ### 🐛 Bug Fixes - a7514e4 isolated-declarations: Preserve const context in literal type inference (oxc-project#19178) (camc314) - 312e756 isolated-declarations: Preserve readonly literal initializers (oxc-project#19177) (camc314) - d0ca8d0 isolated-declarations: Skip parenthesis when inferring type (oxc-project#19176) (camc314) - 110c300 oxc_ecmascript: `+[false]` and `+[true]` should evaluate to `NaN` (oxc-project#19174) (copilot-swe-agent) - f32ea19 semantic: Report redeclaration error for import bindings conflicting with value declarations (oxc-project#19068) (Boshen) - 3aeba7a semantic: Report redeclaration error for `function a() {} var a` in module mode (oxc-project#19041) (Boshen) - 35e32c6 coverage: Match Babel's options.json inheritance for test fixtures (oxc-project#19002) (Boshen) - 463d60d semantic: Skip TS2391 for standalone computed-name class methods (oxc-project#19025) (Boshen) - 56c086b parser: Add modifier ordering validation (TS1029) (oxc-project#19024) (Boshen) - 6067a49 linter/jsdoc: False positive in `check-tag-names` for `@` in email addresses and npm scopes (oxc-project#19021) (Boshen) - b13bb70 semantic/jsdoc: Inline tags like `{@link}` break jsdoc parsing (oxc-project#19019) (Boshen) - e3609e3 regular_expression: Preserve UnicodeEscape CharacterKind in string literals (oxc-project#18998) (Boshen) - 57917ee parser: Parse decorators on rest parameters (oxc-project#18938) (Boshen) - 487601b napi: Disable mimalloc on Windows to fix worker_threads crash (oxc-project#18923) (Boshen) - 1f6b193 parser: Validate TypeScript import type options (oxc-project#18889) (Boshen) - 1663184 parser: Allow conditional types in function type parameters (oxc-project#18886) (Boshen) - 5758046 parser: Error on property access after instantiation expression (oxc-project#18887) (Boshen) - 5eb4a94 parser: Handle `<<` as two `<` tokens in type argument contexts (oxc-project#18885) (Boshen) ### ⚡ Performance - ed8c054 oxc_str: Add precomputed hash to Ident for fast HashMap lookups (oxc-project#19143) (Boshen) - d4a0867 transformer_plugins: Switch ReplaceGlobalDefines from Traverse to VisitMut (oxc-project#19146) (Boshen) - 9eb16b3 syntax: Pack ASCII identifier tables into single bitflag table (oxc-project#19088) (Boshen) - e7595d1 mangler: Use BitSet for exported symbols set (oxc-project#19023) (sapphi-red) - 2537924 semantic: Optimize scope resolution with fast paths and inlining (oxc-project#19029) (Boshen) - 69a8d85 mangler: Use BitSet for keep_names symbols set (oxc-project#19028) (sapphi-red) - f78c525 parser: Try hybrid parsing for jsx children and closing element/fragments (oxc-project#18789) (camchenry) Co-authored-by: camc314 <[email protected]>
OskarLebuda
pushed a commit
to OskarLebuda/oxc
that referenced
this pull request
Feb 17, 2026
…xc-project#19106) ## Summary - generate a minifier-local traverse runtime in `oxc_minifier` - introduce handwritten `MinifierTraverseCtx` and move prior `Ctx` functionality into it - remove old `Ctx` usage and implement the needed traits on `MinifierTraverseCtx` - wire minifier passes/compressor to use local traverse - reuse `ancestor.rs` from `oxc_traverse` via path module in `oxc_minifier` ## Why - avoids orphan-rule friction around implementing traits on the prior context type - keeps minifier traversal concerns local to `oxc_minifier` ## Validation - `just fmt` - `cargo check -p oxc_ast_tools` - `cargo check -p oxc_minifier` - `cargo test -p oxc_minifier` - `just lint`
OskarLebuda
pushed a commit
to OskarLebuda/oxc
that referenced
this pull request
Feb 17, 2026
### 💥 BREAKING CHANGES - 2bf7293 mangler: [**BREAKING**] Enable `top_level` by default for modules and commonjs (oxc-project#18278) (sapphi-red) - 48b0542 span: [**BREAKING**] SourceType::ts should set module to unambigious (oxc-project#18873) (Boshen) ### 🚀 Features - 500d071 minifier: Local traverse ctx and generated minifier traverse (oxc-project#19106) (Boshen) - 142a1be parser: Detect binary files with TS1490 error (oxc-project#19047) (Boshen) - e316857 allocator/bitset: Add `Ones` iterator to `BitSet` (oxc-project#19027) (sapphi-red) - 742ad3f minifier: Default `invalid_import_side_effects` to `false` (oxc-project#18916) (sapphi-red) - 0eff6be parser: Error JSX-like type assertions and generics in `.mts`/`.cts` (oxc-project#18910) (Boshen) - 18320c6 span: Store file extension in `SourceType` (oxc-project#18893) (Boshen) ### 🐛 Bug Fixes - a7514e4 isolated-declarations: Preserve const context in literal type inference (oxc-project#19178) (camc314) - 312e756 isolated-declarations: Preserve readonly literal initializers (oxc-project#19177) (camc314) - d0ca8d0 isolated-declarations: Skip parenthesis when inferring type (oxc-project#19176) (camc314) - 110c300 oxc_ecmascript: `+[false]` and `+[true]` should evaluate to `NaN` (oxc-project#19174) (copilot-swe-agent) - f32ea19 semantic: Report redeclaration error for import bindings conflicting with value declarations (oxc-project#19068) (Boshen) - 3aeba7a semantic: Report redeclaration error for `function a() {} var a` in module mode (oxc-project#19041) (Boshen) - 35e32c6 coverage: Match Babel's options.json inheritance for test fixtures (oxc-project#19002) (Boshen) - 463d60d semantic: Skip TS2391 for standalone computed-name class methods (oxc-project#19025) (Boshen) - 56c086b parser: Add modifier ordering validation (TS1029) (oxc-project#19024) (Boshen) - 6067a49 linter/jsdoc: False positive in `check-tag-names` for `@` in email addresses and npm scopes (oxc-project#19021) (Boshen) - b13bb70 semantic/jsdoc: Inline tags like `{@link}` break jsdoc parsing (oxc-project#19019) (Boshen) - e3609e3 regular_expression: Preserve UnicodeEscape CharacterKind in string literals (oxc-project#18998) (Boshen) - 57917ee parser: Parse decorators on rest parameters (oxc-project#18938) (Boshen) - 487601b napi: Disable mimalloc on Windows to fix worker_threads crash (oxc-project#18923) (Boshen) - 1f6b193 parser: Validate TypeScript import type options (oxc-project#18889) (Boshen) - 1663184 parser: Allow conditional types in function type parameters (oxc-project#18886) (Boshen) - 5758046 parser: Error on property access after instantiation expression (oxc-project#18887) (Boshen) - 5eb4a94 parser: Handle `<<` as two `<` tokens in type argument contexts (oxc-project#18885) (Boshen) ### ⚡ Performance - ed8c054 oxc_str: Add precomputed hash to Ident for fast HashMap lookups (oxc-project#19143) (Boshen) - d4a0867 transformer_plugins: Switch ReplaceGlobalDefines from Traverse to VisitMut (oxc-project#19146) (Boshen) - 9eb16b3 syntax: Pack ASCII identifier tables into single bitflag table (oxc-project#19088) (Boshen) - e7595d1 mangler: Use BitSet for exported symbols set (oxc-project#19023) (sapphi-red) - 2537924 semantic: Optimize scope resolution with fast paths and inlining (oxc-project#19029) (Boshen) - 69a8d85 mangler: Use BitSet for keep_names symbols set (oxc-project#19028) (sapphi-red) - f78c525 parser: Try hybrid parsing for jsx children and closing element/fragments (oxc-project#18789) (camchenry) Co-authored-by: camc314 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
oxc_minifierMinifierTraverseCtxand move priorCtxfunctionality into itCtxusage and implement the needed traits onMinifierTraverseCtxancestor.rsfromoxc_traversevia path module inoxc_minifierWhy
oxc_minifierValidation
just fmtcargo check -p oxc_ast_toolscargo check -p oxc_minifiercargo test -p oxc_minifierjust lint