diff --git a/Cargo.lock b/Cargo.lock index 30adfa684067..6ace37198fa6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3535,7 +3535,6 @@ dependencies = [ "rspack_allocator", "rspack_browser", "rspack_browserslist", - "rspack_cacheable", "rspack_collections", "rspack_core", "rspack_error", @@ -3929,7 +3928,6 @@ name = "rspack_loader_preact_refresh" version = "0.5.7" dependencies = [ "async-trait", - "rspack_cacheable", "rspack_core", "rspack_error", "rspack_hook", @@ -3942,7 +3940,6 @@ name = "rspack_loader_react_refresh" version = "0.5.7" dependencies = [ "async-trait", - "rspack_cacheable", "rspack_core", "rspack_error", "rspack_hook", @@ -4006,7 +4003,6 @@ name = "rspack_loader_testing" version = "0.5.7" dependencies = [ "async-trait", - "rspack_cacheable", "rspack_core", "rspack_error", "rspack_loader_runner", diff --git a/crates/rspack_binding_api/Cargo.toml b/crates/rspack_binding_api/Cargo.toml index 2c2e8629e129..2f49e9a6d309 100644 --- a/crates/rspack_binding_api/Cargo.toml +++ b/crates/rspack_binding_api/Cargo.toml @@ -61,7 +61,6 @@ once_cell = { workspace = true } rayon = { workspace = true } regex = { workspace = true } rspack_browser = { workspace = true, optional = true } -rspack_cacheable = { workspace = true } rspack_ids = { workspace = true } rspack_javascript_compiler = { workspace = true } rspack_loader_lightningcss = { workspace = true } diff --git a/crates/rspack_binding_api/src/modules/normal_module.rs b/crates/rspack_binding_api/src/modules/normal_module.rs index b2b839268a0c..ebac5bf40626 100644 --- a/crates/rspack_binding_api/src/modules/normal_module.rs +++ b/crates/rspack_binding_api/src/modules/normal_module.rs @@ -39,16 +39,6 @@ impl NormalModule { ReadonlyResourceDataWrapper::from(resource_resolved_data.clone()), )? }); - let loaders = Object::from_raw(env.raw(), unsafe { - ToNapiValue::to_napi_value( - env.raw(), - module - .loaders() - .iter() - .map(JsLoaderItem::from) - .collect::>(), - )? - }); #[js_function] pub fn match_resource_getter(ctx: CallContext<'_>) -> napi::Result> { @@ -115,11 +105,6 @@ impl NormalModule { .with_utf8_name("resourceResolveData")? .with_value(&resource_resolve_data), ); - properties.push( - napi::Property::new() - .with_utf8_name("loaders")? - .with_value(&loaders), - ); properties.push( napi::Property::new() .with_utf8_name("matchResource")? diff --git a/crates/rspack_binding_api/src/plugins/js_loader/resolver.rs b/crates/rspack_binding_api/src/plugins/js_loader/resolver.rs index 4dd87f7d169b..31410fb6e16d 100644 --- a/crates/rspack_binding_api/src/plugins/js_loader/resolver.rs +++ b/crates/rspack_binding_api/src/plugins/js_loader/resolver.rs @@ -1,9 +1,5 @@ use std::{borrow::Cow, sync::Arc}; -use rspack_cacheable::{ - cacheable, cacheable_dyn, - with::{AsOption, AsRefStr}, -}; use rspack_collections::Identifier; use rspack_core::{ BoxLoader, Context, Loader, ModuleRuleUseLoader, NormalModuleFactoryResolveLoader, ResolveResult, @@ -15,14 +11,12 @@ use rspack_paths::Utf8Path; use super::{JsLoaderRspackPlugin, JsLoaderRspackPluginInner}; -#[cacheable] #[derive(Debug)] pub struct JsLoader( pub Identifier, - /* LoaderType */ #[cacheable(with=AsOption)] pub Option>, + /* LoaderType */ pub Option>, ); -#[cacheable_dyn] impl Loader for JsLoader { fn identifier(&self) -> Identifier { self.0 diff --git a/crates/rspack_core/src/compilation/make/graph_updater/repair/add.rs b/crates/rspack_core/src/compilation/make/graph_updater/repair/add.rs index fc332648fc4d..1ff17e13cb4a 100644 --- a/crates/rspack_core/src/compilation/make/graph_updater/repair/add.rs +++ b/crates/rspack_core/src/compilation/make/graph_updater/repair/add.rs @@ -1,8 +1,9 @@ +use derive_more::Debug; use rspack_error::Result; use super::{TaskContext, build::BuildTask, lazy::ProcessUnlazyDependenciesTask}; use crate::{ - BoxDependency, Module, ModuleIdentifier, ModuleProfile, + BoxDependency, BoxLoader, Module, ModuleIdentifier, ModuleProfile, compilation::make::ForwardedIdSet, module_graph::{ModuleGraph, ModuleGraphModule}, utils::task_loop::{Task, TaskResult, TaskType}, @@ -12,6 +13,8 @@ use crate::{ pub struct AddTask { pub original_module_identifier: Option, pub module: Box, + #[debug(skip)] + pub loaders: Vec, pub module_graph_module: Box, pub dependencies: Vec, pub current_profile: Option, @@ -112,6 +115,7 @@ impl Task for AddTask { compiler_id: context.compiler_id, compilation_id: context.compilation_id, module: self.module, + loaders: self.loaders, current_profile: self.current_profile, resolver_factory: context.resolver_factory.clone(), compiler_options: context.compiler_options.clone(), diff --git a/crates/rspack_core/src/compilation/make/graph_updater/repair/build.rs b/crates/rspack_core/src/compilation/make/graph_updater/repair/build.rs index 6d5d531a9cc2..5158e9f4f4ba 100644 --- a/crates/rspack_core/src/compilation/make/graph_updater/repair/build.rs +++ b/crates/rspack_core/src/compilation/make/graph_updater/repair/build.rs @@ -1,5 +1,6 @@ use std::{collections::VecDeque, sync::Arc}; +use derive_more::Debug; use rspack_fs::ReadableFileSystem; use rustc_hash::FxHashSet; @@ -7,8 +8,9 @@ use super::{ TaskContext, lazy::ProcessUnlazyDependenciesTask, process_dependencies::ProcessDependenciesTask, }; use crate::{ - AsyncDependenciesBlock, BoxDependency, BuildContext, BuildResult, CompilationId, CompilerId, - CompilerOptions, DependencyParents, Module, ModuleProfile, ResolverFactory, SharedPluginDriver, + AsyncDependenciesBlock, BoxDependency, BoxLoader, BuildContext, BuildResult, CompilationId, + CompilerId, CompilerOptions, DependencyParents, Module, ModuleProfile, ResolverFactory, + SharedPluginDriver, compilation::make::{ForwardedIdSet, HasLazyDependencies, LazyDependencies}, utils::{ ResourceId, @@ -21,6 +23,8 @@ pub struct BuildTask { pub compiler_id: CompilerId, pub compilation_id: CompilationId, pub module: Box, + #[debug(skip)] + pub loaders: Vec, pub current_profile: Option, pub resolver_factory: Arc, pub compiler_options: Arc, @@ -43,6 +47,7 @@ impl Task for BuildTask { plugin_driver, mut current_profile, mut module, + loaders, fs, forwarded_ids, } = *self; @@ -65,6 +70,7 @@ impl Task for BuildTask { resolver_factory: resolver_factory.clone(), plugin_driver: plugin_driver.clone(), fs: fs.clone(), + loaders, }, None, ) diff --git a/crates/rspack_core/src/compilation/make/graph_updater/repair/factorize.rs b/crates/rspack_core/src/compilation/make/graph_updater/repair/factorize.rs index fd5bff54df49..d3b36f2331ca 100644 --- a/crates/rspack_core/src/compilation/make/graph_updater/repair/factorize.rs +++ b/crates/rspack_core/src/compilation/make/graph_updater/repair/factorize.rs @@ -229,6 +229,7 @@ impl Task for FactorizeResultTask { Ok(vec![Box::new(AddTask { original_module_identifier, module, + loaders: factory_result.loaders, module_graph_module: Box::new(mgm), dependencies, current_profile, diff --git a/crates/rspack_core/src/context_module_factory.rs b/crates/rspack_core/src/context_module_factory.rs index d734c55338a0..88919ab49cbc 100644 --- a/crates/rspack_core/src/context_module_factory.rs +++ b/crates/rspack_core/src/context_module_factory.rs @@ -340,9 +340,7 @@ impl ContextModuleFactory { data.add_missing_dependencies(missing_dependencies); // data.add_context_dependencies(context_dependencies); - let module_factory_result = ModuleFactoryResult { - module: Some(module), - }; + let module_factory_result = ModuleFactoryResult::new_with_module(module); Ok((module_factory_result, context_module_options)) } diff --git a/crates/rspack_core/src/module.rs b/crates/rspack_core/src/module.rs index 2a17505d1947..f58360491791 100644 --- a/crates/rspack_core/src/module.rs +++ b/crates/rspack_core/src/module.rs @@ -27,9 +27,9 @@ use rustc_hash::{FxHashMap as HashMap, FxHashSet as HashSet}; use serde::Serialize; use crate::{ - AsyncDependenciesBlock, BindingCell, BoxDependency, BoxDependencyTemplate, BoxModuleDependency, - ChunkGraph, ChunkUkey, CodeGenerationResult, CollectedTypeScriptInfo, Compilation, - CompilationAsset, CompilationId, CompilerId, CompilerOptions, ConcatenationScope, + AsyncDependenciesBlock, BindingCell, BoxDependency, BoxDependencyTemplate, BoxLoader, + BoxModuleDependency, ChunkGraph, ChunkUkey, CodeGenerationResult, CollectedTypeScriptInfo, + Compilation, CompilationAsset, CompilationId, CompilerId, CompilerOptions, ConcatenationScope, ConnectionState, Context, ContextModule, DependenciesBlock, DependencyId, ExportProvided, ExternalModule, ModuleGraph, ModuleGraphCacheArtifact, ModuleLayer, ModuleType, NormalModule, PrefetchExportsInfoMode, RawModule, Resolve, ResolverFactory, RuntimeSpec, SelfModule, @@ -45,6 +45,7 @@ pub struct BuildContext { pub resolver_factory: Arc, pub plugin_driver: SharedPluginDriver, pub fs: Arc, + pub loaders: Vec, } #[cacheable] diff --git a/crates/rspack_core/src/module_factory.rs b/crates/rspack_core/src/module_factory.rs index bb8f624938d4..ce10d79a759d 100644 --- a/crates/rspack_core/src/module_factory.rs +++ b/crates/rspack_core/src/module_factory.rs @@ -1,11 +1,12 @@ -use std::{fmt::Debug, sync::Arc}; +use std::sync::Arc; +use derive_more::Debug; use rspack_error::{Diagnostic, Result}; use rspack_paths::{ArcPath, ArcPathSet}; use crate::{ - BoxDependency, BoxModule, CompilationId, CompilerId, CompilerOptions, Context, ModuleIdentifier, - ModuleLayer, Resolve, ResolverFactory, + BoxDependency, BoxLoader, BoxModule, CompilationId, CompilerId, CompilerOptions, Context, + ModuleIdentifier, ModuleLayer, Resolve, ResolverFactory, }; #[derive(Debug, Clone)] @@ -69,22 +70,20 @@ impl ModuleFactoryCreateData { #[derive(Debug, Default)] pub struct ModuleFactoryResult { pub module: Option, + #[debug(skip)] + pub loaders: Vec, } impl ModuleFactoryResult { pub fn new_with_module(module: BoxModule) -> Self { Self { module: Some(module), + loaders: vec![], } } - - pub fn module(mut self, module: Option) -> Self { - self.module = module; - self - } } #[async_trait::async_trait] -pub trait ModuleFactory: Debug + Sync + Send { +pub trait ModuleFactory: std::fmt::Debug + Sync + Send { async fn create(&self, data: &mut ModuleFactoryCreateData) -> Result; } diff --git a/crates/rspack_core/src/normal_module.rs b/crates/rspack_core/src/normal_module.rs index 67d24b4c3904..25356a57afa1 100644 --- a/crates/rspack_core/src/normal_module.rs +++ b/crates/rspack_core/src/normal_module.rs @@ -33,14 +33,14 @@ use serde_json::json; use tracing::{Instrument, info_span}; use crate::{ - AsyncDependenciesBlockIdentifier, BoxDependencyTemplate, BoxLoader, BoxModule, - BoxModuleDependency, BuildContext, BuildInfo, BuildMeta, BuildResult, ChunkGraph, - CodeGenerationResult, Compilation, ConcatenationScope, ConnectionState, Context, - DependenciesBlock, DependencyId, FactoryMeta, GenerateContext, GeneratorOptions, LibIdentOptions, - Module, ModuleGraph, ModuleGraphCacheArtifact, ModuleIdentifier, ModuleLayer, ModuleType, - OutputOptions, ParseContext, ParseResult, ParserAndGenerator, ParserOptions, Resolve, - RspackLoaderRunnerPlugin, RunnerContext, RuntimeGlobals, RuntimeSpec, SourceType, contextify, - diagnostics::ModuleBuildError, get_context, impl_module_meta_info, module_update_hash, + AsyncDependenciesBlockIdentifier, BoxDependencyTemplate, BoxModule, BoxModuleDependency, + BuildContext, BuildInfo, BuildMeta, BuildResult, ChunkGraph, CodeGenerationResult, Compilation, + ConcatenationScope, ConnectionState, Context, DependenciesBlock, DependencyId, FactoryMeta, + GenerateContext, GeneratorOptions, LibIdentOptions, Module, ModuleGraph, + ModuleGraphCacheArtifact, ModuleIdentifier, ModuleLayer, ModuleType, OutputOptions, ParseContext, + ParseResult, ParserAndGenerator, ParserOptions, Resolve, RspackLoaderRunnerPlugin, RunnerContext, + RuntimeGlobals, RuntimeSpec, SourceType, contextify, diagnostics::ModuleBuildError, get_context, + impl_module_meta_info, module_update_hash, }; #[cacheable] @@ -121,8 +121,6 @@ pub struct NormalModule { /// Resource data (path, query, fragment etc.) resource_data: Arc, /// Loaders for the module - #[debug(skip)] - loaders: Vec, /// Built source of this module (passed with loaders) #[cacheable(with=AsOption)] @@ -180,7 +178,6 @@ impl NormalModule { match_resource: Option, resource_data: Arc, resolve_options: Option>, - loaders: Vec, context: Option, ) -> Self { let module_type = module_type.into(); @@ -201,7 +198,6 @@ impl NormalModule { match_resource, resource_data, resolve_options, - loaders, source: None, debug_id: DEBUG_ID.fetch_add(1, Ordering::Relaxed), @@ -249,10 +245,6 @@ impl NormalModule { &self.raw_request } - pub fn loaders(&self) -> &[BoxLoader] { - &self.loaders - } - pub fn parser_and_generator(&self) -> &dyn ParserAndGenerator { &*self.parser_and_generator } @@ -373,7 +365,7 @@ impl Module for NormalModule { perfetto.process_name = format!("Rspack Build Detail"), module.resource = self.resource_resolved_data().resource(), module.identifier = self.identifier().as_str(), - module.loaders = ?self.loaders.iter().map(|l| l.identifier().as_str()).collect::>()) + loaders = ?build_context.loaders.iter().map(|l| l.identifier().as_str()).collect::>()) )] async fn build( &mut self, @@ -402,7 +394,7 @@ impl Module for NormalModule { }); let (mut loader_result, err) = run_loaders( - self.loaders.clone(), + build_context.loaders.clone(), self.resource_data.clone(), Some(plugin.clone()), RunnerContext { @@ -538,7 +530,7 @@ impl Module for NormalModule { module_layer: self.layer.as_ref(), module_user_request: &self.user_request, module_source_map_kind: *self.get_source_map_kind(), - loaders: &self.loaders, + loaders: &build_context.loaders, resource_data: &self.resource_data, compiler_options: &build_context.compiler_options, additional_data: loader_result.additional_data, diff --git a/crates/rspack_core/src/normal_module_factory.rs b/crates/rspack_core/src/normal_module_factory.rs index 4e33fbffdeec..f4f42bd368b5 100644 --- a/crates/rspack_core/src/normal_module_factory.rs +++ b/crates/rspack_core/src/normal_module_factory.rs @@ -571,7 +571,6 @@ impl NormalModuleFactory { match_resource_data, Arc::new(create_data.resource_resolve_data.clone()), resolved_resolve_options, - loaders, create_data.context.clone().map(|x| x.into()), ) .boxed() @@ -587,7 +586,10 @@ impl NormalModuleFactory { data.add_file_dependencies(file_dependencies); data.add_missing_dependencies(missing_dependencies); - Ok(Some(ModuleFactoryResult::new_with_module(module))) + Ok(Some(ModuleFactoryResult { + module: Some(module), + loaders, + })) } async fn calculate_module_rules<'a>( diff --git a/crates/rspack_loader_lightningcss/src/lib.rs b/crates/rspack_loader_lightningcss/src/lib.rs index 9cad808a2433..a0044c58049a 100644 --- a/crates/rspack_loader_lightningcss/src/lib.rs +++ b/crates/rspack_loader_lightningcss/src/lib.rs @@ -12,7 +12,6 @@ use lightningcss::{ targets::{Features, Targets}, traits::IntoOwned, }; -use rspack_cacheable::{cacheable, cacheable_dyn, with::Skip}; use rspack_core::{ Loader, LoaderContext, RunnerContext, rspack_sources::{Mapping, OriginalLocation, SourceMap, encode_mappings}, @@ -30,12 +29,10 @@ pub const LIGHTNINGCSS_LOADER_IDENTIFIER: &str = "builtin:lightningcss-loader"; pub type LightningcssLoaderVisitor = Box)>; -#[cacheable] #[derive(Debug)] pub struct LightningCssLoader { id: Identifier, #[debug(skip)] - #[cacheable(with=Skip)] visitors: Option>>, config: Config, } @@ -258,7 +255,6 @@ impl LightningCssLoader { } } -#[cacheable_dyn] #[async_trait::async_trait] impl Loader for LightningCssLoader { fn identifier(&self) -> rspack_loader_runner::Identifier { diff --git a/crates/rspack_loader_preact_refresh/Cargo.toml b/crates/rspack_loader_preact_refresh/Cargo.toml index 41f67da2df35..9f823db0b293 100644 --- a/crates/rspack_loader_preact_refresh/Cargo.toml +++ b/crates/rspack_loader_preact_refresh/Cargo.toml @@ -9,7 +9,6 @@ version.workspace = true [dependencies] async-trait = { workspace = true } -rspack_cacheable = { workspace = true } rspack_core = { workspace = true } rspack_error = { workspace = true } rspack_hook = { workspace = true } diff --git a/crates/rspack_loader_preact_refresh/src/lib.rs b/crates/rspack_loader_preact_refresh/src/lib.rs index 0777c3cd128a..263ae3ab2296 100644 --- a/crates/rspack_loader_preact_refresh/src/lib.rs +++ b/crates/rspack_loader_preact_refresh/src/lib.rs @@ -1,12 +1,10 @@ mod plugin; pub use plugin::PreactRefreshLoaderPlugin; -use rspack_cacheable::{cacheable, cacheable_dyn}; use rspack_core::RunnerContext; use rspack_error::Result; use rspack_loader_runner::{Identifier, Loader, LoaderContext}; -#[cacheable] pub struct PreactRefreshLoader { identifier: Identifier, } @@ -29,7 +27,6 @@ impl PreactRefreshLoader { } } -#[cacheable_dyn] #[async_trait::async_trait] impl Loader for PreactRefreshLoader { fn identifier(&self) -> Identifier { diff --git a/crates/rspack_loader_react_refresh/Cargo.toml b/crates/rspack_loader_react_refresh/Cargo.toml index 33fe9b931663..87b755bbeb8e 100644 --- a/crates/rspack_loader_react_refresh/Cargo.toml +++ b/crates/rspack_loader_react_refresh/Cargo.toml @@ -9,7 +9,6 @@ version.workspace = true [dependencies] async-trait = { workspace = true } -rspack_cacheable = { workspace = true } rspack_core = { workspace = true } rspack_error = { workspace = true } rspack_hook = { workspace = true } diff --git a/crates/rspack_loader_react_refresh/src/lib.rs b/crates/rspack_loader_react_refresh/src/lib.rs index 4eedf277ac50..67d45854488d 100644 --- a/crates/rspack_loader_react_refresh/src/lib.rs +++ b/crates/rspack_loader_react_refresh/src/lib.rs @@ -1,12 +1,10 @@ mod plugin; pub use plugin::ReactRefreshLoaderPlugin; -use rspack_cacheable::{cacheable, cacheable_dyn}; use rspack_core::RunnerContext; use rspack_error::Result; use rspack_loader_runner::{Identifier, Loader, LoaderContext}; -#[cacheable] pub struct ReactRefreshLoader { identifier: Identifier, } @@ -29,7 +27,6 @@ impl ReactRefreshLoader { } } -#[cacheable_dyn] #[async_trait::async_trait] impl Loader for ReactRefreshLoader { fn identifier(&self) -> Identifier { diff --git a/crates/rspack_loader_runner/src/loader.rs b/crates/rspack_loader_runner/src/loader.rs index b87d8691b077..82de12407b7c 100644 --- a/crates/rspack_loader_runner/src/loader.rs +++ b/crates/rspack_loader_runner/src/loader.rs @@ -9,7 +9,6 @@ use std::{ use async_trait::async_trait; use derive_more::Debug; -use rspack_cacheable::cacheable_dyn; use rspack_collections::Identifier; use rspack_error::Result; use rspack_paths::{Utf8Path, Utf8PathBuf}; @@ -175,7 +174,6 @@ impl Display for LoaderItemList<'_, Context> { } } -#[cacheable_dyn] #[async_trait] pub trait Loader: Send + Sync where @@ -293,15 +291,12 @@ fn path_query_fragment(mut input: &str) -> winnow::ModalResult<(&str, Option<&st pub(crate) mod test { use std::{path::PathBuf, sync::Arc}; - use rspack_cacheable::{cacheable, cacheable_dyn}; use rspack_collections::Identifier; use super::{Loader, LoaderItem}; - #[cacheable] #[allow(dead_code)] pub(crate) struct Custom; - #[cacheable_dyn] #[async_trait::async_trait] impl Loader<()> for Custom { fn identifier(&self) -> Identifier { @@ -309,10 +304,8 @@ pub(crate) mod test { } } - #[cacheable] #[allow(dead_code)] pub(crate) struct Custom2; - #[cacheable_dyn] #[async_trait::async_trait] impl Loader<()> for Custom2 { fn identifier(&self) -> Identifier { @@ -320,10 +313,8 @@ pub(crate) mod test { } } - #[cacheable] #[allow(dead_code)] pub(crate) struct Builtin; - #[cacheable_dyn] #[async_trait::async_trait] impl Loader<()> for Builtin { fn identifier(&self) -> Identifier { @@ -331,10 +322,7 @@ pub(crate) mod test { } } - #[cacheable] pub(crate) struct PosixNonLenBlankUnicode; - - #[cacheable_dyn] #[async_trait::async_trait] impl Loader<()> for PosixNonLenBlankUnicode { fn identifier(&self) -> Identifier { @@ -342,9 +330,7 @@ pub(crate) mod test { } } - #[cacheable] pub(crate) struct WinNonLenBlankUnicode; - #[cacheable_dyn] #[async_trait::async_trait] impl Loader<()> for WinNonLenBlankUnicode { fn identifier(&self) -> Identifier { diff --git a/crates/rspack_loader_runner/src/runner.rs b/crates/rspack_loader_runner/src/runner.rs index 41a5590d9b12..50d2746d9647 100644 --- a/crates/rspack_loader_runner/src/runner.rs +++ b/crates/rspack_loader_runner/src/runner.rs @@ -256,7 +256,6 @@ impl LoaderResult { mod test { use std::{cell::RefCell, sync::Arc}; - use rspack_cacheable::{cacheable, cacheable_dyn}; use rspack_collections::Identifier; use rspack_error::Result; use rspack_fs::NativeFileSystem; @@ -289,10 +288,7 @@ mod test { static IDENTS: RefCell> = RefCell::default(); } - #[cacheable] struct Pitching; - - #[cacheable_dyn] #[async_trait::async_trait] impl Loader<()> for Pitching { fn identifier(&self) -> Identifier { @@ -305,10 +301,7 @@ mod test { } } - #[cacheable] struct Pitching2; - - #[cacheable_dyn] #[async_trait::async_trait] impl Loader<()> for Pitching2 { fn identifier(&self) -> Identifier { @@ -321,10 +314,7 @@ mod test { } } - #[cacheable] struct Normal; - - #[cacheable_dyn] #[async_trait::async_trait] impl Loader<()> for Normal { fn identifier(&self) -> Identifier { @@ -337,10 +327,7 @@ mod test { } } - #[cacheable] struct Normal2; - - #[cacheable_dyn] #[async_trait::async_trait] impl Loader<()> for Normal2 { fn identifier(&self) -> Identifier { @@ -353,10 +340,7 @@ mod test { } } - #[cacheable] struct PitchNormalBase; - - #[cacheable_dyn] #[async_trait::async_trait] impl Loader<()> for PitchNormalBase { fn identifier(&self) -> Identifier { @@ -374,10 +358,7 @@ mod test { } } - #[cacheable] struct PitchNormal; - - #[cacheable_dyn] #[async_trait::async_trait] impl Loader<()> for PitchNormal { fn identifier(&self) -> Identifier { @@ -396,10 +377,7 @@ mod test { } } - #[cacheable] struct PitchNormal2; - - #[cacheable_dyn] #[async_trait::async_trait] impl Loader<()> for PitchNormal2 { fn identifier(&self) -> Identifier { @@ -476,10 +454,7 @@ mod test { #[tokio::test] async fn should_able_to_consume_additional_data() { - #[cacheable] struct Normal; - - #[cacheable_dyn] #[async_trait::async_trait] impl Loader<()> for Normal { fn identifier(&self) -> Identifier { @@ -499,10 +474,7 @@ mod test { } } - #[cacheable] struct Normal2; - - #[cacheable_dyn] #[async_trait::async_trait] impl Loader<()> for Normal2 { fn identifier(&self) -> Identifier { @@ -537,10 +509,7 @@ mod test { #[tokio::test] async fn should_override_data_if_finish_with_is_not_called() { - #[cacheable] struct Normal; - - #[cacheable_dyn] #[async_trait::async_trait] impl Loader<()> for Normal { fn identifier(&self) -> Identifier { @@ -558,10 +527,7 @@ mod test { "/rspack/main.js?abc=123#efg".to_owned(), )); - #[cacheable] struct Normal2; - - #[cacheable_dyn] #[async_trait::async_trait] impl Loader<()> for Normal2 { fn identifier(&self) -> Identifier { diff --git a/crates/rspack_loader_swc/src/lib.rs b/crates/rspack_loader_swc/src/lib.rs index 0dfcceec6510..63ba7dae6a94 100644 --- a/crates/rspack_loader_swc/src/lib.rs +++ b/crates/rspack_loader_swc/src/lib.rs @@ -8,7 +8,6 @@ use std::{default::Default, path::Path}; use options::SwcCompilerOptionsWithAdditional; pub use options::SwcLoaderJsOptions; pub use plugin::SwcLoaderPlugin; -use rspack_cacheable::{cacheable, cacheable_dyn}; use rspack_core::{COLLECTED_TYPESCRIPT_INFO_PARSE_META_KEY, Mode, RunnerContext}; use rspack_error::{Diagnostic, Error, Result}; use rspack_javascript_compiler::{JavaScriptCompiler, TransformOutput}; @@ -23,7 +22,6 @@ use swc_core::{ use crate::collect_ts_info::collect_typescript_info; -#[cacheable] #[derive(Debug)] pub struct SwcLoader { identifier: Identifier, @@ -175,7 +173,6 @@ impl SwcLoader { pub const SWC_LOADER_IDENTIFIER: &str = "builtin:swc-loader"; -#[cacheable_dyn] #[async_trait::async_trait] impl Loader for SwcLoader { fn identifier(&self) -> Identifier { diff --git a/crates/rspack_loader_testing/Cargo.toml b/crates/rspack_loader_testing/Cargo.toml index 2a9d31406574..2b40ef2f2339 100644 --- a/crates/rspack_loader_testing/Cargo.toml +++ b/crates/rspack_loader_testing/Cargo.toml @@ -14,7 +14,6 @@ version.workspace = true [dependencies] async-trait = { workspace = true } -rspack_cacheable = { workspace = true } rspack_core = { workspace = true } rspack_error = { workspace = true } rspack_loader_runner = { workspace = true } diff --git a/crates/rspack_loader_testing/src/lib.rs b/crates/rspack_loader_testing/src/lib.rs index 6107ed437465..e924534ff735 100644 --- a/crates/rspack_loader_testing/src/lib.rs +++ b/crates/rspack_loader_testing/src/lib.rs @@ -1,13 +1,10 @@ use async_trait::async_trait; -use rspack_cacheable::{cacheable, cacheable_dyn}; use rspack_core::{Loader, LoaderContext, RunnerContext}; use rspack_error::Result; use rspack_loader_runner::{DisplayWithSuffix, Identifier}; use serde_json::json; -#[cacheable] pub struct SimpleLoader; -#[cacheable_dyn] #[async_trait] impl Loader for SimpleLoader { fn identifier(&self) -> Identifier { @@ -25,9 +22,7 @@ impl Loader for SimpleLoader { } pub const SIMPLE_LOADER_IDENTIFIER: &str = "builtin:test-simple-loader"; -#[cacheable] pub struct SimpleAsyncLoader; -#[cacheable_dyn] #[async_trait] impl Loader for SimpleAsyncLoader { fn identifier(&self) -> Identifier { @@ -44,9 +39,7 @@ impl Loader for SimpleAsyncLoader { } pub const SIMPLE_ASYNC_LOADER_IDENTIFIER: &str = "builtin:test-simple-async-loader"; -#[cacheable] pub struct PitchingLoader; -#[cacheable_dyn] #[async_trait] impl Loader for PitchingLoader { fn identifier(&self) -> Identifier { @@ -68,9 +61,7 @@ impl Loader for PitchingLoader { } pub const PITCHING_LOADER_IDENTIFIER: &str = "builtin:test-pitching-loader"; -#[cacheable] pub struct PassthroughLoader; -#[cacheable_dyn] #[async_trait] impl Loader for PassthroughLoader { fn identifier(&self) -> Identifier { @@ -85,9 +76,7 @@ impl Loader for PassthroughLoader { } pub const PASS_THROUGH_LOADER_IDENTIFIER: &str = "builtin:test-passthrough-loader"; -#[cacheable] pub struct NoPassthroughLoader; -#[cacheable_dyn] #[async_trait] impl Loader for NoPassthroughLoader { fn identifier(&self) -> Identifier { diff --git a/crates/rspack_plugin_dll/src/dll_entry/dll_module_factory.rs b/crates/rspack_plugin_dll/src/dll_entry/dll_module_factory.rs index 57481504334d..0b6d0d235ead 100644 --- a/crates/rspack_plugin_dll/src/dll_entry/dll_module_factory.rs +++ b/crates/rspack_plugin_dll/src/dll_entry/dll_module_factory.rs @@ -15,8 +15,8 @@ impl ModuleFactory for DllModuleFactory { .downcast_ref::() .expect("unreachable"); - Ok(ModuleFactoryResult { - module: Some(Box::new(DllModule::new(dll_entry_dependency))), - }) + Ok(ModuleFactoryResult::new_with_module(Box::new( + DllModule::new(dll_entry_dependency), + ))) } } diff --git a/crates/rspack_plugin_javascript/src/plugin/module_concatenation_plugin.rs b/crates/rspack_plugin_javascript/src/plugin/module_concatenation_plugin.rs index 322240c4193b..f78363497366 100644 --- a/crates/rspack_plugin_javascript/src/plugin/module_concatenation_plugin.rs +++ b/crates/rspack_plugin_javascript/src/plugin/module_concatenation_plugin.rs @@ -735,6 +735,7 @@ impl ModuleConcatenationPlugin { plugin_driver: compilation.plugin_driver.clone(), compiler_options: compilation.options.clone(), fs: compilation.input_filesystem.clone(), + loaders: vec![], }, Some(compilation), ) @@ -1503,6 +1504,7 @@ async fn create_concatenated_module( plugin_driver: compilation.plugin_driver.clone(), compiler_options: compilation.options.clone(), fs: compilation.input_filesystem.clone(), + loaders: vec![], }, Some(compilation), )