Skip to content

Commit

Permalink
feat!: generic fs cache `type Resolver = ResolverGeneric<FsCache<File…
Browse files Browse the repository at this point in the history
…SystemOs>>` (#358)

This PR makes the cache fully generic by introducing a `Cache` trait,
and renaming the existing `Cache` to `FsCache`.

The `FileSystem` trait still exists, but is only relevant still for
users of `FsCache`. By keeping the trait, I hope to minimize the amount
of breaking changes, even though some still remain.

The most notable breaking change is that
`ResolverGeneric::new_with_file_system(fs, ...)` has become
`ResolverGeneric::new_with_cache(Arc::new(FsCache::new(fs)), ...)`.

Both `FsCache` and `FileSystem` are now behind a `fs_cache` feature
flag, which is enabled by default.

I am actually considering to make both the `PackageJson` and `TsConfig`
types generic as well (Biome already has its own, which ideally we would
use directly for our custom `Cache` implementation). This should be
achievable by introducing traits for them and adding them as associated
types to the `Cache` trait. But before going too deep, I was hoping to
first get feedback on the work so far :)
  • Loading branch information
arendjr authored Jan 16, 2025
1 parent 29807ba commit 2bc5173
Show file tree
Hide file tree
Showing 16 changed files with 762 additions and 629 deletions.
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ rayon = { version = "1.10.0" }
vfs = "0.12.0" # for testing with in memory file system

[features]
default = []
default = ["fs_cache"]
## Provides the `FsCache` implementation.
fs_cache = []
## Enables the [PackageJson::raw_json] API,
## which returns the `package.json` with `serde_json::Value`.
package_json_raw_json_api = []
Expand Down
Loading

0 comments on commit 2bc5173

Please sign in to comment.