Skip to content

Commit ada32f9

Browse files
authored
fix: allow Infinity for stats space options (#11685)
fix: allow Infinity in stats space options
1 parent 217878f commit ada32f9

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

packages/rspack/src/schema/config.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { createErrorMap, fromZodError } from "zod-validation-error/v4";
44
import type * as t from "../config/types";
55
import { memoize } from "../util/memoize";
66
import { getZodSwcLoaderOptionsSchema } from "./loaders";
7-
import { anyFunction, numberOrInfinity } from "./utils";
7+
import { anyFunction, intOrInfinity, numberOrInfinity } from "./utils";
88

99
z.config({
1010
jitless: true
@@ -1132,16 +1132,16 @@ export const getRspackOptionsSchema = memoize(() => {
11321132
groupModulesByAttributes: z.boolean(),
11331133
groupModulesByPath: z.boolean(),
11341134
groupModulesByExtension: z.boolean(),
1135-
modulesSpace: z.int(),
1136-
chunkModulesSpace: z.int(),
1137-
nestedModulesSpace: z.int(),
1135+
modulesSpace: intOrInfinity,
1136+
chunkModulesSpace: intOrInfinity,
1137+
nestedModulesSpace: intOrInfinity,
11381138
relatedAssets: z.boolean(),
11391139
groupAssetsByEmitStatus: z.boolean(),
11401140
groupAssetsByInfo: z.boolean(),
11411141
groupAssetsByPath: z.boolean(),
11421142
groupAssetsByExtension: z.boolean(),
11431143
groupAssetsByChunk: z.boolean(),
1144-
assetsSpace: z.int(),
1144+
assetsSpace: intOrInfinity,
11451145
orphanModules: z.boolean(),
11461146
excludeModules: z
11471147
.array(z.string().or(z.instanceof(RegExp)).or(anyFunction))
@@ -1168,16 +1168,16 @@ export const getRspackOptionsSchema = memoize(() => {
11681168
chunkOrigins: z.boolean(),
11691169
runtime: z.boolean(),
11701170
depth: z.boolean(),
1171-
reasonsSpace: z.int(),
1171+
reasonsSpace: intOrInfinity,
11721172
groupReasonsByOrigin: z.boolean(),
11731173
errorDetails: z.boolean(),
11741174
errorStack: z.boolean(),
11751175
moduleTrace: z.boolean(),
11761176
cachedModules: z.boolean(),
11771177
cachedAssets: z.boolean(),
11781178
cached: z.boolean(),
1179-
errorsSpace: z.int(),
1180-
warningsSpace: z.int()
1179+
errorsSpace: intOrInfinity,
1180+
warningsSpace: intOrInfinity
11811181
})
11821182
.partial() satisfies z.ZodType<t.StatsOptions>;
11831183

packages/rspack/src/schema/utils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ export const numberOrInfinity = z
66
.number()
77
.or(z.literal(Number.POSITIVE_INFINITY));
88

9+
export const intOrInfinity = z.int().or(z.literal(Number.POSITIVE_INFINITY));
10+
911
export const anyFunction = z.custom<(...args: unknown[]) => any>(
1012
data => typeof data === "function",
1113
// Make the similar error message as zod v3
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log("stats assetsSpace Infinity test");
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/** @type {import("@rspack/core").Configuration} */
2+
module.exports = {
3+
context: __dirname,
4+
entry: "./index.js",
5+
stats: {
6+
assetsSpace: Infinity
7+
}
8+
};

0 commit comments

Comments
 (0)