Skip to content

Commit

Permalink
fix(type): Add missing OptimizationSplitChunksNameFunction param (#8707)
Browse files Browse the repository at this point in the history
* fix(type): Add missing OptimizationSplitChunksNameFunction param

* docs: regenerate api extractor
  • Loading branch information
Lemonexe authored Jan 9, 2025
1 parent 5b73853 commit 3c73d06
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 23 deletions.
34 changes: 17 additions & 17 deletions packages/rspack/etc/core.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4169,7 +4169,7 @@ type OptimizationSplitChunksChunks = "initial" | "async" | "all" | RegExp | ((ch
type OptimizationSplitChunksName = string | false | OptimizationSplitChunksNameFunction;

// @public (undocumented)
export type OptimizationSplitChunksNameFunction = (module?: Module) => unknown;
export type OptimizationSplitChunksNameFunction = (module: Module, chunks: Chunk[], cacheGroupKey: string) => string | undefined;

// @public
export type OptimizationSplitChunksOptions = {
Expand Down Expand Up @@ -6980,7 +6980,7 @@ export const rspackOptions: z.ZodObject<{
defaultSizeTypes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
minChunks: z.ZodOptional<z.ZodNumber>;
usedExports: z.ZodOptional<z.ZodBoolean>;
name: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodLiteral<false>]>, z.ZodFunction<z.ZodTuple<[z.ZodOptional<z.ZodType<Module, z.ZodTypeDef, Module>>], z.ZodUnknown>, z.ZodUnknown>]>>;
name: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodLiteral<false>]>, z.ZodFunction<z.ZodTuple<[z.ZodType<Module, z.ZodTypeDef, Module>, z.ZodArray<z.ZodType<Chunk, z.ZodTypeDef, Chunk>, "many">, z.ZodString], z.ZodUnknown>, z.ZodOptional<z.ZodString>>]>>;
minSize: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodRecord<z.ZodString, z.ZodNumber>]>>;
maxSize: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodRecord<z.ZodString, z.ZodNumber>]>>;
maxAsyncSize: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodRecord<z.ZodString, z.ZodNumber>]>>;
Expand All @@ -6993,7 +6993,7 @@ export const rspackOptions: z.ZodObject<{
defaultSizeTypes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
minChunks: z.ZodOptional<z.ZodNumber>;
usedExports: z.ZodOptional<z.ZodBoolean>;
name: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodLiteral<false>]>, z.ZodFunction<z.ZodTuple<[z.ZodOptional<z.ZodType<Module, z.ZodTypeDef, Module>>], z.ZodUnknown>, z.ZodUnknown>]>>;
name: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodString, z.ZodLiteral<false>]>, z.ZodFunction<z.ZodTuple<[z.ZodType<Module, z.ZodTypeDef, Module>, z.ZodArray<z.ZodType<Chunk, z.ZodTypeDef, Chunk>, "many">, z.ZodString], z.ZodUnknown>, z.ZodOptional<z.ZodString>>]>>;
minSize: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodRecord<z.ZodString, z.ZodNumber>]>>;
maxSize: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodRecord<z.ZodString, z.ZodNumber>]>>;
maxAsyncSize: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodRecord<z.ZodString, z.ZodNumber>]>>;
Expand All @@ -7011,7 +7011,7 @@ export const rspackOptions: z.ZodObject<{
}, "strict", z.ZodTypeAny, {
type?: string | RegExp | undefined;
chunks?: RegExp | "initial" | "async" | "all" | ((args_0: Chunk, ...args: unknown[]) => boolean) | undefined;
name?: string | false | ((args_0: Module | undefined, ...args: unknown[]) => unknown) | undefined;
name?: string | false | ((args_0: Module, args_1: Chunk[], args_2: string, ...args: unknown[]) => string | undefined) | undefined;
filename?: string | ((args_0: PathData, args_1: JsAssetInfo | undefined, ...args: unknown[]) => string) | undefined;
usedExports?: boolean | undefined;
defaultSizeTypes?: string[] | undefined;
Expand All @@ -7031,7 +7031,7 @@ export const rspackOptions: z.ZodObject<{
}, {
type?: string | RegExp | undefined;
chunks?: RegExp | "initial" | "async" | "all" | ((args_0: Chunk, ...args: unknown[]) => boolean) | undefined;
name?: string | false | ((args_0: Module | undefined, ...args: unknown[]) => unknown) | undefined;
name?: string | false | ((args_0: Module, args_1: Chunk[], args_2: string, ...args: unknown[]) => string | undefined) | undefined;
filename?: string | ((args_0: PathData, args_1: JsAssetInfo | undefined, ...args: unknown[]) => string) | undefined;
usedExports?: boolean | undefined;
defaultSizeTypes?: string[] | undefined;
Expand Down Expand Up @@ -7074,13 +7074,13 @@ export const rspackOptions: z.ZodObject<{
hidePathInfo: z.ZodOptional<z.ZodBoolean>;
}, "strict", z.ZodTypeAny, {
chunks?: RegExp | "initial" | "async" | "all" | ((args_0: Chunk, ...args: unknown[]) => boolean) | undefined;
name?: string | false | ((args_0: Module | undefined, ...args: unknown[]) => unknown) | undefined;
name?: string | false | ((args_0: Module, args_1: Chunk[], args_2: string, ...args: unknown[]) => string | undefined) | undefined;
usedExports?: boolean | undefined;
defaultSizeTypes?: string[] | undefined;
cacheGroups?: Record<string, false | {
type?: string | RegExp | undefined;
chunks?: RegExp | "initial" | "async" | "all" | ((args_0: Chunk, ...args: unknown[]) => boolean) | undefined;
name?: string | false | ((args_0: Module | undefined, ...args: unknown[]) => unknown) | undefined;
name?: string | false | ((args_0: Module, args_1: Chunk[], args_2: string, ...args: unknown[]) => string | undefined) | undefined;
filename?: string | ((args_0: PathData, args_1: JsAssetInfo | undefined, ...args: unknown[]) => string) | undefined;
usedExports?: boolean | undefined;
defaultSizeTypes?: string[] | undefined;
Expand Down Expand Up @@ -7117,13 +7117,13 @@ export const rspackOptions: z.ZodObject<{
automaticNameDelimiter?: string | undefined;
}, {
chunks?: RegExp | "initial" | "async" | "all" | ((args_0: Chunk, ...args: unknown[]) => boolean) | undefined;
name?: string | false | ((args_0: Module | undefined, ...args: unknown[]) => unknown) | undefined;
name?: string | false | ((args_0: Module, args_1: Chunk[], args_2: string, ...args: unknown[]) => string | undefined) | undefined;
usedExports?: boolean | undefined;
defaultSizeTypes?: string[] | undefined;
cacheGroups?: Record<string, false | {
type?: string | RegExp | undefined;
chunks?: RegExp | "initial" | "async" | "all" | ((args_0: Chunk, ...args: unknown[]) => boolean) | undefined;
name?: string | false | ((args_0: Module | undefined, ...args: unknown[]) => unknown) | undefined;
name?: string | false | ((args_0: Module, args_1: Chunk[], args_2: string, ...args: unknown[]) => string | undefined) | undefined;
filename?: string | ((args_0: PathData, args_1: JsAssetInfo | undefined, ...args: unknown[]) => string) | undefined;
usedExports?: boolean | undefined;
defaultSizeTypes?: string[] | undefined;
Expand Down Expand Up @@ -7199,13 +7199,13 @@ export const rspackOptions: z.ZodObject<{
mergeDuplicateChunks?: boolean | undefined;
splitChunks?: false | {
chunks?: RegExp | "initial" | "async" | "all" | ((args_0: Chunk, ...args: unknown[]) => boolean) | undefined;
name?: string | false | ((args_0: Module | undefined, ...args: unknown[]) => unknown) | undefined;
name?: string | false | ((args_0: Module, args_1: Chunk[], args_2: string, ...args: unknown[]) => string | undefined) | undefined;
usedExports?: boolean | undefined;
defaultSizeTypes?: string[] | undefined;
cacheGroups?: Record<string, false | {
type?: string | RegExp | undefined;
chunks?: RegExp | "initial" | "async" | "all" | ((args_0: Chunk, ...args: unknown[]) => boolean) | undefined;
name?: string | false | ((args_0: Module | undefined, ...args: unknown[]) => unknown) | undefined;
name?: string | false | ((args_0: Module, args_1: Chunk[], args_2: string, ...args: unknown[]) => string | undefined) | undefined;
filename?: string | ((args_0: PathData, args_1: JsAssetInfo | undefined, ...args: unknown[]) => string) | undefined;
usedExports?: boolean | undefined;
defaultSizeTypes?: string[] | undefined;
Expand Down Expand Up @@ -7266,13 +7266,13 @@ export const rspackOptions: z.ZodObject<{
mergeDuplicateChunks?: boolean | undefined;
splitChunks?: false | {
chunks?: RegExp | "initial" | "async" | "all" | ((args_0: Chunk, ...args: unknown[]) => boolean) | undefined;
name?: string | false | ((args_0: Module | undefined, ...args: unknown[]) => unknown) | undefined;
name?: string | false | ((args_0: Module, args_1: Chunk[], args_2: string, ...args: unknown[]) => string | undefined) | undefined;
usedExports?: boolean | undefined;
defaultSizeTypes?: string[] | undefined;
cacheGroups?: Record<string, false | {
type?: string | RegExp | undefined;
chunks?: RegExp | "initial" | "async" | "all" | ((args_0: Chunk, ...args: unknown[]) => boolean) | undefined;
name?: string | false | ((args_0: Module | undefined, ...args: unknown[]) => unknown) | undefined;
name?: string | false | ((args_0: Module, args_1: Chunk[], args_2: string, ...args: unknown[]) => string | undefined) | undefined;
filename?: string | ((args_0: PathData, args_1: JsAssetInfo | undefined, ...args: unknown[]) => string) | undefined;
usedExports?: boolean | undefined;
defaultSizeTypes?: string[] | undefined;
Expand Down Expand Up @@ -8891,13 +8891,13 @@ export const rspackOptions: z.ZodObject<{
mergeDuplicateChunks?: boolean | undefined;
splitChunks?: false | {
chunks?: RegExp | "initial" | "async" | "all" | ((args_0: Chunk, ...args: unknown[]) => boolean) | undefined;
name?: string | false | ((args_0: Module | undefined, ...args: unknown[]) => unknown) | undefined;
name?: string | false | ((args_0: Module, args_1: Chunk[], args_2: string, ...args: unknown[]) => string | undefined) | undefined;
usedExports?: boolean | undefined;
defaultSizeTypes?: string[] | undefined;
cacheGroups?: Record<string, false | {
type?: string | RegExp | undefined;
chunks?: RegExp | "initial" | "async" | "all" | ((args_0: Chunk, ...args: unknown[]) => boolean) | undefined;
name?: string | false | ((args_0: Module | undefined, ...args: unknown[]) => unknown) | undefined;
name?: string | false | ((args_0: Module, args_1: Chunk[], args_2: string, ...args: unknown[]) => string | undefined) | undefined;
filename?: string | ((args_0: PathData, args_1: JsAssetInfo | undefined, ...args: unknown[]) => string) | undefined;
usedExports?: boolean | undefined;
defaultSizeTypes?: string[] | undefined;
Expand Down Expand Up @@ -9495,13 +9495,13 @@ export const rspackOptions: z.ZodObject<{
mergeDuplicateChunks?: boolean | undefined;
splitChunks?: false | {
chunks?: RegExp | "initial" | "async" | "all" | ((args_0: Chunk, ...args: unknown[]) => boolean) | undefined;
name?: string | false | ((args_0: Module | undefined, ...args: unknown[]) => unknown) | undefined;
name?: string | false | ((args_0: Module, args_1: Chunk[], args_2: string, ...args: unknown[]) => string | undefined) | undefined;
usedExports?: boolean | undefined;
defaultSizeTypes?: string[] | undefined;
cacheGroups?: Record<string, false | {
type?: string | RegExp | undefined;
chunks?: RegExp | "initial" | "async" | "all" | ((args_0: Chunk, ...args: unknown[]) => boolean) | undefined;
name?: string | false | ((args_0: Module | undefined, ...args: unknown[]) => unknown) | undefined;
name?: string | false | ((args_0: Module, args_1: Chunk[], args_2: string, ...args: unknown[]) => string | undefined) | undefined;
filename?: string | ((args_0: PathData, args_1: JsAssetInfo | undefined, ...args: unknown[]) => string) | undefined;
usedExports?: boolean | undefined;
defaultSizeTypes?: string[] | undefined;
Expand Down
6 changes: 5 additions & 1 deletion packages/rspack/src/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2080,7 +2080,11 @@ export type OptimizationRuntimeChunk =
name?: string | ((value: { name: string }) => string);
};

export type OptimizationSplitChunksNameFunction = (module?: Module) => unknown;
export type OptimizationSplitChunksNameFunction = (
module: Module,
chunks: Chunk[],
cacheGroupKey: string
) => string | undefined;

type OptimizationSplitChunksName =
| string
Expand Down
11 changes: 6 additions & 5 deletions packages/rspack/src/config/zod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1178,11 +1178,12 @@ const optimizationRuntimeChunk = z
})
) satisfies z.ZodType<t.OptimizationRuntimeChunk>;

const optimizationSplitChunksNameFunction = z.function().args(
z.instanceof(Module).optional()
// FIXME: z.array(z.instanceof(Chunk)).optional(), z.string()
// FIXME: Chunk[], cacheChunkKey
) satisfies z.ZodType<t.OptimizationSplitChunksNameFunction>;
const optimizationSplitChunksNameFunction = z
.function()
.args(z.instanceof(Module), z.array(z.instanceof(Chunk)), z.string())
.returns(
z.string().optional()
) satisfies z.ZodType<t.OptimizationSplitChunksNameFunction>;

const optimizationSplitChunksName = z
.string()
Expand Down

2 comments on commit 3c73d06

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented on 3c73d06 Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Benchmark detail: Open

Name Base (2025-01-09 203b7e9) Current Change
10000_big_production-mode_disable-minimize + exec 37.4 s ± 521 ms 37.6 s ± 343 ms +0.55 %
10000_development-mode + exec 1.89 s ± 27 ms 1.88 s ± 49 ms -0.32 %
10000_development-mode_hmr + exec 680 ms ± 5 ms 679 ms ± 5.9 ms -0.13 %
10000_production-mode + exec 2.46 s ± 73 ms 2.45 s ± 70 ms -0.43 %
arco-pro_development-mode + exec 1.74 s ± 59 ms 1.76 s ± 88 ms +0.87 %
arco-pro_development-mode_hmr + exec 378 ms ± 0.84 ms 379 ms ± 3.7 ms +0.26 %
arco-pro_production-mode + exec 3.74 s ± 54 ms 3.64 s ± 79 ms -2.52 %
arco-pro_production-mode_generate-package-json-webpack-plugin + exec 3.74 s ± 137 ms 3.81 s ± 129 ms +1.87 %
arco-pro_production-mode_traverse-chunk-modules + exec 3.77 s ± 125 ms 3.64 s ± 93 ms -3.58 %
large-dyn-imports_development-mode + exec 2.13 s ± 30 ms 2.15 s ± 28 ms +0.67 %
large-dyn-imports_production-mode + exec 2.19 s ± 33 ms 2.21 s ± 89 ms +0.96 %
threejs_development-mode_10x + exec 1.54 s ± 55 ms 1.49 s ± 16 ms -3.20 %
threejs_development-mode_10x_hmr + exec 792 ms ± 20 ms 769 ms ± 38 ms -2.94 %
threejs_production-mode_10x + exec 5.36 s ± 92 ms 5.38 s ± 183 ms +0.28 %
10000_big_production-mode_disable-minimize + rss memory 9538 MiB ± 224 MiB 9597 MiB ± 106 MiB +0.61 %
10000_development-mode + rss memory 649 MiB ± 13.7 MiB 652 MiB ± 16.5 MiB +0.39 %
10000_development-mode_hmr + rss memory 1435 MiB ± 327 MiB 1338 MiB ± 316 MiB -6.77 %
10000_production-mode + rss memory 643 MiB ± 26.3 MiB 643 MiB ± 36.3 MiB -0.04 %
arco-pro_development-mode + rss memory 550 MiB ± 28.7 MiB 546 MiB ± 43.3 MiB -0.76 %
arco-pro_development-mode_hmr + rss memory 619 MiB ± 52 MiB 596 MiB ± 88.7 MiB -3.66 %
arco-pro_production-mode + rss memory 720 MiB ± 76 MiB 714 MiB ± 45.1 MiB -0.90 %
arco-pro_production-mode_generate-package-json-webpack-plugin + rss memory 725 MiB ± 72.1 MiB 726 MiB ± 50.8 MiB +0.20 %
arco-pro_production-mode_traverse-chunk-modules + rss memory 741 MiB ± 51 MiB 690 MiB ± 29.9 MiB -6.81 %
large-dyn-imports_development-mode + rss memory 632 MiB ± 2.97 MiB 625 MiB ± 4.42 MiB -1.10 %
large-dyn-imports_production-mode + rss memory 525 MiB ± 3.14 MiB 518 MiB ± 1.61 MiB -1.37 %
threejs_development-mode_10x + rss memory 579 MiB ± 11.7 MiB 570 MiB ± 14.2 MiB -1.55 %
threejs_development-mode_10x_hmr + rss memory 1131 MiB ± 121 MiB 1085 MiB ± 134 MiB -4.06 %
threejs_production-mode_10x + rss memory 880 MiB ± 51.8 MiB 867 MiB ± 28.7 MiB -1.52 %

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented on 3c73d06 Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Ecosystem CI detail: Open

suite result
modernjs ❌ failure
rspress ✅ success
rslib ✅ success
rsbuild ✅ success
rsdoctor ✅ success
examples ✅ success
devserver ✅ success
nuxt ✅ success

Please sign in to comment.