Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: split validators.ts into multiple files to allow proper tree shaking #519

Closed
gempain opened this issue Feb 8, 2020 · 3 comments
Closed
Labels
status: done/released Issue has been completed, no further action is needed. type: fix Issues describing a broken feature.

Comments

@gempain
Copy link

gempain commented Feb 8, 2020

In validators.ts, line 20-22:

private libPhoneNumber = {
    phoneUtil: require("google-libphonenumber").PhoneNumberUtil.getInstance(),
};

When class-validator is bundled with webpack, google-libphonenumber, which represents 71% of the bundle size, is embedded, even if you don't use the phone number validator. See this bundle analysis made with webpack-bundle-analyzer:

Screenshot 2020-02-08 at 17 43 41

Validators should be split into different files, allowing to import only the needed files without extra code and thus enabling proper tree shaking when bundling dependencies with webpack.

@Larsrdev
Copy link
Contributor

here some older PR and more to read: #258

@gempain
Copy link
Author

gempain commented Feb 25, 2020

@Larsrdev right ! Weird, I thought I had searched properly before even taking the time to investigate. Anyways, closing in favor of #258. Sorry for the noise 😄

@gempain gempain closed this as completed Feb 29, 2020
@lock
Copy link

lock bot commented Mar 10, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Mar 10, 2020
@NoNameProvided NoNameProvided added status: done/released Issue has been completed, no further action is needed. type: fix Issues describing a broken feature. labels Aug 8, 2020
@NoNameProvided NoNameProvided changed the title Split validators.ts into multiple files to allow proper tree shaking fix: split validators.ts into multiple files to allow proper tree shaking Aug 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: done/released Issue has been completed, no further action is needed. type: fix Issues describing a broken feature.
Development

No branches or pull requests

3 participants