Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: generic fs cache type Resolver = ResolverGeneric<FsCache<FileSystemOs>> #358

Merged
merged 8 commits into from
Jan 16, 2025

Conversation

arendjr
Copy link
Contributor

@arendjr arendjr commented Jan 13, 2025

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 :)

@Boshen Boshen self-requested a review January 13, 2025 09:33
@Boshen Boshen self-assigned this Jan 13, 2025
Copy link

codspeed-hq bot commented Jan 13, 2025

CodSpeed Performance Report

Merging #358 will not alter performance

Comparing arendjr:generic-cache (feefbfd) with main (fede8dc)

Summary

✅ 3 untouched benchmarks

@Boshen
Copy link
Member

Boshen commented Jan 13, 2025

I can start integrating with Oxc and Rolldown once test passes.

@arendjr
Copy link
Contributor Author

arendjr commented Jan 13, 2025

What do you think about making PackageJson and TsConfig traits too? I can do it now, so you only need to update once, or we can iterate on it so this PR doesn't become too big.

@arendjr
Copy link
Contributor Author

arendjr commented Jan 15, 2025

Btw, I've come pretty far implementing a cache for Biome based on this PR, but it looks like I do need PackageJson and TsConfig traits now to make meaningful progress. I can do that on a separate PR on top of this one.

@Boshen
Copy link
Member

Boshen commented Jan 15, 2025

A package.json + tsconfig.json trait is inevitable, let's do it!

@Boshen
Copy link
Member

Boshen commented Jan 15, 2025

I've successfully tested this change in oxc and Rolldown, let's merge after CI passes!

@arendjr
Copy link
Contributor Author

arendjr commented Jan 15, 2025

Pushed a fix that I think will turn the Windows build green.

@Boshen Boshen changed the title Make cache generic feat!: generic fs cache type Resolver = ResolverGeneric<FsCache<FileSystemOs>> Jan 16, 2025
@Boshen Boshen merged commit 2bc5173 into oxc-project:main Jan 16, 2025
13 checks passed
@Boshen
Copy link
Member

Boshen commented Jan 16, 2025

Thank you so much for working on this!

@oxc-bot oxc-bot mentioned this pull request Jan 10, 2025
Boshen pushed a commit that referenced this pull request Jan 20, 2025
## 🤖 New release
* `oxc_resolver`: 3.0.3 -> 4.0.0 (⚠️ API breaking changes)

### ⚠️ `oxc_resolver` breaking changes

```
--- failure inherent_method_missing: pub method removed or renamed ---

Description:
A publicly-visible method or associated fn is no longer available under its prior name. It may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.37.0/src/lints/inherent_method_missing.ron

Failed in:
  ResolverGeneric::new_with_file_system, previously in file /tmp/.tmpKVx03E/oxc_resolver/src/lib.rs:138

--- failure struct_missing: pub struct removed or renamed ---

Description:
A publicly-visible struct cannot be imported by its prior path. A `pub use` may have been removed, or the struct itself may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.37.0/src/lints/struct_missing.ron

Failed in:
  struct oxc_resolver::PackageJson, previously in file /tmp/.tmpKVx03E/oxc_resolver/src/package_json.rs:14
```

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

##
[4.0.0](oxc_resolver-v3.0.3...oxc_resolver-v4.0.0)
- 2025-01-20

### <!-- 0 -->Features

- [**breaking**] generic fs cache `type Resolver =
ResolverGeneric<FsCache<FileSystemOs>>` (#358)

### <!-- 2 -->Performance

- use papaya instead of dashmap (#356)
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants