pub trait Module:
Debug
+ Send
+ Sync
+ Any
+ AsAny
+ Identifiable
+ DependenciesBlock
+ Diagnosable
+ ModuleSourceMapConfig
+ SerializeDyn {
Show 31 methods
// Required methods
fn module_type(&self) -> &ModuleType;
fn source_types(&self, module_graph: &ModuleGraph<'_>) -> &[SourceType];
fn source(&self) -> Option<&BoxSource>;
fn readable_identifier(&self, _context: &Context) -> Cow<'_, str>;
fn size(
&self,
source_type: Option<&SourceType>,
compilation: Option<&Compilation>,
) -> f64;
fn factory_meta(&self) -> Option<&FactoryMeta>;
fn set_factory_meta(&mut self, factory_meta: FactoryMeta);
fn build_info(&self) -> &BuildInfo;
fn build_info_mut(&mut self) -> &mut BuildInfo;
fn build_meta(&self) -> &BuildMeta;
fn build_meta_mut(&mut self) -> &mut BuildMeta;
fn code_generation<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_compilation: &'life1 Compilation,
_runtime: Option<&'life2 RuntimeSpec>,
_concatenation_scope: Option<ConcatenationScope>,
) -> Pin<Box<dyn Future<Output = Result<CodeGenerationResult>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn get_runtime_hash<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
compilation: &'life1 Compilation,
runtime: Option<&'life2 RuntimeSpec>,
) -> Pin<Box<dyn Future<Output = Result<RspackHashDigest>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
// Provided methods
fn build<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_build_context: BuildContext,
_compilation: Option<&'life1 Compilation>,
) -> Pin<Box<dyn Future<Output = Result<BuildResult>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn get_exports_argument(&self) -> ExportsArgument { ... }
fn get_module_argument(&self) -> ModuleArgument { ... }
fn get_exports_type(
&self,
module_graph: &ModuleGraph<'_>,
module_graph_cache: &ModuleGraphCacheArtifact,
strict: bool,
) -> ExportsType { ... }
fn get_strict_esm_module(&self) -> bool { ... }
fn name_for_condition(&self) -> Option<Box<str>> { ... }
fn lib_ident(&self, _options: LibIdentOptions<'_>) -> Option<Cow<'_, str>> { ... }
fn get_code_generation_dependencies(&self) -> Option<&[BoxModuleDependency]> { ... }
fn get_presentational_dependencies(
&self,
) -> Option<&[BoxDependencyTemplate]> { ... }
fn get_concatenation_bailout_reason(
&self,
_mg: &ModuleGraph<'_>,
_cg: &ChunkGraph,
) -> Option<Cow<'static, str>> { ... }
fn get_resolve_options(&self) -> Option<Arc<Resolve>> { ... }
fn get_context(&self) -> Option<Box<Context>> { ... }
fn get_layer(&self) -> Option<&ModuleLayer> { ... }
fn chunk_condition(
&self,
_chunk_key: &ChunkUkey,
_compilation: &Compilation,
) -> Option<bool> { ... }
fn get_side_effects_connection_state(
&self,
_module_graph: &ModuleGraph<'_>,
_module_graph_cache: &ModuleGraphCacheArtifact,
_module_chain: &mut IdentifierSet,
_connection_state_cache: &mut IdentifierMap<ConnectionState>,
) -> ConnectionState { ... }
fn need_build(&self, value_cache_version: &ValueCacheVersions) -> bool { ... }
fn depends_on(&self, modified_file: &ArcPathSet) -> bool { ... }
fn need_id(&self) -> bool { ... }
}Required Methods§
Sourcefn module_type(&self) -> &ModuleType
fn module_type(&self) -> &ModuleType
Defines what kind of module this is.
Sourcefn source_types(&self, module_graph: &ModuleGraph<'_>) -> &[SourceType]
fn source_types(&self, module_graph: &ModuleGraph<'_>) -> &[SourceType]
Defines what kind of code generation results this module can generate.
Sourcefn source(&self) -> Option<&BoxSource>
fn source(&self) -> Option<&BoxSource>
The source of the module. This could be optional, modules like the NormalModule can have the corresponding source.
However, modules that is created from “nowhere” (e.g. ExternalModule and MissingModule) does not have its source.
Sourcefn readable_identifier(&self, _context: &Context) -> Cow<'_, str>
fn readable_identifier(&self, _context: &Context) -> Cow<'_, str>
User readable identifier of the module.
Sourcefn size(
&self,
source_type: Option<&SourceType>,
compilation: Option<&Compilation>,
) -> f64
fn size( &self, source_type: Option<&SourceType>, compilation: Option<&Compilation>, ) -> f64
The size of the original source, which will used as a parameter for code-splitting. Only when calculating the size of the RuntimeModule is the Compilation depended on
fn factory_meta(&self) -> Option<&FactoryMeta>
fn set_factory_meta(&mut self, factory_meta: FactoryMeta)
fn build_info(&self) -> &BuildInfo
fn build_info_mut(&mut self) -> &mut BuildInfo
fn build_meta(&self) -> &BuildMeta
fn build_meta_mut(&mut self) -> &mut BuildMeta
Sourcefn code_generation<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_compilation: &'life1 Compilation,
_runtime: Option<&'life2 RuntimeSpec>,
_concatenation_scope: Option<ConcatenationScope>,
) -> Pin<Box<dyn Future<Output = Result<CodeGenerationResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn code_generation<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_compilation: &'life1 Compilation,
_runtime: Option<&'life2 RuntimeSpec>,
_concatenation_scope: Option<ConcatenationScope>,
) -> Pin<Box<dyn Future<Output = Result<CodeGenerationResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
The actual code generation of the module, which will be called by the Compilation.
The code generation result should not be cached as it is implemented elsewhere to
provide a universal cache mechanism (time to invalidate cache, etc.)
Code generation will often iterate through every source_types given by the module
to provide multiple code generation results for different source_types.
Sourcefn get_runtime_hash<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
compilation: &'life1 Compilation,
runtime: Option<&'life2 RuntimeSpec>,
) -> Pin<Box<dyn Future<Output = Result<RspackHashDigest>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn get_runtime_hash<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
compilation: &'life1 Compilation,
runtime: Option<&'life2 RuntimeSpec>,
) -> Pin<Box<dyn Future<Output = Result<RspackHashDigest>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Update hash for cgm.hash (chunk graph module hash)
Different cgm code generation result should have different cgm.hash,
so this also accept compilation (mainly chunk graph) and runtime as args.
(Difference with impl Hash for Module: this is just a part for calculating cgm.hash, not for Module itself)
Provided Methods§
Sourcefn build<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_build_context: BuildContext,
_compilation: Option<&'life1 Compilation>,
) -> Pin<Box<dyn Future<Output = Result<BuildResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn build<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_build_context: BuildContext,
_compilation: Option<&'life1 Compilation>,
) -> Pin<Box<dyn Future<Output = Result<BuildResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
The actual build of the module, which will be called by the Compilation.
Build can also returns the dependencies of the module, which will be used by the Compilation to build the dependency graph.
fn get_exports_argument(&self) -> ExportsArgument
fn get_module_argument(&self) -> ModuleArgument
fn get_exports_type( &self, module_graph: &ModuleGraph<'_>, module_graph_cache: &ModuleGraphCacheArtifact, strict: bool, ) -> ExportsType
fn get_strict_esm_module(&self) -> bool
Sourcefn name_for_condition(&self) -> Option<Box<str>>
fn name_for_condition(&self) -> Option<Box<str>>
Name matched against bundle-splitting conditions.
fn lib_ident(&self, _options: LibIdentOptions<'_>) -> Option<Cow<'_, str>>
Sourcefn get_code_generation_dependencies(&self) -> Option<&[BoxModuleDependency]>
fn get_code_generation_dependencies(&self) -> Option<&[BoxModuleDependency]>
Code generation dependencies of the module, which means the code generation of this module
depends on the code generation results of dependencies which are returned by this function.
e.g Css module may rely on the code generation result of CssUrlDependency to re-direct
the url of the referenced assets.
fn get_presentational_dependencies(&self) -> Option<&[BoxDependencyTemplate]>
fn get_concatenation_bailout_reason( &self, _mg: &ModuleGraph<'_>, _cg: &ChunkGraph, ) -> Option<Cow<'static, str>>
Sourcefn get_resolve_options(&self) -> Option<Arc<Resolve>>
fn get_resolve_options(&self) -> Option<Arc<Resolve>>
Resolve options matched by module rules.
e.g javascript/esm may have special resolving options like fullySpecified.
css and css/module may have special resolving options like preferRelative.
fn get_context(&self) -> Option<Box<Context>>
fn get_layer(&self) -> Option<&ModuleLayer>
fn chunk_condition( &self, _chunk_key: &ChunkUkey, _compilation: &Compilation, ) -> Option<bool>
fn get_side_effects_connection_state( &self, _module_graph: &ModuleGraph<'_>, _module_graph_cache: &ModuleGraphCacheArtifact, _module_chain: &mut IdentifierSet, _connection_state_cache: &mut IdentifierMap<ConnectionState>, ) -> ConnectionState
fn need_build(&self, value_cache_version: &ValueCacheVersions) -> bool
fn depends_on(&self, modified_file: &ArcPathSet) -> bool
fn need_id(&self) -> bool
Implementations§
Source§impl dyn Module
impl dyn Module
pub fn as_normal_module(&self) -> Option<&NormalModule>
pub fn as_normal_module_mut(&mut self) -> Option<&mut NormalModule>
pub fn try_as_normal_module(&self) -> Result<&NormalModule>
pub fn try_as_normal_module_mut(&mut self) -> Result<&mut NormalModule>
Source§impl dyn Module
impl dyn Module
pub fn as_raw_module(&self) -> Option<&RawModule>
pub fn as_raw_module_mut(&mut self) -> Option<&mut RawModule>
pub fn try_as_raw_module(&self) -> Result<&RawModule>
pub fn try_as_raw_module_mut(&mut self) -> Result<&mut RawModule>
Source§impl dyn Module
impl dyn Module
pub fn as_context_module(&self) -> Option<&ContextModule>
pub fn as_context_module_mut(&mut self) -> Option<&mut ContextModule>
pub fn try_as_context_module(&self) -> Result<&ContextModule>
pub fn try_as_context_module_mut(&mut self) -> Result<&mut ContextModule>
Source§impl dyn Module
impl dyn Module
pub fn as_external_module(&self) -> Option<&ExternalModule>
pub fn as_external_module_mut(&mut self) -> Option<&mut ExternalModule>
pub fn try_as_external_module(&self) -> Result<&ExternalModule>
pub fn try_as_external_module_mut(&mut self) -> Result<&mut ExternalModule>
Source§impl dyn Module
impl dyn Module
pub fn as_self_module(&self) -> Option<&SelfModule>
pub fn as_self_module_mut(&mut self) -> Option<&mut SelfModule>
pub fn try_as_self_module(&self) -> Result<&SelfModule>
pub fn try_as_self_module_mut(&mut self) -> Result<&mut SelfModule>
Source§impl dyn Module
impl dyn Module
pub fn as_concatenated_module(&self) -> Option<&ConcatenatedModule>
pub fn as_concatenated_module_mut(&mut self) -> Option<&mut ConcatenatedModule>
pub fn try_as_concatenated_module(&self) -> Result<&ConcatenatedModule>
pub fn try_as_concatenated_module_mut( &mut self, ) -> Result<&mut ConcatenatedModule>
Trait Implementations§
Source§impl ArchiveUnsized for dyn Module
impl ArchiveUnsized for dyn Module
Source§type Archived = dyn DeserializeModule
type Archived = dyn DeserializeModule
Archive, it may be
unsized. Read moreSource§fn archived_metadata(&self) -> ArchivedMetadata<Self>
fn archived_metadata(&self) -> ArchivedMetadata<Self>
Source§impl DeserializeDyn<dyn Module> for ArchivedConcatenatedModule
impl DeserializeDyn<dyn Module> for ArchivedConcatenatedModule
Source§fn deserialize_dyn(
&self,
deserializer: &mut Deserializer,
out: *mut dyn Module,
) -> Result<(), DeserializeError>
fn deserialize_dyn( &self, deserializer: &mut Deserializer, out: *mut dyn Module, ) -> Result<(), DeserializeError>
Source§fn deserialized_pointer_metadata(&self) -> DynMetadata<dyn Module>
fn deserialized_pointer_metadata(&self) -> DynMetadata<dyn Module>
Source§impl DeserializeDyn<dyn Module> for ArchivedContextModule
impl DeserializeDyn<dyn Module> for ArchivedContextModule
Source§fn deserialize_dyn(
&self,
deserializer: &mut Deserializer,
out: *mut dyn Module,
) -> Result<(), DeserializeError>
fn deserialize_dyn( &self, deserializer: &mut Deserializer, out: *mut dyn Module, ) -> Result<(), DeserializeError>
Source§fn deserialized_pointer_metadata(&self) -> DynMetadata<dyn Module>
fn deserialized_pointer_metadata(&self) -> DynMetadata<dyn Module>
Source§impl DeserializeDyn<dyn Module> for ArchivedExternalModule
impl DeserializeDyn<dyn Module> for ArchivedExternalModule
Source§fn deserialize_dyn(
&self,
deserializer: &mut Deserializer,
out: *mut dyn Module,
) -> Result<(), DeserializeError>
fn deserialize_dyn( &self, deserializer: &mut Deserializer, out: *mut dyn Module, ) -> Result<(), DeserializeError>
Source§fn deserialized_pointer_metadata(&self) -> DynMetadata<dyn Module>
fn deserialized_pointer_metadata(&self) -> DynMetadata<dyn Module>
Source§impl DeserializeDyn<dyn Module> for ArchivedNormalModule
impl DeserializeDyn<dyn Module> for ArchivedNormalModule
Source§fn deserialize_dyn(
&self,
deserializer: &mut Deserializer,
out: *mut dyn Module,
) -> Result<(), DeserializeError>
fn deserialize_dyn( &self, deserializer: &mut Deserializer, out: *mut dyn Module, ) -> Result<(), DeserializeError>
Source§fn deserialized_pointer_metadata(&self) -> DynMetadata<dyn Module>
fn deserialized_pointer_metadata(&self) -> DynMetadata<dyn Module>
Source§impl DeserializeDyn<dyn Module> for ArchivedRawModule
impl DeserializeDyn<dyn Module> for ArchivedRawModule
Source§fn deserialize_dyn(
&self,
deserializer: &mut Deserializer,
out: *mut dyn Module,
) -> Result<(), DeserializeError>
fn deserialize_dyn( &self, deserializer: &mut Deserializer, out: *mut dyn Module, ) -> Result<(), DeserializeError>
Source§fn deserialized_pointer_metadata(&self) -> DynMetadata<dyn Module>
fn deserialized_pointer_metadata(&self) -> DynMetadata<dyn Module>
Source§impl DeserializeDyn<dyn Module> for ArchivedSelfModule
impl DeserializeDyn<dyn Module> for ArchivedSelfModule
Source§fn deserialize_dyn(
&self,
deserializer: &mut Deserializer,
out: *mut dyn Module,
) -> Result<(), DeserializeError>
fn deserialize_dyn( &self, deserializer: &mut Deserializer, out: *mut dyn Module, ) -> Result<(), DeserializeError>
Source§fn deserialized_pointer_metadata(&self) -> DynMetadata<dyn Module>
fn deserialized_pointer_metadata(&self) -> DynMetadata<dyn Module>
Source§impl Identifiable for Box<dyn Module>
impl Identifiable for Box<dyn Module>
Source§fn identifier(&self) -> Identifier
fn identifier(&self) -> Identifier
Uniquely identify a module. If two modules share the same module identifier, then they are considered as the same module.
e.g javascript/auto|<absolute-path>/index.js and javascript/auto|<absolute-path>/index.js are considered as the same.