@@ -2,7 +2,7 @@ pub mod build_chunk_graph;
22pub mod build_module_graph;
33use std:: {
44 collections:: { VecDeque , hash_map} ,
5- fmt:: Debug ,
5+ fmt:: { self , Debug } ,
66 hash:: { BuildHasherDefault , Hash } ,
77 sync:: {
88 Arc ,
@@ -37,6 +37,7 @@ use rspack_util::allocative;
3737use rspack_util:: { itoa, tracing_preset:: TRACING_BENCH_TARGET } ;
3838use rustc_hash:: { FxHashMap as HashMap , FxHashSet as HashSet , FxHasher } ;
3939use tracing:: instrument;
40+ use ustr:: Ustr ;
4041
4142use crate :: {
4243 AsyncModulesArtifact , BindingCell , BoxDependency , BoxModule , CacheCount , CacheOptions ,
@@ -2955,6 +2956,8 @@ pub struct AssetInfo {
29552956 pub css_unused_idents : Option < HashSet < String > > ,
29562957 /// whether this asset is over the size limit
29572958 pub is_over_size_limit : Option < bool > ,
2959+ /// the plugin that created the asset
2960+ pub asset_type : ManifestAssetType ,
29582961
29592962 /// Webpack: AssetInfo = KnownAssetInfo & Record<string, any>
29602963 /// This is a hack to store the additional fields in the rust struct.
@@ -2994,6 +2997,11 @@ impl AssetInfo {
29942997 self
29952998 }
29962999
3000+ pub fn with_asset_type ( mut self , v : ManifestAssetType ) -> Self {
3001+ self . asset_type = v;
3002+ self
3003+ }
3004+
29973005 pub fn set_full_hash ( & mut self , v : String ) {
29983006 self . full_hash . insert ( v) ;
29993007 }
@@ -3154,3 +3162,41 @@ pub struct ChunkHashResult {
31543162 pub hash : RspackHashDigest ,
31553163 pub content_hash : ChunkContentHash ,
31563164}
3165+
3166+ #[ cacheable]
3167+ #[ derive( Debug , Clone , Copy , PartialEq , Eq , Hash , Default ) ]
3168+ pub enum ManifestAssetType {
3169+ #[ default]
3170+ Unknown ,
3171+ Asset ,
3172+ Css ,
3173+ JavaScript ,
3174+ Wasm ,
3175+ Custom ( #[ cacheable( with=AsPreset ) ] Ustr ) ,
3176+ }
3177+
3178+ impl fmt:: Display for ManifestAssetType {
3179+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
3180+ match self {
3181+ ManifestAssetType :: Unknown => write ! ( f, "unknown" ) ,
3182+ ManifestAssetType :: Asset => write ! ( f, "asset" ) ,
3183+ ManifestAssetType :: Css => write ! ( f, "css" ) ,
3184+ ManifestAssetType :: JavaScript => write ! ( f, "javascript" ) ,
3185+ ManifestAssetType :: Wasm => write ! ( f, "wasm" ) ,
3186+ ManifestAssetType :: Custom ( custom) => write ! ( f, "{custom}" ) ,
3187+ }
3188+ }
3189+ }
3190+
3191+ impl From < String > for ManifestAssetType {
3192+ fn from ( value : String ) -> Self {
3193+ match value. as_str ( ) {
3194+ "unknown" => ManifestAssetType :: Unknown ,
3195+ "asset" => ManifestAssetType :: Asset ,
3196+ "css" => ManifestAssetType :: Css ,
3197+ "javascript" => ManifestAssetType :: JavaScript ,
3198+ "wasm" => ManifestAssetType :: Wasm ,
3199+ _ => ManifestAssetType :: Custom ( value. into ( ) ) ,
3200+ }
3201+ }
3202+ }
0 commit comments