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

refactor: rename FileSystem to SyncFileSystem #8520

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 53 additions & 53 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions crates/node_binding/src/resolver_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::sync::Arc;

use napi_derive::napi;
use rspack_core::{Resolve, ResolverFactory};
use rspack_fs::{NativeFileSystem, ReadableFileSystem};
use rspack_fs::{NativeFileSystem, SyncReadableFileSystem};

use crate::{
raw_resolve::{
Expand All @@ -15,7 +15,7 @@ use crate::{
pub struct JsResolverFactory {
pub(crate) resolver_factory: Option<Arc<ResolverFactory>>,
pub(crate) loader_resolver_factory: Option<Arc<ResolverFactory>>,
pub(crate) input_filesystem: Arc<dyn ReadableFileSystem>,
pub(crate) input_filesystem: Arc<dyn SyncReadableFileSystem>,
}

#[napi]
Expand Down
4 changes: 2 additions & 2 deletions crates/rspack_core/src/cache/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pub mod persistent;

use std::{fmt::Debug, sync::Arc};

use rspack_fs::ReadableFileSystem;
use rspack_fs::SyncReadableFileSystem;

use self::{disable::DisableCache, memory::MemoryCache, persistent::PersistentCache};
use crate::{Compilation, CompilerOptions, ExperimentCacheOptions};
Expand All @@ -28,7 +28,7 @@ pub trait Cache: Debug + Send + Sync {

pub fn new_cache(
compiler_option: Arc<CompilerOptions>,
fs: Arc<dyn ReadableFileSystem>,
fs: Arc<dyn SyncReadableFileSystem>,
) -> Arc<dyn Cache> {
match &compiler_option.experiments.cache {
ExperimentCacheOptions::Disabled => Arc::new(DisableCache),
Expand Down
4 changes: 2 additions & 2 deletions crates/rspack_core/src/cache/persistent/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pub mod storage;

use std::sync::Arc;

use rspack_fs::ReadableFileSystem;
use rspack_fs::SyncReadableFileSystem;
use rspack_paths::{AssertUtf8, Utf8PathBuf};
use rustc_hash::FxHashSet as HashSet;

Expand All @@ -28,7 +28,7 @@ pub struct PersistentCache {
}

impl PersistentCache {
pub fn new(option: &PersistentCacheOptions, fs: Arc<dyn ReadableFileSystem>) -> Self {
pub fn new(option: &PersistentCacheOptions, fs: Arc<dyn SyncReadableFileSystem>) -> Self {
let storage = Arc::new(MemoryStorage::default());
Self {
snapshot: Snapshot::new(option.snapshot.clone(), fs, storage.clone()),
Expand Down
8 changes: 4 additions & 4 deletions crates/rspack_core/src/cache/persistent/snapshot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ mod strategy;
use std::sync::Arc;

use rspack_cacheable::{from_bytes, to_bytes};
use rspack_fs::ReadableFileSystem;
use rspack_fs::SyncReadableFileSystem;
use rspack_paths::Utf8PathBuf;
use rustc_hash::FxHashSet as HashSet;

Expand All @@ -25,14 +25,14 @@ pub struct Snapshot {
// 1. update compiler.input_file_system to async file system
// 2. update this fs to AsyncReadableFileSystem
// 3. update add/calc_modified_files to async fn
fs: Arc<dyn ReadableFileSystem>,
fs: Arc<dyn SyncReadableFileSystem>,
storage: Arc<dyn Storage>,
}

impl Snapshot {
pub fn new(
options: SnapshotOptions,
fs: Arc<dyn ReadableFileSystem>,
fs: Arc<dyn SyncReadableFileSystem>,
storage: Arc<dyn Storage>,
) -> Self {
Self {
Expand Down Expand Up @@ -107,7 +107,7 @@ impl Snapshot {
mod tests {
use std::sync::Arc;

use rspack_fs::{MemoryFileSystem, WritableFileSystem};
use rspack_fs::{MemoryFileSystem, SyncWritableFileSystem};
use rspack_paths::Utf8PathBuf;

use super::super::MemoryStorage;
Expand Down
8 changes: 4 additions & 4 deletions crates/rspack_core/src/cache/persistent/snapshot/strategy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::{
};

use rspack_cacheable::cacheable;
use rspack_fs::ReadableFileSystem;
use rspack_fs::SyncReadableFileSystem;
use rspack_paths::Utf8PathBuf;
use rustc_hash::FxHashMap as HashMap;

Expand Down Expand Up @@ -36,12 +36,12 @@ pub enum ValidateResult {
}

pub struct StrategyHelper {
fs: Arc<dyn ReadableFileSystem>,
fs: Arc<dyn SyncReadableFileSystem>,
package_version_cache: HashMap<Utf8PathBuf, Option<String>>,
}

impl StrategyHelper {
pub fn new(fs: Arc<dyn ReadableFileSystem>) -> Self {
pub fn new(fs: Arc<dyn SyncReadableFileSystem>) -> Self {
Self {
fs,
package_version_cache: Default::default(),
Expand Down Expand Up @@ -132,7 +132,7 @@ impl StrategyHelper {
mod tests {
use std::sync::Arc;

use rspack_fs::{MemoryFileSystem, ReadableFileSystem, WritableFileSystem};
use rspack_fs::{MemoryFileSystem, SyncReadableFileSystem, SyncWritableFileSystem};

use super::{Strategy, StrategyHelper, ValidateResult};

Expand Down
6 changes: 3 additions & 3 deletions crates/rspack_core/src/compiler/compilation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use rspack_collections::{
DatabaseItem, Identifiable, IdentifierDashMap, IdentifierMap, IdentifierSet, UkeyMap, UkeySet,
};
use rspack_error::{error, miette::diagnostic, Diagnostic, DiagnosticExt, Result, Severity};
use rspack_fs::ReadableFileSystem;
use rspack_fs::SyncReadableFileSystem;
use rspack_futures::FuturesResults;
use rspack_hash::{RspackHash, RspackHashDigest};
use rspack_hook::define_hook;
Expand Down Expand Up @@ -201,7 +201,7 @@ pub struct Compilation {
pub modified_files: HashSet<PathBuf>,
pub removed_files: HashSet<PathBuf>,
make_artifact: MakeArtifact,
pub input_filesystem: Arc<dyn ReadableFileSystem>,
pub input_filesystem: Arc<dyn SyncReadableFileSystem>,
}

impl Compilation {
Expand Down Expand Up @@ -238,7 +238,7 @@ impl Compilation {
module_executor: Option<ModuleExecutor>,
modified_files: HashSet<PathBuf>,
removed_files: HashSet<PathBuf>,
input_filesystem: Arc<dyn ReadableFileSystem>,
input_filesystem: Arc<dyn SyncReadableFileSystem>,
) -> Self {
let incremental = Incremental::new(options.experiments.incremental);
Self {
Expand Down
4 changes: 2 additions & 2 deletions crates/rspack_core/src/compiler/make/repair/build.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{collections::VecDeque, sync::Arc};

use rspack_error::{Diagnostic, IntoTWithDiagnosticArray};
use rspack_fs::ReadableFileSystem;
use rspack_fs::SyncReadableFileSystem;

use super::{process_dependencies::ProcessDependenciesTask, MakeTaskContext};
use crate::{
Expand All @@ -18,7 +18,7 @@ pub struct BuildTask {
pub resolver_factory: Arc<ResolverFactory>,
pub compiler_options: Arc<CompilerOptions>,
pub plugin_driver: SharedPluginDriver,
pub fs: Arc<dyn ReadableFileSystem>,
pub fs: Arc<dyn SyncReadableFileSystem>,
}

#[async_trait::async_trait]
Expand Down
4 changes: 2 additions & 2 deletions crates/rspack_core/src/compiler/make/repair/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ pub mod process_dependencies;
use std::sync::Arc;

use rspack_error::Result;
use rspack_fs::ReadableFileSystem;
use rspack_fs::SyncReadableFileSystem;
use rustc_hash::{FxHashMap as HashMap, FxHashSet as HashSet};

use super::MakeArtifact;
Expand All @@ -24,7 +24,7 @@ pub struct MakeTaskContext {
pub compilation_id: CompilationId,
pub plugin_driver: SharedPluginDriver,
pub buildtime_plugin_driver: SharedPluginDriver,
pub fs: Arc<dyn ReadableFileSystem>,
pub fs: Arc<dyn SyncReadableFileSystem>,
pub compiler_options: Arc<CompilerOptions>,
pub resolver_factory: Arc<ResolverFactory>,
pub loader_resolver_factory: Arc<ResolverFactory>,
Expand Down
6 changes: 3 additions & 3 deletions crates/rspack_core/src/compiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ mod module_executor;
use std::sync::Arc;

use rspack_error::Result;
use rspack_fs::{AsyncWritableFileSystem, NativeFileSystem, ReadableFileSystem};
use rspack_fs::{AsyncWritableFileSystem, NativeFileSystem, SyncReadableFileSystem};
use rspack_futures::FuturesResults;
use rspack_hook::define_hook;
use rspack_paths::{Utf8Path, Utf8PathBuf};
Expand Down Expand Up @@ -54,7 +54,7 @@ pub struct CompilerHooks {
pub struct Compiler {
pub options: Arc<CompilerOptions>,
pub output_filesystem: Box<dyn AsyncWritableFileSystem + Send + Sync>,
pub input_filesystem: Arc<dyn ReadableFileSystem>,
pub input_filesystem: Arc<dyn SyncReadableFileSystem>,
pub compilation: Compilation,
pub plugin_driver: SharedPluginDriver,
pub buildtime_plugin_driver: SharedPluginDriver,
Expand All @@ -75,7 +75,7 @@ impl Compiler {
buildtime_plugins: Vec<BoxPlugin>,
output_filesystem: Option<Box<dyn AsyncWritableFileSystem + Send + Sync>>,
// only supports passing input_filesystem in rust api, no support for js api
input_filesystem: Option<Arc<dyn ReadableFileSystem + Send + Sync>>,
input_filesystem: Option<Arc<dyn SyncReadableFileSystem + Send + Sync>>,
// no need to pass resolve_factory in rust api
resolver_factory: Option<Arc<ResolverFactory>>,
loader_resolver_factory: Option<Arc<ResolverFactory>>,
Expand Down
4 changes: 2 additions & 2 deletions crates/rspack_core/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use async_trait::async_trait;
use json::JsonValue;
use rspack_collections::{Identifiable, Identifier, IdentifierSet};
use rspack_error::{Diagnosable, Diagnostic, Result};
use rspack_fs::ReadableFileSystem;
use rspack_fs::SyncReadableFileSystem;
use rspack_hash::RspackHashDigest;
use rspack_sources::Source;
use rspack_util::atom::Atom;
Expand All @@ -32,7 +32,7 @@ pub struct BuildContext {
pub compiler_options: Arc<CompilerOptions>,
pub resolver_factory: Arc<ResolverFactory>,
pub plugin_driver: SharedPluginDriver,
pub fs: Arc<dyn ReadableFileSystem>,
pub fs: Arc<dyn SyncReadableFileSystem>,
}

#[derive(Debug, Clone, Hash, PartialEq, Eq)]
Expand Down
6 changes: 3 additions & 3 deletions crates/rspack_core/src/resolver/boxfs.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use std::{io, sync::Arc};

use rspack_fs::{Error, ReadableFileSystem};
use rspack_fs::{Error, SyncReadableFileSystem};
use rspack_paths::AssertUtf8;
use rspack_resolver::{FileMetadata, FileSystem as ResolverFileSystem};

#[derive(Clone)]
pub struct BoxFS(Arc<dyn ReadableFileSystem>);
pub struct BoxFS(Arc<dyn SyncReadableFileSystem>);

impl BoxFS {
pub fn new(fs: Arc<dyn ReadableFileSystem>) -> Self {
pub fn new(fs: Arc<dyn SyncReadableFileSystem>) -> Self {
Self(fs)
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/rspack_core/src/resolver/factory.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{hash::BuildHasherDefault, sync::Arc};

use dashmap::DashMap;
use rspack_fs::ReadableFileSystem;
use rspack_fs::SyncReadableFileSystem;
use rustc_hash::FxHasher;

use super::resolver_impl::Resolver;
Expand Down Expand Up @@ -29,7 +29,7 @@ impl ResolverFactory {
self.resolver.clear_cache();
}

pub fn new(options: Resolve, fs: Arc<dyn ReadableFileSystem>) -> Self {
pub fn new(options: Resolve, fs: Arc<dyn SyncReadableFileSystem>) -> Self {
Self {
base_options: options.clone(),
resolver: Resolver::new(options, fs),
Expand Down
6 changes: 3 additions & 3 deletions crates/rspack_core/src/resolver/resolver_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use rspack_error::{
miette::{diagnostic, Diagnostic},
DiagnosticExt, Severity, TraceableError,
};
use rspack_fs::ReadableFileSystem;
use rspack_fs::SyncReadableFileSystem;
use rspack_loader_runner::DescriptionData;
use rspack_paths::AssertUtf8;
use rustc_hash::FxHashSet as HashSet;
Expand Down Expand Up @@ -83,11 +83,11 @@ pub struct Resolver {
}

impl Resolver {
pub fn new(options: Resolve, fs: Arc<dyn ReadableFileSystem>) -> Self {
pub fn new(options: Resolve, fs: Arc<dyn SyncReadableFileSystem>) -> Self {
Self::new_rspack_resolver(options, fs)
}

fn new_rspack_resolver(options: Resolve, fs: Arc<dyn ReadableFileSystem>) -> Self {
fn new_rspack_resolver(options: Resolve, fs: Arc<dyn SyncReadableFileSystem>) -> Self {
let options = to_rspack_resolver_options(options, false, DependencyCategory::Unknown);
let boxfs = BoxFS::new(fs);
let resolver = rspack_resolver::ResolverGeneric::new_with_file_system(boxfs, options);
Expand Down
2 changes: 1 addition & 1 deletion crates/rspack_fs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ mod r#async;
pub use r#async::{AsyncFileSystem, AsyncReadableFileSystem, AsyncWritableFileSystem};

mod sync;
pub use sync::{FileSystem, ReadableFileSystem, WritableFileSystem};
pub use sync::{SyncFileSystem, SyncReadableFileSystem, SyncWritableFileSystem};

mod file_metadata;
pub use file_metadata::FileMetadata;
Expand Down
Loading
Loading