Feature flag the use of `oak_package_metadata` and `oak_sources` in `oak_index`?
Hi, I'm experimenting with Claude to use the new Oak infrastructure in Jarl to get diagnostics on unused objects and unused function arguments (https://github.com/etiennebacher/jarl/pull/478, https://github.com/etiennebacher/jarl/pull/479). I noticed that pulling `oak_index` also adds a lot of dependencies from `oak_package_metadata` and `oak_sources`. I'm wondering if it is possible to put these imports behind a feature flag so that I have the option to not pull all those dependencies.
I don't think this requires large changes in `oak_index`, see below a patch generated by Claude. Using this patch locally removed 69 dependencies from Jarl (mostly because `rustls` isn't imported anymore) while keeping the key features of `oak_index`. I know this is still early stage and WIP on your side, but I wanted to raise this early in case it influences future development. Maybe you were already planning to address this in some way.
Thanks, and I'm really curious to see the future capabilities of Oak!
<details>
<summary>Claude patch</summary>
```diff
diff --git a/crates/oak_index/Cargo.toml b/crates/oak_index/Cargo.toml
index 817e9546..d5a1399a 100644
--- a/crates/oak_index/Cargo.toml
+++ b/crates/oak_index/Cargo.toml
@@ -12,6 +12,12 @@ license.workspace = true
rust-version.workspace = true
[features]
+default = ["package_metadata"]
+# Enables the `library`, `package`, `package_definitions`, `scope_layer`, and
+# `external` modules, which model installed R packages and cross-file scope
+# resolution. Disable for lighter consumers (e.g. linters running per-file
+# semantic analysis) that don't need installed-package lookups.
+package_metadata = ["dep:oak_package_metadata", "dep:oak_sources"]
testing = ["dep:tempfile"]
[lints]
@@ -27,13 +33,19 @@ itertools.workspace = true
log.workspace = true
oak_core.workspace = true
oak_index_vec.workspace = true
-oak_package_metadata.workspace = true
-oak_sources.workspace = true
rustc-hash.workspace = true
smallvec.workspace = true
stdext.workspace = true
url.workspace = true
+[dependencies.oak_package_metadata]
+workspace = true
+optional = true
+
+[dependencies.oak_sources]
+workspace = true
+optional = true
+
[dependencies.tempfile]
workspace = true
optional = true
diff --git a/crates/oak_index/src/lib.rs b/crates/oak_index/src/lib.rs
index 94301573..9f857358 100644
--- a/crates/oak_index/src/lib.rs
+++ b/crates/oak_index/src/lib.rs
@@ -1,8 +1,13 @@
pub mod builder;
+#[cfg(feature = "package_metadata")]
pub mod external;
+#[cfg(feature = "package_metadata")]
pub mod library;
+#[cfg(feature = "package_metadata")]
pub mod package;
+#[cfg(feature = "package_metadata")]
pub mod package_definitions;
+#[cfg(feature = "package_metadata")]
pub mod scope_layer;
pub mod semantic_index;
pub mod use_def_map;
```
</details>
2 条评论