Commit 6d4efdd
committed
Fix #15564.
`oxc_ast_tools` depends on Oxc crates from crates.io, not the local workspace. When AST changes break local crates, the codegen can't compile either - a Catch-22 situation, since running codegen is the only way to fix compilation.
This isn't ideal as it complicates dependency management. Alter `oxc_ast_tools` so it depends on crates from local workspace, and work around the Catch-22 problem by introducing a `generate-js` Cargo feature which disables these dependencies, so the codegen can still compile if they're broken.
## Changes
- **Add `generate-js` Cargo feature** (enabled by default)
- Makes all `oxc_*` dependencies optional, activated only when feature enabled.
- Only JS generators (`RawTransferGenerator`, `TypescriptGenerator`, `ESTreeVisitGenerator`, `RawTransferLazyGenerator`) require these dependencies.
- **Conditional compilation**
- Gate JS generator modules and `Output::Javascript` variant behind `#[cfg(feature = "generate-js")]`
- **Fallback in `just ast`**
```sh
cargo run -p oxc_ast_tools || (
cargo run -p oxc_ast_tools --no-default-features
&& cargo run -p oxc_ast_tools
)
```
First attempts to run full codegen. On failure, regenerates Rust code only, without dependencies (so that `oxc_*` crates will now compile), then retries full generation.
1 parent e763919 commit 6d4efdd
File tree
6 files changed
+314
-538
lines changed- tasks/ast_tools
- src
- generators
- output
6 files changed
+314
-538
lines changed
0 commit comments