Skip to content

Importing all validation functions into index.js prevents successful treeshaking. #2587

@Jme797

Description

@Jme797

Describe the bug

Tree-shaking does not work as expected when using validator.js with modern bundlers (esbuild, webpack, etc). Even when only a single function isEmail is imported, the entire library is included in the bundle. This results in unnecessarily large bundles.

This is caused by the main index.js file, which imports all validator functions and aggregates them into a single default export object. This pattern prevents bundlers from removing unused code, even with "sideEffects": false in package.json.

Examples
If applicable, add screenshots to help explain your problem.

Reproductions
If applicable, provide a reproduction on platforms like runkit

Additional context
Validator.js version:
Node.js version:
OS platform: [windows, linux, macOS, etc]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions