diff --git a/.changeset/rsbuild-cheaper-compilation-scans.md b/.changeset/rsbuild-cheaper-compilation-scans.md new file mode 100644 index 00000000000..9a9d015f68f --- /dev/null +++ b/.changeset/rsbuild-cheaper-compilation-scans.md @@ -0,0 +1,5 @@ +--- +'@tanstack/start-plugin-core': patch +--- + +Skip server function metadata validation for Rsbuild modules that have no server function metadata. diff --git a/packages/start-plugin-core/src/rsbuild/start-compiler-host.ts b/packages/start-plugin-core/src/rsbuild/start-compiler-host.ts index 3cd1725fa09..cae59ce7c39 100644 --- a/packages/start-plugin-core/src/rsbuild/start-compiler-host.ts +++ b/packages/start-plugin-core/src/rsbuild/start-compiler-host.ts @@ -82,9 +82,13 @@ function resolveMetadataLoader(): string { function readServerFnBuildInfo( module: Rspack.Module, ): Record | null { - const result = serverFnBuildInfoSchema.safeParse( - module.buildInfo[SERVER_FN_BUILD_INFO_FIELD], - ) + const metadata = module.buildInfo[SERVER_FN_BUILD_INFO_FIELD] + // Most modules have no metadata, and zod's failure path dominates replay. + if (metadata === undefined) { + return null + } + + const result = serverFnBuildInfoSchema.safeParse(metadata) if (!result.success) { return null }