Skip to content

refactor: feature-gate via langauges and other core features#10762

Merged
ematipico merged 10 commits into
mainfrom
refactor/opt-in-langs
Jun 26, 2026
Merged

refactor: feature-gate via langauges and other core features#10762
ematipico merged 10 commits into
mainfrom
refactor/opt-in-langs

Conversation

@ematipico

@ematipico ematipico commented Jun 25, 2026

Copy link
Copy Markdown
Member

Summary

This PR finishes the feature gating for the Biome service. This job was done to make tests and benches a bit smoother and faster, and reduce the build pressure of the jobs. We have almost 100 crates and more.

All languages, except for JSON inside biome_service, have been gated. The reason why JSON was excluded for now is that we use it to parse the configuration file. I will refactor it later.

Other than languages, we have the following feature gates:

  • html_embeds
  • js_embeds
  • module_graph
  • type_inference

I used a coding agent to help me with this. It was mostly a mechanical job, but I also changed things on the way. The existing features must be unchanged.

Test Plan

Green CI

Docs

N/A

@changeset-bot

changeset-bot Bot commented Jun 25, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 647ea75

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions

Copy link
Copy Markdown
Contributor

✅ Organic activity

No automation signals detected in the analyzed events.

View full analysis →

This is an automated analysis by AgentScan

@github-actions github-actions Bot added A-CLI Area: CLI A-Project Area: project A-Linter Area: linter A-Formatter Area: formatter L-JavaScript Language: JavaScript and super languages L-CSS Language: CSS and super languages L-JSON Language: JSON and super languages L-HTML Language: HTML and super languages L-Grit Language: GritQL A-Type-Inference Area: type inference L-Yaml Language: Yaml labels Jun 25, 2026
@ematipico ematipico requested review from a team June 25, 2026 10:17
@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ebe12b61-b243-46af-997f-30bbf509d32d

📥 Commits

Reviewing files that changed from the base of the PR and between 815df3a and 647ea75.

📒 Files selected for processing (1)
  • crates/biome_module_graph/Cargo.toml
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/biome_module_graph/Cargo.toml

Walkthrough

This PR adds feature-flag wiring across workspace crates so language-specific dependencies, configuration, embed handling, module-graph paths, and test utilities only compile when the matching features are enabled. It also introduces separate HTML and JS embed modules, updates go-to-definition and workspace/module-graph plumbing, and adjusts settings and override mapping for the new feature layout.

Possibly related PRs

  • biomejs/biome#9700: Touches the same HTML and JS go-to-definition resolver paths.
  • biomejs/biome#10315: Changes the module-graph and workspace resolution plumbing in the same service area.
  • biomejs/biome#9920: Also adjusts crates/biome_configuration public exports and feature gating.

Suggested reviewers

  • dyc3
  • denbezrukov
  • Conaclos
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the main change: broad feature-gating across language and core features.
Description check ✅ Passed The description clearly covers the feature-gating work, motivation, scope, and test plan.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/opt-in-langs

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🧹 Nitpick comments (3)
crates/biome_service/src/file_handlers/css.rs (1)

616-625: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚖️ Poor tradeoff

Same module_db cfg incantation copy-pasted eight times.

This exact block appears across lint, code_actions, and three fix_all sites here (and again in html.rs). Consider exposing a single always-compiled helper on WorkspaceDb so the cfg lives in one place:

♻️ Suggested helper (in biome_workspace_db)
impl WorkspaceDb {
    /// Returns the module DB when the `module_graph` feature is enabled, else `None`.
    pub fn optional_module_db(&self) -> Option<Rc<dyn ModuleDb>> {
        #[cfg(feature = "module_graph")]
        { Some(self.rc_module_db()) }
        #[cfg(not(feature = "module_graph"))]
        { None }
    }
}

Each call site then collapses to module_db: params.workspace_db.optional_module_db(),. Purely optional, but it trims eight copies that would otherwise have to be kept in lockstep forever.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/biome_service/src/file_handlers/css.rs` around lines 616 - 625, The
`module_db` feature-gating logic is duplicated across multiple call sites,
including the `css.rs` handlers and related `html.rs` paths. Add a single
always-compiled helper on `WorkspaceDb` (for example, `optional_module_db`) that
encapsulates the `#[cfg(feature = "module_graph")]` / `#[cfg(not(feature =
"module_graph"))]` split and returns the optional module DB. Then update the
`module_db:` assignments in `lint`, `code_actions`, and the `fix_all` sites to
call that helper instead of repeating the cfg block.
crates/biome_service/Cargo.toml (1)

170-172: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Two unresolved TODOs about feature dependencies.

Lines 170 and 202 leave open questions on whether module_graph and type_inference need extra lang_* deps. Worth resolving before merge so the matrix isn't a guess.

Happy to draft a verification script that maps the cfg(feature=...) usages in the relevant source files to confirm the correct dependency set — just say the word.

Also applies to: 202-203

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/biome_service/Cargo.toml` around lines 170 - 172, Resolve the
unresolved feature-dependency TODOs in Cargo.toml by verifying which lang_*
crates are actually required for module_graph and type_inference. Check the
cfg(feature=...) usage in the relevant code paths and update the feature lists
for module_graph, type_inference, and any related entries so the declared
dependencies match the real usage instead of leaving the matrix as a guess.
crates/biome_service/src/file_handlers/javascript.rs (1)

1536-1547: 🩺 Stability & Availability | 🔵 Trivial | 💤 Low value

Prefer a graceful fallback over panic! here, to match the HTML handler.

The #[cfg(not(feature = "js_embeds"))] stub panics, whereas file_handlers/html.rs falls back to plain format(...) in the same situation. It's currently unreachable (the non-js_embeds parse_embedded_nodes returns empty, so embedded_nodes is never non-empty), but mirroring HTML keeps the two handlers symmetric and removes a latent foot-gun if capability wiring ever changes.

♻️ Fall back to format
     #[cfg(not(feature = "js_embeds"))]
     {
-        let _ = (
-            biome_path,
-            document_file_source,
-            parse,
-            settings,
-            embedded_nodes,
-            workspace_db,
-        );
-        panic!("formatting embedded JavaScript snippets requires the `js_embeds` feature")
+        let _ = embedded_nodes;
+        format(biome_path, document_file_source, parse, settings, workspace_db)
     }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/biome_service/src/file_handlers/javascript.rs` around lines 1536 -
1547, The `#[cfg(not(feature = "js_embeds"))]` branch in `parse_embedded_nodes`
should not `panic!`; mirror the HTML handler’s behavior and fall back to the
normal `format(...)` path instead. Update the JavaScript file handler in
`javascript.rs` so the non-`js_embeds` stub remains a graceful no-op/formatting
fallback, using the same surrounding logic and symbols like
`parse_embedded_nodes`, `embedded_nodes`, and `format` to keep the handlers
symmetric.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/biome_service/src/diagnostics.rs`:
- Line 790: The test module currently imports
biome_module_graph::JsModuleInfoDiagnostic unconditionally, which breaks builds
when the optional module_graph feature is disabled. Gate the import and the
module_diagnostic test helper with #[cfg(feature = "module_graph")] so the
diagnostics.rs test code only compiles when module_graph is enabled, and cargo
test --no-default-features continues to build.

---

Nitpick comments:
In `@crates/biome_service/Cargo.toml`:
- Around line 170-172: Resolve the unresolved feature-dependency TODOs in
Cargo.toml by verifying which lang_* crates are actually required for
module_graph and type_inference. Check the cfg(feature=...) usage in the
relevant code paths and update the feature lists for module_graph,
type_inference, and any related entries so the declared dependencies match the
real usage instead of leaving the matrix as a guess.

In `@crates/biome_service/src/file_handlers/css.rs`:
- Around line 616-625: The `module_db` feature-gating logic is duplicated across
multiple call sites, including the `css.rs` handlers and related `html.rs`
paths. Add a single always-compiled helper on `WorkspaceDb` (for example,
`optional_module_db`) that encapsulates the `#[cfg(feature = "module_graph")]` /
`#[cfg(not(feature = "module_graph"))]` split and returns the optional module
DB. Then update the `module_db:` assignments in `lint`, `code_actions`, and the
`fix_all` sites to call that helper instead of repeating the cfg block.

In `@crates/biome_service/src/file_handlers/javascript.rs`:
- Around line 1536-1547: The `#[cfg(not(feature = "js_embeds"))]` branch in
`parse_embedded_nodes` should not `panic!`; mirror the HTML handler’s behavior
and fall back to the normal `format(...)` path instead. Update the JavaScript
file handler in `javascript.rs` so the non-`js_embeds` stub remains a graceful
no-op/formatting fallback, using the same surrounding logic and symbols like
`parse_embedded_nodes`, `embedded_nodes`, and `format` to keep the handlers
symmetric.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b717f512-071a-4cd4-a13b-2de4a082afa9

📥 Commits

Reviewing files that changed from the base of the PR and between 54e8239 and a659647.

⛔ Files ignored due to path filters (2)
  • Cargo.lock is excluded by !**/*.lock and included by **
  • crates/biome_configuration/src/analyzer/linter/rules.rs is excluded by !**/rules.rs and included by **
📒 Files selected for processing (57)
  • crates/biome_cli/Cargo.toml
  • crates/biome_configuration/Cargo.toml
  • crates/biome_configuration/src/analyzer/assist/actions.rs
  • crates/biome_configuration/src/lib.rs
  • crates/biome_configuration/src/overrides.rs
  • crates/biome_configuration_macros/Cargo.toml
  • crates/biome_configuration_macros/src/group_struct.rs
  • crates/biome_configuration_macros/src/lib.rs
  • crates/biome_configuration_macros/src/visitors.rs
  • crates/biome_css_analyze/Cargo.toml
  • crates/biome_css_formatter/Cargo.toml
  • crates/biome_formatter_test/Cargo.toml
  • crates/biome_graphql_formatter/Cargo.toml
  • crates/biome_grit_formatter/Cargo.toml
  • crates/biome_html_analyze/Cargo.toml
  • crates/biome_html_formatter/Cargo.toml
  • crates/biome_js_analyze/Cargo.toml
  • crates/biome_js_formatter/Cargo.toml
  • crates/biome_js_transform/Cargo.toml
  • crates/biome_js_type_info/Cargo.toml
  • crates/biome_json_analyze/Cargo.toml
  • crates/biome_json_formatter/Cargo.toml
  • crates/biome_module_graph/Cargo.toml
  • crates/biome_ruledoc_utils/Cargo.toml
  • crates/biome_service/Cargo.toml
  • crates/biome_service/src/configuration.rs
  • crates/biome_service/src/diagnostics.rs
  • crates/biome_service/src/documentation/mod.rs
  • crates/biome_service/src/embed/detector.rs
  • crates/biome_service/src/embed/html.rs
  • crates/biome_service/src/embed/js.rs
  • crates/biome_service/src/embed/mod.rs
  • crates/biome_service/src/embed/registry.rs
  • crates/biome_service/src/embed/types.rs
  • crates/biome_service/src/file_handlers/css.rs
  • crates/biome_service/src/file_handlers/css/go_to.rs
  • crates/biome_service/src/file_handlers/html.rs
  • crates/biome_service/src/file_handlers/html/go_to.rs
  • crates/biome_service/src/file_handlers/html/parse_embedded_nodes.rs
  • crates/biome_service/src/file_handlers/javascript.rs
  • crates/biome_service/src/file_handlers/javascript/go_to.rs
  • crates/biome_service/src/file_handlers/mod.rs
  • crates/biome_service/src/lib.rs
  • crates/biome_service/src/module_graph.rs
  • crates/biome_service/src/scanner.rs
  • crates/biome_service/src/scanner/workspace_bridges.rs
  • crates/biome_service/src/settings.rs
  • crates/biome_service/src/workspace.rs
  • crates/biome_service/src/workspace/db.rs
  • crates/biome_service/src/workspace/search/grit.rs
  • crates/biome_service/src/workspace/search/mod.rs
  • crates/biome_service/src/workspace/server.rs
  • crates/biome_test_utils/Cargo.toml
  • crates/biome_test_utils/src/lib.rs
  • crates/biome_workspace_db/Cargo.toml
  • crates/biome_workspace_db/src/lib.rs
  • crates/biome_yaml_formatter/Cargo.toml
💤 Files with no reviewable changes (3)
  • crates/biome_service/src/embed/detector.rs
  • crates/biome_service/src/embed/registry.rs
  • crates/biome_service/src/embed/types.rs

Comment thread crates/biome_service/src/diagnostics.rs
@ematipico ematipico force-pushed the refactor/opt-in-langs branch from a659647 to dd3ca2d Compare June 25, 2026 10:37
@codspeed-hq

codspeed-hq Bot commented Jun 25, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 30.63%

⚡ 1 improved benchmark
❌ 1 regressed benchmark
✅ 247 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
deserialize_from_json_str[biome.json] 389.4 µs 859.5 µs -54.7%
uncached[simple_classes.txt] 219.3 µs 206.4 µs +6.24%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing refactor/opt-in-langs (647ea75) with main (54e8239)

Open in CodSpeed

@ematipico ematipico force-pushed the refactor/opt-in-langs branch from e45eaf8 to 815df3a Compare June 25, 2026 12:41
@github-actions github-actions Bot added the A-LSP Area: language server protocol label Jun 25, 2026
@ematipico ematipico merged commit 1e7dbfc into main Jun 26, 2026
37 of 38 checks passed
@ematipico ematipico deleted the refactor/opt-in-langs branch June 26, 2026 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CLI Area: CLI A-Formatter Area: formatter A-Linter Area: linter A-LSP Area: language server protocol A-Project Area: project A-Type-Inference Area: type inference L-CSS Language: CSS and super languages L-Grit Language: GritQL L-HTML Language: HTML and super languages L-JavaScript Language: JavaScript and super languages L-JSON Language: JSON and super languages L-Yaml Language: Yaml

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant