Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 10, 2025

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

    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.

@graphite-app
Copy link
Contributor

graphite-app bot commented Nov 10, 2025

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 hot fixes, skip the queue and merge this PR next

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.

Copilot AI changed the title [WIP] Remove dependency of ast_tools on Oxc crates from crates.io Break circular dependency of ast_tools on Oxc crates from crates.io Nov 10, 2025
Copilot AI requested a review from overlookmotel November 10, 2025 19:45
Copilot finished work on behalf of overlookmotel November 10, 2025 19:45
@github-actions github-actions bot added the A-ast-tools Area - AST tools label Nov 11, 2025
@overlookmotel overlookmotel changed the title Break circular dependency of ast_tools on Oxc crates from crates.io fix(ast_tools): oxc_ast_tools depend on local oxc_* crates Nov 11, 2025
@github-actions github-actions bot added the C-bug Category - Bug label Nov 11, 2025
@overlookmotel overlookmotel marked this pull request as ready for review November 11, 2025 10:43
Copilot AI review requested due to automatic review settings November 11, 2025 10:43
Copilot finished reviewing on behalf of overlookmotel November 11, 2025 10:46
Copy link
Contributor

Copilot AI left a comment

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 fixes a circular dependency issue where oxc_ast_tools depends on crates.io versions of oxc_* crates (v0.96.0), which prevents compilation when local AST changes break those crates before codegen can run to fix them.

Key changes:

  • Adds a generate-js feature flag (enabled by default) to make JavaScript generators optional
  • Makes all oxc_* crate dependencies optional, activated only when the feature is enabled
  • Implements fallback logic in the just ast command to retry without JS generators if the first attempt fails

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tasks/ast_tools/Cargo.toml Adds generate-js feature flag and makes all oxc_* dependencies optional
tasks/ast_tools/src/main.rs Adds conditional compilation for JS generators and updates comments
tasks/ast_tools/src/generators/mod.rs Gates JS generator module declarations and exports behind feature flag
tasks/ast_tools/src/output/mod.rs Gates Javascript output variant and related functions behind feature flag
justfile Updates ast command with fallback logic to handle compilation failures

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@overlookmotel overlookmotel marked this pull request as draft November 11, 2025 10:57
@overlookmotel overlookmotel marked this pull request as ready for review November 11, 2025 11:04
@overlookmotel overlookmotel force-pushed the copilot/remove-ast-tools-dependency branch from cb8292c to cacd59d Compare November 11, 2025 11:10
@codspeed-hq
Copy link

codspeed-hq bot commented Nov 11, 2025

CodSpeed Performance Report

Merging #15565 will not alter performance

Comparing copilot/remove-ast-tools-dependency (c30ef5a) with main (635e74c)1

Summary

✅ 37 untouched

Footnotes

  1. No successful run was found on main (e389b47) during the generation of this report, so 635e74c was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@overlookmotel
Copy link
Member

@Boshen please see my comment: #15564 (comment)

If you agree with the rationale, I think this PR is good to go. It means we no longer have dependencies on our own crates from crates.io.

@overlookmotel overlookmotel force-pushed the copilot/remove-ast-tools-dependency branch from cacd59d to c30ef5a Compare November 11, 2025 13:13
@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Nov 11, 2025
Copy link
Member

Boshen commented Nov 11, 2025

Merge activity

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.
@graphite-app graphite-app bot force-pushed the copilot/remove-ast-tools-dependency branch from c30ef5a to 6d4efdd Compare November 11, 2025 16:12
@graphite-app graphite-app bot merged commit 6d4efdd into main Nov 11, 2025
21 checks passed
@graphite-app graphite-app bot deleted the copilot/remove-ast-tools-dependency branch November 11, 2025 16:17
graphite-app bot pushed a commit that referenced this pull request Nov 11, 2025
#15603)

#15565 made `oxc_ast_tools` depend on local workspace versions of various crates. Add those crates to the watch list for "AST Changes" CI task, so if changes are made in them, `ast_tools` codegen will run to ensure generated code has been updated to reflect those changes.

In particular, this will prevent generated code getting out of sync when changes to minifier affect the generated code.
graphite-app bot pushed a commit that referenced this pull request Nov 14, 2025
According to Claude, `just ast` in its current form will not work on Windows, as PowerShell does not support `( ... )` for command groupings. Switch to `{ ... }`.

This script was added in #15565. Copilot writes it, Claude critiques it!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

0-merge Merge with Graphite Merge Queue A-ast-tools Area - AST tools C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove dependency of ast_tools on Oxc crates from crates.io

3 participants