Importing all validation functions into index.js prevents successful treeshaking.
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]
Feel free to open a PR that improves this, while keeping in mind the current tests and that we still support old Node versions
Feel free to open a PR that improves this, while keeping in mind the current tests and that we still support old Node versions
There's a PR that I've tested in one of my projects and works. I can't seem to get the node 6 version to run but I can't see anything that would cause it to fail in the changes I made.
I've tried resetting to master and I also can't get it to work locally anymore (it did earlier today). So I'm a little confused what's happening there.
Wtf is this
On Wed, Sep 17, 2025 at 12:20 PM Jordan @.***> wrote:
Jme797 left a comment (validatorjs/validator.js#2587) https://github.com/validatorjs/validator.js/issues/2587#issuecomment-3303911995
Feel free to open a PR that improves this, while keeping in mind the current tests and that we still support old Node versions
There's a PR that I've tested in one of my projects and works. I can't seem to get the node 6 version to run but I can't see anything that would cause it to fail in the changes I made.
I've tried resetting to master and I also can't get it to work locally anymore (it did earlier today). So I'm a little confused what's happening there.
— Reply to this email directly, view it on GitHub https://github.com/validatorjs/validator.js/issues/2587#issuecomment-3303911995, or unsubscribe https://github.com/notifications/unsubscribe-auth/AR6KIW6TTX5FBENHJ5G5OUT3TGJ5NAVCNFSM6AAAAACGX4DTCOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTGMBTHEYTCOJZGU . You are receiving this because you are subscribed to this thread.Message ID: @.***>