@@ -7,15 +7,8 @@ use futures::future::BoxFuture;
77use indoc:: formatdoc;
88use itertools:: Itertools ;
99use rspack_cacheable:: {
10- __private:: rkyv:: {
11- Place ,
12- de:: Pooling ,
13- rancor:: Fallible ,
14- ser:: Sharing ,
15- with:: { ArchiveWith , DeserializeWith , SerializeWith } ,
16- } ,
17- ContextGuard , Error as CacheableError , cacheable, cacheable_dyn,
18- with:: { AsCacheable , AsOption , AsPreset , AsVec } ,
10+ cacheable, cacheable_dyn,
11+ with:: { AsCacheable , AsOption , AsPreset , AsVec , Unsupported } ,
1912} ;
2013use rspack_collections:: { Identifiable , Identifier } ;
2114use rspack_error:: { Result , impl_empty_diagnosable_trait} ;
@@ -41,9 +34,8 @@ use crate::{
4134 LibIdentOptions , Module , ModuleArgument , ModuleCodeGenerationContext , ModuleCodeTemplate ,
4235 ModuleGraph , ModuleId , ModuleIdsArtifact , ModuleLayer , ModuleType , NeedBuildContext ,
4336 RealDependencyLocation , ReferencedSpecifier , Resolve , RuntimeGlobals , RuntimeGlobalsRenderMode ,
44- RuntimeSpec , SnapshotValidationResult , SourceType , cache:: CacheCodecContext , contextify,
45- get_exports_type_with_strict, get_outgoing_async_modules, impl_module_meta_info,
46- module_update_hash, property_access, to_path,
37+ RuntimeSpec , SnapshotValidationResult , SourceType , contextify, get_exports_type_with_strict,
38+ get_outgoing_async_modules, impl_module_meta_info, module_update_hash, property_access, to_path,
4739} ;
4840
4941static CHUNK_NAME_INDEX_PLACEHOLDER : & str = "[index]" ;
@@ -282,65 +274,6 @@ pub type ResolveContextModuleDependencies = Arc<
282274 + Sync ,
283275> ;
284276
285- /// Context dependency resolution is factory state and is restored from the
286- /// fresh module by `update_cache_module`, just like webpack's
287- /// `ContextModule.resolveDependencies`.
288- struct SkipResolveContextModuleDependencies ;
289-
290- impl ArchiveWith < ResolveContextModuleDependencies > for SkipResolveContextModuleDependencies {
291- type Archived = ( ) ;
292- type Resolver = ( ) ;
293-
294- fn resolve_with (
295- _field : & ResolveContextModuleDependencies ,
296- _resolver : Self :: Resolver ,
297- _out : Place < Self :: Archived > ,
298- ) {
299- }
300- }
301-
302- impl < S > SerializeWith < ResolveContextModuleDependencies , S > for SkipResolveContextModuleDependencies
303- where
304- S : Fallible < Error = CacheableError > + Sharing + ?Sized ,
305- {
306- fn serialize_with (
307- _field : & ResolveContextModuleDependencies ,
308- serializer : & mut S ,
309- ) -> std:: result:: Result < Self :: Resolver , CacheableError > {
310- let context =
311- ContextGuard :: sharing_guard ( serializer) ?. downcast_context :: < CacheCodecContext > ( ) ?;
312- if context. omit_module_factory_state ( ) {
313- Ok ( ( ) )
314- } else {
315- Err ( CacheableError :: UnsupportedField )
316- }
317- }
318- }
319-
320- impl < D > DeserializeWith < ( ) , ResolveContextModuleDependencies , D >
321- for SkipResolveContextModuleDependencies
322- where
323- D : Fallible < Error = CacheableError > + Pooling + ?Sized ,
324- {
325- fn deserialize_with (
326- _field : & ( ) ,
327- deserializer : & mut D ,
328- ) -> std:: result:: Result < ResolveContextModuleDependencies , CacheableError > {
329- let context =
330- ContextGuard :: pooling_guard ( deserializer) ?. downcast_context :: < CacheCodecContext > ( ) ?;
331- if !context. omit_module_factory_state ( ) {
332- return Err ( CacheableError :: UnsupportedField ) ;
333- }
334- Ok ( Arc :: new ( |_| {
335- Box :: pin ( async {
336- Err ( rspack_error:: error!(
337- "Context module resolver was not restored from the fresh module"
338- ) )
339- } )
340- } ) )
341- }
342- }
343-
344277#[ impl_source_map_config]
345278#[ cacheable]
346279#[ derive( Debug ) ]
@@ -353,7 +286,7 @@ pub struct ContextModule {
353286 build_info : BuildInfo ,
354287 build_meta : BuildMeta ,
355288 #[ debug( skip) ]
356- #[ cacheable( with=SkipResolveContextModuleDependencies ) ]
289+ #[ cacheable( with=Unsupported ) ]
357290 resolve_dependencies : ResolveContextModuleDependencies ,
358291 force_build : bool ,
359292}
0 commit comments