rspack_plugin_split_chunks/options/
cache_group.rs

1use derive_more::Debug;
2use rspack_core::Filename;
3
4use super::{cache_group_test::CacheGroupTest, chunk_name::ChunkNameGetter};
5use crate::common::{ChunkFilter, ModuleLayerFilter, ModuleTypeFilter, SplitChunkSizes};
6
7#[derive(Debug)]
8pub struct CacheGroup {
9  /// For `splitChunks.cacheGroups` config
10  /// ```js
11  /// splitChunks: {
12  ///   hello: {
13  ///     test: /hello-world\.js/,
14  ///     name: 'hello-world',
15  ///   }
16  /// }
17  /// ```
18  /// `hello` is the `key` here
19  pub key: String,
20  #[debug(skip)]
21  pub chunk_filter: ChunkFilter,
22  #[debug(skip)]
23  pub test: CacheGroupTest,
24  #[debug(skip)]
25  pub r#type: ModuleTypeFilter,
26  #[debug(skip)]
27  pub layer: ModuleLayerFilter,
28  /// `name` is used to create chunk
29  #[debug(skip)]
30  pub name: ChunkNameGetter,
31  pub priority: f64,
32  pub min_size: SplitChunkSizes,
33  pub min_size_reduction: SplitChunkSizes,
34  pub reuse_existing_chunk: bool,
35  /// number of referenced chunks
36  pub min_chunks: u32,
37  pub id_hint: String,
38  pub max_initial_requests: f64, // f64 for compat js Infinity
39  pub max_async_requests: f64,   // f64 for compat js Infinity
40  pub max_async_size: SplitChunkSizes,
41  pub max_initial_size: SplitChunkSizes,
42  pub filename: Option<Filename>,
43  pub automatic_name_delimiter: String,
44  pub used_exports: bool,
45}