Is your feature request related to a problem? Please describe.
The current runtime validation logic is always included in the production bundle, even when validation is intended to be used only in development environments.
Because the validation functions are referenced in a way that prevents static analysis from eliminating them, bundlers cannot reliably tree-shake this code. This results in unnecessary bundle size and additional runtime overhead in production.
Describe the solution you'd like
Refactor the validation logic to follow a statically analyzable pattern that guarantees 100% tree-shaking in production builds.
Specifically:
- Ensure validation code is isolated behind compile-time constants (e.g.
__DEV__) or conditional exports.
- Avoid dynamic function references or runtime branching that blocks dead-code elimination.
- Structure validation as side-effect-free modules that can be fully removed by modern bundlers when disabled.
- Keep the runtime API unchanged for users.
Describe alternatives you've considered
-
Keeping the current runtime checks and relying on minification only
→ Rejected, as this does not guarantee complete removal of validation code.
-
Toggling validation with runtime flags or environment variables at execution time
→ Rejected, since runtime conditionals still prevent reliable tree-shaking.
-
Removing runtime validation entirely from production builds via separate entry points
→ Considered, but increases maintenance cost and API complexity.
Additional context
This change is part of an effort to improve bundle efficiency and ensure that development-only safeguards do not leak into production builds.
The pattern should be compatible with common bundlers (Vite, Rollup, Webpack) and align with best practices for dead-code elimination and side-effect management.
Is your feature request related to a problem? Please describe.
The current runtime validation logic is always included in the production bundle, even when validation is intended to be used only in development environments.
Because the validation functions are referenced in a way that prevents static analysis from eliminating them, bundlers cannot reliably tree-shake this code. This results in unnecessary bundle size and additional runtime overhead in production.
Describe the solution you'd like
Refactor the validation logic to follow a statically analyzable pattern that guarantees 100% tree-shaking in production builds.
Specifically:
__DEV__) or conditional exports.Describe alternatives you've considered
Keeping the current runtime checks and relying on minification only
→ Rejected, as this does not guarantee complete removal of validation code.
Toggling validation with runtime flags or environment variables at execution time
→ Rejected, since runtime conditionals still prevent reliable tree-shaking.
Removing runtime validation entirely from production builds via separate entry points
→ Considered, but increases maintenance cost and API complexity.
Additional context
This change is part of an effort to improve bundle efficiency and ensure that development-only safeguards do not leak into production builds.
The pattern should be compatible with common bundlers (Vite, Rollup, Webpack) and align with best practices for dead-code elimination and side-effect management.