From f1f8f31eb43e397ebe248747b8061196bf2e7b87 Mon Sep 17 00:00:00 2001 From: jserfeng <1114550440@qq.com> Date: Fri, 9 Aug 2024 12:15:58 +0800 Subject: [PATCH] fix: maxInitialRequests should exists in cache groups --- crates/node_binding/binding.d.ts | 2 + .../src/options/raw_split_chunks/mod.rs | 8 +- .../rspack-issue-7509/index.js | 14 +++ .../rspack-issue-7509/node_modules/a.js | 1 + .../rspack-issue-7509/node_modules/b.js | 1 + .../rspack-issue-7509/node_modules/c.js | 1 + .../rspack-issue-7509/node_modules/d.js | 1 + .../rspack-issue-7509/rspack.config.js | 20 ++++ packages/rspack/etc/api.md | 108 +++++++++++++----- packages/rspack/src/config/defaults.ts | 8 +- packages/rspack/src/config/zod.ts | 4 +- 11 files changed, 126 insertions(+), 42 deletions(-) create mode 100644 packages/rspack-test-tools/tests/configCases/split-chunks-common/rspack-issue-7509/index.js create mode 100644 packages/rspack-test-tools/tests/configCases/split-chunks-common/rspack-issue-7509/node_modules/a.js create mode 100644 packages/rspack-test-tools/tests/configCases/split-chunks-common/rspack-issue-7509/node_modules/b.js create mode 100644 packages/rspack-test-tools/tests/configCases/split-chunks-common/rspack-issue-7509/node_modules/c.js create mode 100644 packages/rspack-test-tools/tests/configCases/split-chunks-common/rspack-issue-7509/node_modules/d.js create mode 100644 packages/rspack-test-tools/tests/configCases/split-chunks-common/rspack-issue-7509/rspack.config.js 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..e5916ee047e2 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 @@ -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(u32::MAX), + max_initial_requests: v.max_initial_requests.unwrap_or(u32::MAX), max_async_size, max_initial_size, r#type, 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..fbcbb1219cf8 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 : 2 ** 32 - 1)); + F(splitChunks, "maxInitialRequests", () => (production ? 30 : 2 ** 32 - 1)); 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(),