@@ -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 ,
@@ -2962,6 +2963,8 @@ pub struct AssetInfo {
29622963 pub css_unused_idents : Option < HashSet < String > > ,
29632964 /// whether this asset is over the size limit
29642965 pub is_over_size_limit : Option < bool > ,
2966+ /// the plugin that created the asset
2967+ pub asset_type : ManifestAssetType ,
29652968
29662969 /// Webpack: AssetInfo = KnownAssetInfo & Record<string, any>
29672970 /// This is a hack to store the additional fields in the rust struct.
@@ -3001,6 +3004,11 @@ impl AssetInfo {
30013004 self
30023005 }
30033006
3007+ pub fn with_asset_type ( mut self , v : ManifestAssetType ) -> Self {
3008+ self . asset_type = v;
3009+ self
3010+ }
3011+
30043012 pub fn set_full_hash ( & mut self , v : String ) {
30053013 self . full_hash . insert ( v) ;
30063014 }
@@ -3161,3 +3169,41 @@ pub struct ChunkHashResult {
31613169 pub hash : RspackHashDigest ,
31623170 pub content_hash : ChunkContentHash ,
31633171}
3172+
3173+ #[ cacheable]
3174+ #[ derive( Debug , Clone , Copy , PartialEq , Eq , Hash , Default ) ]
3175+ pub enum ManifestAssetType {
3176+ #[ default]
3177+ Unknown ,
3178+ Asset ,
3179+ Css ,
3180+ JavaScript ,
3181+ Wasm ,
3182+ Custom ( #[ cacheable( with=AsPreset ) ] Ustr ) ,
3183+ }
3184+
3185+ impl fmt:: Display for ManifestAssetType {
3186+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
3187+ match self {
3188+ ManifestAssetType :: Unknown => write ! ( f, "unknown" ) ,
3189+ ManifestAssetType :: Asset => write ! ( f, "asset" ) ,
3190+ ManifestAssetType :: Css => write ! ( f, "css" ) ,
3191+ ManifestAssetType :: JavaScript => write ! ( f, "javascript" ) ,
3192+ ManifestAssetType :: Wasm => write ! ( f, "wasm" ) ,
3193+ ManifestAssetType :: Custom ( custom) => write ! ( f, "{custom}" ) ,
3194+ }
3195+ }
3196+ }
3197+
3198+ impl From < String > for ManifestAssetType {
3199+ fn from ( value : String ) -> Self {
3200+ match value. as_str ( ) {
3201+ "unknown" => ManifestAssetType :: Unknown ,
3202+ "asset" => ManifestAssetType :: Asset ,
3203+ "css" => ManifestAssetType :: Css ,
3204+ "javascript" => ManifestAssetType :: JavaScript ,
3205+ "wasm" => ManifestAssetType :: Wasm ,
3206+ _ => ManifestAssetType :: Custom ( value. into ( ) ) ,
3207+ }
3208+ }
3209+ }
0 commit comments