Skip to content

Commit 018a357

Browse files
authored
feat: expose PnpFileSystem (#43)
1 parent c970407 commit 018a357

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

src/file_system.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,15 @@ impl Default for FileSystemOptions {
115115
}
116116
}
117117

118-
pub struct VirtualFileSystem<T> {
118+
pub struct PnpFileSystem<T> {
119119
options: FileSystemOptions,
120120
internal_fs: T,
121121

122122
#[cfg(feature = "yarn_pnp")]
123123
pnp_lru: LruZipCache<Vec<u8>>,
124124
}
125125

126-
impl<T> VirtualFileSystem<T> {
126+
impl<T> PnpFileSystem<T> {
127127
pub fn new_with_options(internal_fs: T, options: FileSystemOptions) -> Self {
128128
Self {
129129
options,
@@ -134,7 +134,7 @@ impl<T> VirtualFileSystem<T> {
134134
}
135135
}
136136

137-
impl<T: FileSystem> FileSystem for VirtualFileSystem<T> {
137+
impl<T: FileSystem> FileSystem for PnpFileSystem<T> {
138138
fn read(&self, path: &Path) -> io::Result<Vec<u8>> {
139139
cfg_if! {
140140
if #[cfg(feature = "yarn_pnp")] {

src/lib.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,14 @@ use std::{
7272
};
7373

7474
use dashmap::{mapref::one::Ref, DashMap};
75-
use file_system::{FileSystemOptions, VirtualFileSystem};
75+
use file_system::FileSystemOptions;
7676
use rustc_hash::FxHashSet;
7777
use serde_json::Value as JSONValue;
7878

7979
pub use crate::{
8080
builtins::NODEJS_BUILTINS,
8181
error::{JSONError, ResolveError, SpecifierError},
82-
file_system::{FileMetadata, FileSystem, FileSystemOs},
82+
file_system::{FileMetadata, FileSystem, FileSystemOs, PnpFileSystem},
8383
options::{
8484
Alias, AliasValue, EnforceExtension, ResolveOptions, Restriction, TsconfigOptions,
8585
TsconfigReferences,
@@ -115,7 +115,7 @@ pub type Resolver = ResolverGeneric<FileSystemOs>;
115115
/// Generic implementation of the resolver, can be configured by the [FileSystem] trait
116116
pub struct ResolverGeneric<Fs> {
117117
options: ResolveOptions,
118-
cache: Arc<Cache<VirtualFileSystem<Fs>>>,
118+
cache: Arc<Cache<PnpFileSystem<Fs>>>,
119119
#[cfg(feature = "yarn_pnp")]
120120
pnp_cache: Arc<DashMap<CachedPath, Option<pnp::Manifest>>>,
121121
}
@@ -138,10 +138,7 @@ impl<Fs: FileSystem + Default> ResolverGeneric<Fs> {
138138

139139
Self {
140140
options: options.sanitize(),
141-
cache: Arc::new(Cache::new(VirtualFileSystem::new_with_options(
142-
Fs::default(),
143-
fs_options,
144-
))),
141+
cache: Arc::new(Cache::new(PnpFileSystem::new_with_options(Fs::default(), fs_options))),
145142
#[cfg(feature = "yarn_pnp")]
146143
pnp_cache: Arc::new(DashMap::default()),
147144
}
@@ -154,10 +151,7 @@ impl<Fs: FileSystem> ResolverGeneric<Fs> {
154151

155152
Self {
156153
options: options.sanitize(),
157-
cache: Arc::new(Cache::new(VirtualFileSystem::new_with_options(
158-
file_system,
159-
fs_options,
160-
))),
154+
cache: Arc::new(Cache::new(PnpFileSystem::new_with_options(file_system, fs_options))),
161155
#[cfg(feature = "yarn_pnp")]
162156
pnp_cache: Arc::new(DashMap::default()),
163157
}

0 commit comments

Comments
 (0)