refactor: feature-gate via langauges and other core features#10762
Conversation
|
✅ Organic activityNo automation signals detected in the analyzed events. This is an automated analysis by AgentScan |
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThis 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
Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (3)
crates/biome_service/src/file_handlers/css.rs (1)
616-625: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚖️ Poor tradeoffSame
module_dbcfg incantation copy-pasted eight times.This exact block appears across
lint,code_actions, and threefix_allsites here (and again inhtml.rs). Consider exposing a single always-compiled helper onWorkspaceDbso 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 valueTwo unresolved TODOs about feature dependencies.
Lines 170 and 202 leave open questions on whether
module_graphandtype_inferenceneed extralang_*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 valuePrefer a graceful fallback over
panic!here, to match the HTML handler.The
#[cfg(not(feature = "js_embeds"))]stub panics, whereasfile_handlers/html.rsfalls back to plainformat(...)in the same situation. It's currently unreachable (the non-js_embedsparse_embedded_nodesreturns empty, soembedded_nodesis 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
⛔ Files ignored due to path filters (2)
Cargo.lockis excluded by!**/*.lockand included by**crates/biome_configuration/src/analyzer/linter/rules.rsis excluded by!**/rules.rsand included by**
📒 Files selected for processing (57)
crates/biome_cli/Cargo.tomlcrates/biome_configuration/Cargo.tomlcrates/biome_configuration/src/analyzer/assist/actions.rscrates/biome_configuration/src/lib.rscrates/biome_configuration/src/overrides.rscrates/biome_configuration_macros/Cargo.tomlcrates/biome_configuration_macros/src/group_struct.rscrates/biome_configuration_macros/src/lib.rscrates/biome_configuration_macros/src/visitors.rscrates/biome_css_analyze/Cargo.tomlcrates/biome_css_formatter/Cargo.tomlcrates/biome_formatter_test/Cargo.tomlcrates/biome_graphql_formatter/Cargo.tomlcrates/biome_grit_formatter/Cargo.tomlcrates/biome_html_analyze/Cargo.tomlcrates/biome_html_formatter/Cargo.tomlcrates/biome_js_analyze/Cargo.tomlcrates/biome_js_formatter/Cargo.tomlcrates/biome_js_transform/Cargo.tomlcrates/biome_js_type_info/Cargo.tomlcrates/biome_json_analyze/Cargo.tomlcrates/biome_json_formatter/Cargo.tomlcrates/biome_module_graph/Cargo.tomlcrates/biome_ruledoc_utils/Cargo.tomlcrates/biome_service/Cargo.tomlcrates/biome_service/src/configuration.rscrates/biome_service/src/diagnostics.rscrates/biome_service/src/documentation/mod.rscrates/biome_service/src/embed/detector.rscrates/biome_service/src/embed/html.rscrates/biome_service/src/embed/js.rscrates/biome_service/src/embed/mod.rscrates/biome_service/src/embed/registry.rscrates/biome_service/src/embed/types.rscrates/biome_service/src/file_handlers/css.rscrates/biome_service/src/file_handlers/css/go_to.rscrates/biome_service/src/file_handlers/html.rscrates/biome_service/src/file_handlers/html/go_to.rscrates/biome_service/src/file_handlers/html/parse_embedded_nodes.rscrates/biome_service/src/file_handlers/javascript.rscrates/biome_service/src/file_handlers/javascript/go_to.rscrates/biome_service/src/file_handlers/mod.rscrates/biome_service/src/lib.rscrates/biome_service/src/module_graph.rscrates/biome_service/src/scanner.rscrates/biome_service/src/scanner/workspace_bridges.rscrates/biome_service/src/settings.rscrates/biome_service/src/workspace.rscrates/biome_service/src/workspace/db.rscrates/biome_service/src/workspace/search/grit.rscrates/biome_service/src/workspace/search/mod.rscrates/biome_service/src/workspace/server.rscrates/biome_test_utils/Cargo.tomlcrates/biome_test_utils/src/lib.rscrates/biome_workspace_db/Cargo.tomlcrates/biome_workspace_db/src/lib.rscrates/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
a659647 to
dd3ca2d
Compare
Merging this PR will degrade performance by 30.63%
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing |
e45eaf8 to
815df3a
Compare
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_embedsjs_embedsmodule_graphtype_inferenceI 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