diff --git a/crates/node_binding/binding.d.ts b/crates/node_binding/binding.d.ts index 59cf81a3898d..486a0d5b6a0e 100644 --- a/crates/node_binding/binding.d.ts +++ b/crates/node_binding/binding.d.ts @@ -979,6 +979,8 @@ export interface RawCacheGroupOptions { maxSize?: number | RawSplitChunkSizes maxAsyncSize?: number | RawSplitChunkSizes maxInitialSize?: number | RawSplitChunkSizes + maxAsyncRequests?: number + maxInitialRequests?: number name?: string | false | Function reuseExistingChunk?: boolean enforce?: boolean diff --git a/crates/rspack_binding_options/src/options/raw_split_chunks/mod.rs b/crates/rspack_binding_options/src/options/raw_split_chunks/mod.rs index d836fac79c43..ec7ad615a0d0 100644 --- a/crates/rspack_binding_options/src/options/raw_split_chunks/mod.rs +++ b/crates/rspack_binding_options/src/options/raw_split_chunks/mod.rs @@ -39,8 +39,8 @@ pub struct RawSplitChunksOptions { pub chunks: Option, pub used_exports: Option, pub automatic_name_delimiter: Option, - pub max_async_requests: Option, - pub max_initial_requests: Option, + pub max_async_requests: Option, + pub max_initial_requests: Option, pub default_size_types: Vec, pub min_chunks: Option, pub hide_path_info: Option, @@ -90,6 +90,8 @@ pub struct RawCacheGroupOptions { pub max_size: Option>, pub max_async_size: Option>, pub max_initial_size: Option>, + pub max_async_requests: Option, + pub max_initial_requests: Option, #[napi(ts_type = "string | false | Function")] #[derivative(Debug = "ignore")] pub name: Option, @@ -214,10 +216,8 @@ impl From for rspack_plugin_split_chunks::PluginOptions { .unwrap_or(overall_automatic_name_delimiter.clone()), filename: v.filename.map(Filename::from), reuse_existing_chunk: v.reuse_existing_chunk.unwrap_or(false), - // TODO(hyf0): the non-enforced default value should be 30 - // I would set align default value with Webpack when the options is exposed to users - max_async_requests: u32::MAX, - max_initial_requests: u32::MAX, + max_async_requests: v.max_async_requests.unwrap_or(f64::INFINITY), + max_initial_requests: v.max_initial_requests.unwrap_or(f64::INFINITY), max_async_size, max_initial_size, r#type, diff --git a/crates/rspack_plugin_split_chunks/src/options/cache_group.rs b/crates/rspack_plugin_split_chunks/src/options/cache_group.rs index 104130ac26f8..a78eab2f6a91 100644 --- a/crates/rspack_plugin_split_chunks/src/options/cache_group.rs +++ b/crates/rspack_plugin_split_chunks/src/options/cache_group.rs @@ -36,8 +36,8 @@ pub struct CacheGroup { /// number of referenced chunks pub min_chunks: u32, pub id_hint: String, - pub max_initial_requests: u32, - pub max_async_requests: u32, + pub max_initial_requests: f64, // f64 for compat js Infinity + pub max_async_requests: f64, // f64 for compat js Infinity pub max_async_size: SplitChunkSizes, pub max_initial_size: SplitChunkSizes, pub filename: Option, diff --git a/crates/rspack_plugin_split_chunks/src/plugin/max_request.rs b/crates/rspack_plugin_split_chunks/src/plugin/max_request.rs index f954ec14bf8e..638402119d38 100644 --- a/crates/rspack_plugin_split_chunks/src/plugin/max_request.rs +++ b/crates/rspack_plugin_split_chunks/src/plugin/max_request.rs @@ -24,7 +24,7 @@ impl SplitChunksPlugin { let allowed_max_request = if chunk.is_only_initial(chunk_group_db) { cache_group.max_initial_requests } else if chunk.can_be_initial(chunk_group_db) { - u32::max( + f64::max( cache_group.max_initial_requests, cache_group.max_async_requests, ) @@ -54,7 +54,7 @@ impl SplitChunksPlugin { .map(|requests| requests as u32) .unwrap_or_default(); - if actually_requests >= allowed_max_request { + if actually_requests as f64 >= allowed_max_request { Some(chunk.ukey) } else { None diff --git a/packages/rspack-test-tools/tests/configCases/split-chunks-common/rspack-issue-7509/index.js b/packages/rspack-test-tools/tests/configCases/split-chunks-common/rspack-issue-7509/index.js new file mode 100644 index 000000000000..b95e1ad4f599 --- /dev/null +++ b/packages/rspack-test-tools/tests/configCases/split-chunks-common/rspack-issue-7509/index.js @@ -0,0 +1,14 @@ +it("should not split chunk when maxInitialRequests set to only 1", function () { + const a = require("./node_modules/a"); + expect(a).toBe("a"); + const b = require("./node_modules/b"); + expect(b).toBe("b"); + const c = require("./node_modules/c"); + expect(c).toBe("c"); + const d = require("./node_modules/d"); + expect(d).toBe("d"); + + const fs = require('fs') + const files = fs.readdirSync(__dirname) + expect(files.filter(file => file.endsWith('.js')).length).toBe(1) +}); diff --git a/packages/rspack-test-tools/tests/configCases/split-chunks-common/rspack-issue-7509/node_modules/a.js b/packages/rspack-test-tools/tests/configCases/split-chunks-common/rspack-issue-7509/node_modules/a.js new file mode 100644 index 000000000000..6cd1d0075d40 --- /dev/null +++ b/packages/rspack-test-tools/tests/configCases/split-chunks-common/rspack-issue-7509/node_modules/a.js @@ -0,0 +1 @@ +module.exports = "a"; diff --git a/packages/rspack-test-tools/tests/configCases/split-chunks-common/rspack-issue-7509/node_modules/b.js b/packages/rspack-test-tools/tests/configCases/split-chunks-common/rspack-issue-7509/node_modules/b.js new file mode 100644 index 000000000000..dfbbeb621fa8 --- /dev/null +++ b/packages/rspack-test-tools/tests/configCases/split-chunks-common/rspack-issue-7509/node_modules/b.js @@ -0,0 +1 @@ +module.exports = "b"; diff --git a/packages/rspack-test-tools/tests/configCases/split-chunks-common/rspack-issue-7509/node_modules/c.js b/packages/rspack-test-tools/tests/configCases/split-chunks-common/rspack-issue-7509/node_modules/c.js new file mode 100644 index 000000000000..f55ffed587c9 --- /dev/null +++ b/packages/rspack-test-tools/tests/configCases/split-chunks-common/rspack-issue-7509/node_modules/c.js @@ -0,0 +1 @@ +module.exports = "c"; diff --git a/packages/rspack-test-tools/tests/configCases/split-chunks-common/rspack-issue-7509/node_modules/d.js b/packages/rspack-test-tools/tests/configCases/split-chunks-common/rspack-issue-7509/node_modules/d.js new file mode 100644 index 000000000000..0a281018ca16 --- /dev/null +++ b/packages/rspack-test-tools/tests/configCases/split-chunks-common/rspack-issue-7509/node_modules/d.js @@ -0,0 +1 @@ +module.exports = "d"; diff --git a/packages/rspack-test-tools/tests/configCases/split-chunks-common/rspack-issue-7509/rspack.config.js b/packages/rspack-test-tools/tests/configCases/split-chunks-common/rspack-issue-7509/rspack.config.js new file mode 100644 index 000000000000..8378cc505c76 --- /dev/null +++ b/packages/rspack-test-tools/tests/configCases/split-chunks-common/rspack-issue-7509/rspack.config.js @@ -0,0 +1,20 @@ +/** @type {import("@rspack/core").Configuration} */ +module.exports = { + optimization: { + chunkIds: 'named', + splitChunks: { + maxInitialRequests: 10, + cacheGroups: { + vendors: { + chunks: 'all', + test: /node_modules/, + minSize: 0, + filename: 'split-[name].js', + + // should override the splitChunks.maxInitialRequests + maxInitialRequests: 1, + } + } + } + } +} diff --git a/packages/rspack/etc/api.md b/packages/rspack/etc/api.md index 3e4bd69d3945..a5b31dca14ec 100644 --- a/packages/rspack/etc/api.md +++ b/packages/rspack/etc/api.md @@ -7302,6 +7302,8 @@ const optimization: z.ZodObject<{ maxSize: z.ZodOptional]>>; maxAsyncSize: z.ZodOptional]>>; maxInitialSize: z.ZodOptional]>>; + maxAsyncRequests: z.ZodOptional; + maxInitialRequests: z.ZodOptional; automaticNameDelimiter: z.ZodOptional; cacheGroups: z.ZodOptional, z.ZodObject<{ chunks: z.ZodOptional, z.ZodType]>, z.ZodFunction], z.ZodUnknown>, z.ZodBoolean>]>>; @@ -7313,6 +7315,8 @@ const optimization: z.ZodObject<{ maxSize: z.ZodOptional]>>; maxAsyncSize: z.ZodOptional]>>; maxInitialSize: z.ZodOptional]>>; + maxAsyncRequests: z.ZodOptional; + maxInitialRequests: z.ZodOptional; automaticNameDelimiter: z.ZodOptional; test: z.ZodOptional]>, z.ZodFunction], z.ZodUnknown>, z.ZodUnknown>]>>; priority: z.ZodOptional; @@ -7338,6 +7342,8 @@ const optimization: z.ZodObject<{ maxSize?: number | Record | undefined; maxAsyncSize?: number | Record | undefined; maxInitialSize?: number | Record | undefined; + maxAsyncRequests?: number | undefined; + maxInitialRequests?: number | undefined; automaticNameDelimiter?: string | undefined; }, { filename?: string | undefined; @@ -7356,10 +7362,10 @@ const optimization: z.ZodObject<{ maxSize?: number | Record | undefined; maxAsyncSize?: number | Record | undefined; maxInitialSize?: number | Record | undefined; + maxAsyncRequests?: number | undefined; + maxInitialRequests?: number | undefined; automaticNameDelimiter?: string | undefined; }>]>>>; - maxAsyncRequests: z.ZodOptional; - maxInitialRequests: z.ZodOptional; fallbackCacheGroup: z.ZodOptional, z.ZodType]>, z.ZodFunction], z.ZodUnknown>, z.ZodBoolean>]>>; minSize: z.ZodOptional; @@ -7393,6 +7399,8 @@ const optimization: z.ZodObject<{ maxSize?: number | Record | undefined; maxAsyncSize?: number | Record | undefined; maxInitialSize?: number | Record | undefined; + maxAsyncRequests?: number | undefined; + maxInitialRequests?: number | undefined; automaticNameDelimiter?: string | undefined; cacheGroups?: Record | undefined; maxAsyncSize?: number | Record | undefined; maxInitialSize?: number | Record | undefined; + maxAsyncRequests?: number | undefined; + maxInitialRequests?: number | undefined; automaticNameDelimiter?: string | undefined; }> | undefined; - maxAsyncRequests?: number | undefined; - maxInitialRequests?: number | undefined; fallbackCacheGroup?: { chunks?: RegExp | "async" | "initial" | "all" | ((args_0: Chunk, ...args_1: unknown[]) => boolean) | undefined; minSize?: number | undefined; @@ -7434,6 +7442,8 @@ const optimization: z.ZodObject<{ maxSize?: number | Record | undefined; maxAsyncSize?: number | Record | undefined; maxInitialSize?: number | Record | undefined; + maxAsyncRequests?: number | undefined; + maxInitialRequests?: number | undefined; automaticNameDelimiter?: string | undefined; cacheGroups?: Record | undefined; maxAsyncSize?: number | Record | undefined; maxInitialSize?: number | Record | undefined; + maxAsyncRequests?: number | undefined; + maxInitialRequests?: number | undefined; automaticNameDelimiter?: string | undefined; }> | undefined; - maxAsyncRequests?: number | undefined; - maxInitialRequests?: number | undefined; fallbackCacheGroup?: { chunks?: RegExp | "async" | "initial" | "all" | ((args_0: Chunk, ...args_1: unknown[]) => boolean) | undefined; minSize?: number | undefined; @@ -7510,6 +7520,8 @@ const optimization: z.ZodObject<{ maxSize?: number | Record | undefined; maxAsyncSize?: number | Record | undefined; maxInitialSize?: number | Record | undefined; + maxAsyncRequests?: number | undefined; + maxInitialRequests?: number | undefined; automaticNameDelimiter?: string | undefined; cacheGroups?: Record | undefined; maxAsyncSize?: number | Record | undefined; maxInitialSize?: number | Record | undefined; + maxAsyncRequests?: number | undefined; + maxInitialRequests?: number | undefined; automaticNameDelimiter?: string | undefined; }> | undefined; - maxAsyncRequests?: number | undefined; - maxInitialRequests?: number | undefined; fallbackCacheGroup?: { chunks?: RegExp | "async" | "initial" | "all" | ((args_0: Chunk, ...args_1: unknown[]) => boolean) | undefined; minSize?: number | undefined; @@ -7573,6 +7585,8 @@ const optimization: z.ZodObject<{ maxSize?: number | Record | undefined; maxAsyncSize?: number | Record | undefined; maxInitialSize?: number | Record | undefined; + maxAsyncRequests?: number | undefined; + maxInitialRequests?: number | undefined; automaticNameDelimiter?: string | undefined; cacheGroups?: Record | undefined; maxAsyncSize?: number | Record | undefined; maxInitialSize?: number | Record | undefined; + maxAsyncRequests?: number | undefined; + maxInitialRequests?: number | undefined; automaticNameDelimiter?: string | undefined; }> | undefined; - maxAsyncRequests?: number | undefined; - maxInitialRequests?: number | undefined; fallbackCacheGroup?: { chunks?: RegExp | "async" | "initial" | "all" | ((args_0: Chunk, ...args_1: unknown[]) => boolean) | undefined; minSize?: number | undefined; @@ -7664,6 +7678,8 @@ const optimizationSplitChunksCacheGroup: z.ZodObject<{ maxSize: z.ZodOptional]>>; maxAsyncSize: z.ZodOptional]>>; maxInitialSize: z.ZodOptional]>>; + maxAsyncRequests: z.ZodOptional; + maxInitialRequests: z.ZodOptional; automaticNameDelimiter: z.ZodOptional; test: z.ZodOptional]>, z.ZodFunction], z.ZodUnknown>, z.ZodUnknown>]>>; priority: z.ZodOptional; @@ -7689,6 +7705,8 @@ const optimizationSplitChunksCacheGroup: z.ZodObject<{ maxSize?: number | Record | undefined; maxAsyncSize?: number | Record | undefined; maxInitialSize?: number | Record | undefined; + maxAsyncRequests?: number | undefined; + maxInitialRequests?: number | undefined; automaticNameDelimiter?: string | undefined; }, { filename?: string | undefined; @@ -7707,6 +7725,8 @@ const optimizationSplitChunksCacheGroup: z.ZodObject<{ maxSize?: number | Record | undefined; maxAsyncSize?: number | Record | undefined; maxInitialSize?: number | Record | undefined; + maxAsyncRequests?: number | undefined; + maxInitialRequests?: number | undefined; automaticNameDelimiter?: string | undefined; }>; @@ -7730,6 +7750,8 @@ const optimizationSplitChunksOptions: z.ZodObject<{ maxSize: z.ZodOptional]>>; maxAsyncSize: z.ZodOptional]>>; maxInitialSize: z.ZodOptional]>>; + maxAsyncRequests: z.ZodOptional; + maxInitialRequests: z.ZodOptional; automaticNameDelimiter: z.ZodOptional; cacheGroups: z.ZodOptional, z.ZodObject<{ chunks: z.ZodOptional, z.ZodType]>, z.ZodFunction], z.ZodUnknown>, z.ZodBoolean>]>>; @@ -7741,6 +7763,8 @@ const optimizationSplitChunksOptions: z.ZodObject<{ maxSize: z.ZodOptional]>>; maxAsyncSize: z.ZodOptional]>>; maxInitialSize: z.ZodOptional]>>; + maxAsyncRequests: z.ZodOptional; + maxInitialRequests: z.ZodOptional; automaticNameDelimiter: z.ZodOptional; test: z.ZodOptional]>, z.ZodFunction], z.ZodUnknown>, z.ZodUnknown>]>>; priority: z.ZodOptional; @@ -7766,6 +7790,8 @@ const optimizationSplitChunksOptions: z.ZodObject<{ maxSize?: number | Record | undefined; maxAsyncSize?: number | Record | undefined; maxInitialSize?: number | Record | undefined; + maxAsyncRequests?: number | undefined; + maxInitialRequests?: number | undefined; automaticNameDelimiter?: string | undefined; }, { filename?: string | undefined; @@ -7784,10 +7810,10 @@ const optimizationSplitChunksOptions: z.ZodObject<{ maxSize?: number | Record | undefined; maxAsyncSize?: number | Record | undefined; maxInitialSize?: number | Record | undefined; + maxAsyncRequests?: number | undefined; + maxInitialRequests?: number | undefined; automaticNameDelimiter?: string | undefined; }>]>>>; - maxAsyncRequests: z.ZodOptional; - maxInitialRequests: z.ZodOptional; fallbackCacheGroup: z.ZodOptional, z.ZodType]>, z.ZodFunction], z.ZodUnknown>, z.ZodBoolean>]>>; minSize: z.ZodOptional; @@ -7821,6 +7847,8 @@ const optimizationSplitChunksOptions: z.ZodObject<{ maxSize?: number | Record | undefined; maxAsyncSize?: number | Record | undefined; maxInitialSize?: number | Record | undefined; + maxAsyncRequests?: number | undefined; + maxInitialRequests?: number | undefined; automaticNameDelimiter?: string | undefined; cacheGroups?: Record | undefined; maxAsyncSize?: number | Record | undefined; maxInitialSize?: number | Record | undefined; + maxAsyncRequests?: number | undefined; + maxInitialRequests?: number | undefined; automaticNameDelimiter?: string | undefined; }> | undefined; - maxAsyncRequests?: number | undefined; - maxInitialRequests?: number | undefined; fallbackCacheGroup?: { chunks?: RegExp | "async" | "initial" | "all" | ((args_0: Chunk, ...args_1: unknown[]) => boolean) | undefined; minSize?: number | undefined; @@ -7862,6 +7890,8 @@ const optimizationSplitChunksOptions: z.ZodObject<{ maxSize?: number | Record | undefined; maxAsyncSize?: number | Record | undefined; maxInitialSize?: number | Record | undefined; + maxAsyncRequests?: number | undefined; + maxInitialRequests?: number | undefined; automaticNameDelimiter?: string | undefined; cacheGroups?: Record | undefined; maxAsyncSize?: number | Record | undefined; maxInitialSize?: number | Record | undefined; + maxAsyncRequests?: number | undefined; + maxInitialRequests?: number | undefined; automaticNameDelimiter?: string | undefined; }> | undefined; - maxAsyncRequests?: number | undefined; - maxInitialRequests?: number | undefined; fallbackCacheGroup?: { chunks?: RegExp | "async" | "initial" | "all" | ((args_0: Chunk, ...args_1: unknown[]) => boolean) | undefined; minSize?: number | undefined; @@ -11381,6 +11411,8 @@ export const rspackOptions: z.ZodObject<{ maxSize: z.ZodOptional]>>; maxAsyncSize: z.ZodOptional]>>; maxInitialSize: z.ZodOptional]>>; + maxAsyncRequests: z.ZodOptional; + maxInitialRequests: z.ZodOptional; automaticNameDelimiter: z.ZodOptional; cacheGroups: z.ZodOptional, z.ZodObject<{ chunks: z.ZodOptional, z.ZodType]>, z.ZodFunction], z.ZodUnknown>, z.ZodBoolean>]>>; @@ -11392,6 +11424,8 @@ export const rspackOptions: z.ZodObject<{ maxSize: z.ZodOptional]>>; maxAsyncSize: z.ZodOptional]>>; maxInitialSize: z.ZodOptional]>>; + maxAsyncRequests: z.ZodOptional; + maxInitialRequests: z.ZodOptional; automaticNameDelimiter: z.ZodOptional; test: z.ZodOptional]>, z.ZodFunction], z.ZodUnknown>, z.ZodUnknown>]>>; priority: z.ZodOptional; @@ -11417,6 +11451,8 @@ export const rspackOptions: z.ZodObject<{ maxSize?: number | Record | undefined; maxAsyncSize?: number | Record | undefined; maxInitialSize?: number | Record | undefined; + maxAsyncRequests?: number | undefined; + maxInitialRequests?: number | undefined; automaticNameDelimiter?: string | undefined; }, { filename?: string | undefined; @@ -11435,10 +11471,10 @@ export const rspackOptions: z.ZodObject<{ maxSize?: number | Record | undefined; maxAsyncSize?: number | Record | undefined; maxInitialSize?: number | Record | undefined; + maxAsyncRequests?: number | undefined; + maxInitialRequests?: number | undefined; automaticNameDelimiter?: string | undefined; }>]>>>; - maxAsyncRequests: z.ZodOptional; - maxInitialRequests: z.ZodOptional; fallbackCacheGroup: z.ZodOptional, z.ZodType]>, z.ZodFunction], z.ZodUnknown>, z.ZodBoolean>]>>; minSize: z.ZodOptional; @@ -11472,6 +11508,8 @@ export const rspackOptions: z.ZodObject<{ maxSize?: number | Record | undefined; maxAsyncSize?: number | Record | undefined; maxInitialSize?: number | Record | undefined; + maxAsyncRequests?: number | undefined; + maxInitialRequests?: number | undefined; automaticNameDelimiter?: string | undefined; cacheGroups?: Record | undefined; maxAsyncSize?: number | Record | undefined; maxInitialSize?: number | Record | undefined; + maxAsyncRequests?: number | undefined; + maxInitialRequests?: number | undefined; automaticNameDelimiter?: string | undefined; }> | undefined; - maxAsyncRequests?: number | undefined; - maxInitialRequests?: number | undefined; fallbackCacheGroup?: { chunks?: RegExp | "async" | "initial" | "all" | ((args_0: Chunk, ...args_1: unknown[]) => boolean) | undefined; minSize?: number | undefined; @@ -11513,6 +11551,8 @@ export const rspackOptions: z.ZodObject<{ maxSize?: number | Record | undefined; maxAsyncSize?: number | Record | undefined; maxInitialSize?: number | Record | undefined; + maxAsyncRequests?: number | undefined; + maxInitialRequests?: number | undefined; automaticNameDelimiter?: string | undefined; cacheGroups?: Record | undefined; maxAsyncSize?: number | Record | undefined; maxInitialSize?: number | Record | undefined; + maxAsyncRequests?: number | undefined; + maxInitialRequests?: number | undefined; automaticNameDelimiter?: string | undefined; }> | undefined; - maxAsyncRequests?: number | undefined; - maxInitialRequests?: number | undefined; fallbackCacheGroup?: { chunks?: RegExp | "async" | "initial" | "all" | ((args_0: Chunk, ...args_1: unknown[]) => boolean) | undefined; minSize?: number | undefined; @@ -11589,6 +11629,8 @@ export const rspackOptions: z.ZodObject<{ maxSize?: number | Record | undefined; maxAsyncSize?: number | Record | undefined; maxInitialSize?: number | Record | undefined; + maxAsyncRequests?: number | undefined; + maxInitialRequests?: number | undefined; automaticNameDelimiter?: string | undefined; cacheGroups?: Record | undefined; maxAsyncSize?: number | Record | undefined; maxInitialSize?: number | Record | undefined; + maxAsyncRequests?: number | undefined; + maxInitialRequests?: number | undefined; automaticNameDelimiter?: string | undefined; }> | undefined; - maxAsyncRequests?: number | undefined; - maxInitialRequests?: number | undefined; fallbackCacheGroup?: { chunks?: RegExp | "async" | "initial" | "all" | ((args_0: Chunk, ...args_1: unknown[]) => boolean) | undefined; minSize?: number | undefined; @@ -11652,6 +11694,8 @@ export const rspackOptions: z.ZodObject<{ maxSize?: number | Record | undefined; maxAsyncSize?: number | Record | undefined; maxInitialSize?: number | Record | undefined; + maxAsyncRequests?: number | undefined; + maxInitialRequests?: number | undefined; automaticNameDelimiter?: string | undefined; cacheGroups?: Record | undefined; maxAsyncSize?: number | Record | undefined; maxInitialSize?: number | Record | undefined; + maxAsyncRequests?: number | undefined; + maxInitialRequests?: number | undefined; automaticNameDelimiter?: string | undefined; }> | undefined; - maxAsyncRequests?: number | undefined; - maxInitialRequests?: number | undefined; fallbackCacheGroup?: { chunks?: RegExp | "async" | "initial" | "all" | ((args_0: Chunk, ...args_1: unknown[]) => boolean) | undefined; minSize?: number | undefined; @@ -13110,6 +13154,8 @@ export const rspackOptions: z.ZodObject<{ maxSize?: number | Record | undefined; maxAsyncSize?: number | Record | undefined; maxInitialSize?: number | Record | undefined; + maxAsyncRequests?: number | undefined; + maxInitialRequests?: number | undefined; automaticNameDelimiter?: string | undefined; cacheGroups?: Record | undefined; maxAsyncSize?: number | Record | undefined; maxInitialSize?: number | Record | undefined; + maxAsyncRequests?: number | undefined; + maxInitialRequests?: number | undefined; automaticNameDelimiter?: string | undefined; }> | undefined; - maxAsyncRequests?: number | undefined; - maxInitialRequests?: number | undefined; fallbackCacheGroup?: { chunks?: RegExp | "async" | "initial" | "all" | ((args_0: Chunk, ...args_1: unknown[]) => boolean) | undefined; minSize?: number | undefined; @@ -13680,6 +13726,8 @@ export const rspackOptions: z.ZodObject<{ maxSize?: number | Record | undefined; maxAsyncSize?: number | Record | undefined; maxInitialSize?: number | Record | undefined; + maxAsyncRequests?: number | undefined; + maxInitialRequests?: number | undefined; automaticNameDelimiter?: string | undefined; cacheGroups?: Record | undefined; maxAsyncSize?: number | Record | undefined; maxInitialSize?: number | Record | undefined; + maxAsyncRequests?: number | undefined; + maxInitialRequests?: number | undefined; automaticNameDelimiter?: string | undefined; }> | undefined; - maxAsyncRequests?: number | undefined; - maxInitialRequests?: number | undefined; fallbackCacheGroup?: { chunks?: RegExp | "async" | "initial" | "all" | ((args_0: Chunk, ...args_1: unknown[]) => boolean) | undefined; minSize?: number | undefined; diff --git a/packages/rspack/src/config/defaults.ts b/packages/rspack/src/config/defaults.ts index 3de849980a37..c2aba119fbb4 100644 --- a/packages/rspack/src/config/defaults.ts +++ b/packages/rspack/src/config/defaults.ts @@ -950,12 +950,8 @@ const applyOptimizationDefaults = ( F(splitChunks, "minSize", () => (production ? 20000 : 10000)); // F(splitChunks, "minRemainingSize", () => (development ? 0 : undefined)); // F(splitChunks, "enforceSizeThreshold", () => (production ? 50000 : 30000)); - F(splitChunks, "maxAsyncRequests", () => - production ? 30 : Number.POSITIVE_INFINITY - ); - F(splitChunks, "maxInitialRequests", () => - production ? 30 : Number.POSITIVE_INFINITY - ); + F(splitChunks, "maxAsyncRequests", () => (production ? 30 : Infinity)); + F(splitChunks, "maxInitialRequests", () => (production ? 30 : Infinity)); D(splitChunks, "automaticNameDelimiter", "-"); const { cacheGroups } = splitChunks; if (cacheGroups) { diff --git a/packages/rspack/src/config/zod.ts b/packages/rspack/src/config/zod.ts index 033d06e07813..9ff9897e1906 100644 --- a/packages/rspack/src/config/zod.ts +++ b/packages/rspack/src/config/zod.ts @@ -1244,6 +1244,8 @@ const sharedOptimizationSplitChunksCacheGroup = { maxSize: optimizationSplitChunksSizes.optional(), maxAsyncSize: optimizationSplitChunksSizes.optional(), maxInitialSize: optimizationSplitChunksSizes.optional(), + maxAsyncRequests: z.number().optional(), + maxInitialRequests: z.number().optional(), automaticNameDelimiter: z.string().optional() }; const optimizationSplitChunksCacheGroup = z.strictObject({ @@ -1272,8 +1274,6 @@ const optimizationSplitChunksOptions = z.strictObject({ cacheGroups: z .record(z.literal(false).or(optimizationSplitChunksCacheGroup)) .optional(), - maxAsyncRequests: z.number().optional(), - maxInitialRequests: z.number().optional(), fallbackCacheGroup: z .strictObject({ chunks: optimizationSplitChunksChunks.optional(), diff --git a/tests/webpack-test/__snapshots__/ConfigTestCases.basictest.js.snap b/tests/webpack-test/__snapshots__/ConfigTestCases.basictest.js.snap deleted file mode 100644 index 0fa53831f1d7..000000000000 --- a/tests/webpack-test/__snapshots__/ConfigTestCases.basictest.js.snap +++ /dev/null @@ -1,13 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`ConfigTestCases css large exported tests should allow to create css modules: dev 1`] = ` -Object { - "placeholder": "my-app-_tailwind_module_css-placeholder-gray-700", -} -`; - -exports[`ConfigTestCases css large exported tests should allow to create css modules: prod 1`] = ` -Object { - "placeholder": "-dcadb0ba74d8edf55c3-placeholder-gray-700", -} -`; diff --git a/tests/webpack-test/__snapshots__/StatsTestCases.basictest.js.snap b/tests/webpack-test/__snapshots__/StatsTestCases.basictest.js.snap index 1e903ba537ad..927cffd10a82 100644 --- a/tests/webpack-test/__snapshots__/StatsTestCases.basictest.js.snap +++ b/tests/webpack-test/__snapshots__/StatsTestCases.basictest.js.snap @@ -548,11 +548,11 @@ runtime modules 2.59 KiB 3 modules ./a.js 18 bytes [built] [code generated] Rspack x.x.x compiled successfully in X.23 -asset b-runtime~main-eb1e55e9714495b68bff.js 4.39 KiB [emitted] [immutable] (name: runtime~main) +asset b-runtime~main-2a432c6b45b448fcde80.js 4.39 KiB [emitted] [immutable] (name: runtime~main) asset b-all-b_js-468c0f551eefc9f96f0b.js 461 bytes [emitted] [immutable] (id hint: all) -asset b-main-72ac2a7c5326395bcc89.js 420 bytes [emitted] [immutable] (name: main) +asset b-main-236b715ba81f9430f0c7.js 420 bytes [emitted] [immutable] (name: main) asset b-vendors-node_modules_vendor_js-97d43f84c65cc0e25938.js 173 bytes [emitted] [immutable] (id hint: vendors) -Entrypoint main 5.42 KiB = b-runtime~main-eb1e55e9714495b68bff.js 4.39 KiB b-vendors-node_modules_vendor_js-97d43f84c65cc0e25938.js 173 bytes b-all-b_js-468c0f551eefc9f96f0b.js 461 bytes b-main-72ac2a7c5326395bcc89.js 420 bytes +Entrypoint main 5.42 KiB = b-runtime~main-2a432c6b45b448fcde80.js 4.39 KiB b-vendors-node_modules_vendor_js-97d43f84c65cc0e25938.js 173 bytes b-all-b_js-468c0f551eefc9f96f0b.js 461 bytes b-main-236b715ba81f9430f0c7.js 420 bytes runtime modules 3.17 KiB 5 modules cacheable modules 40 bytes ./b.js 17 bytes [built] [code generated]