Skip to content

perf: remove JS side config validation#11897

Merged
chenjiahan merged 21 commits intomainfrom
remove_zod_1016
Oct 17, 2025
Merged

perf: remove JS side config validation#11897
chenjiahan merged 21 commits intomainfrom
remove_zod_1016

Conversation

@chenjiahan
Copy link
Member

@chenjiahan chenjiahan commented Oct 16, 2025

Summary

This PR removes Zod validation, the validation logic has been stripped from various plugins and configuration files, and the Zod-related dependencies has been removed.

Motivation

  • Improved startup performance: Zod schema validation introduced about 20–40 ms of overhead, skipping it noticeably speeds up startup.
  • Modern applications typically rely on TypeScript for config validation — it offers better type hints without impacting build performance.
    *-// @ts-check is now added by default in create-rspack: feat(create-rspack): add type annotations to JS configs #11896
  • Rsbuild removed Zod validation 3 months ago with no negative impact: perf: disable Rspack config schema validation rsbuild#5475
  • Rspack also performs some validations in Rust side, such as swc-loader option validations, which provides clearer and more direct diagnostics than Zod:

20251016-191107

Performance

  • 20+ms faster:

20251016-214331

  • @rspack/core/dist/index.js is 210.2KB smaller (863.5KB -> 653.3KB)

TODO

  • Optimize duplicate errors caused by multiple #getInstance calls
  • Improve additional option validation for swc-loader

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI review requested due to automatic review settings October 16, 2025 13:45
@chenjiahan chenjiahan requested a review from hardfist as a code owner October 16, 2025 13:45
@netlify
Copy link

netlify bot commented Oct 16, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit f674db1
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/68f207b11990420009724a6d

@github-actions github-actions bot added team The issue/pr is created by the member of Rspack. release: performance release: performance related release(mr only) labels Oct 16, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR removes Zod validation from Rspack's JavaScript configuration validation layer, aiming to improve startup performance by 20-40ms. The validation logic has been completely stripped from plugins, configuration files, and the core Rspack module, with Zod dependencies removed from the package.

Key changes:

  • Removed all Zod schema validation from the JavaScript layer
  • Eliminated validation-related environment variables and test cases
  • Moved ValidationError to RspackError module for backward compatibility

Reviewed Changes

Copilot reviewed 34 out of 35 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/rspack/src/schema/ Complete removal of Zod validation schemas and utilities
packages/rspack/src/rspack.ts Removed validation calls from main rspack function
packages/rspack/src/builtin-plugin/ Stripped validation from all builtin plugins
packages/rspack/src/exports.ts Moved ValidationError export location
packages/rspack/src/RspackError.ts Added deprecated ValidationError class
tests/rspack-test/ Removed validation tests and environment variable settings
website/docs/ Updated documentation to remove validation mode references
packages/rspack/package.json Removed zod and zod-validation-error dependencies
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 16, 2025

📦 Binary Size-limit

Comparing f674db1 to test: Revert 'migrate config tests to rstest (#11895)' (#11902) by 9aoy

❌ Size increased by 256bytes from 47.67MB to 47.67MB (⬆️0.00%)

@codspeed-hq
Copy link

codspeed-hq bot commented Oct 16, 2025

CodSpeed Performance Report

Merging #11897 will not alter performance

Comparing remove_zod_1016 (f674db1) with main (1ff04bd)

Summary

✅ 17 untouched

@chenjiahan chenjiahan merged commit 5208b45 into main Oct 17, 2025
94 of 98 checks passed
@chenjiahan chenjiahan deleted the remove_zod_1016 branch October 17, 2025 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: performance release: performance related release(mr only) team The issue/pr is created by the member of Rspack.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants