MichalLytek / class-transformer-validator

A simple plugin for class-transformer and class-validator which combines them in a nice and programmer-friendly API.
MIT License
200 stars 19 forks source link

Support tree shaking (google-libphonenumber is huge) #30

Open C0Nd3Mnd opened 4 years ago

C0Nd3Mnd commented 4 years ago

Using class-transformer-validator results in google-libphonenumber being included in the webpack bundle (even though tree shaking is enabled and no phone number validators are being used).

This was fixed in class-validator itself, see:

I'm wondering if there is an "easy" fix for this package?

MichalLytek commented 4 years ago

Install newer version? class-validator is just a peer dep

C0Nd3Mnd commented 4 years ago

I use version 0.12.2. I think the problem is that class-transformer-validator is importing the whole class-validator package. When I leave class-transformer-validator out of my project, the bundle doesn't include google-libphonenumber and is significantly smaller.

MichalLytek commented 4 years ago

I use version 0.12.2. I think the problem is that class-transformer-validator is importing the whole class-validator package.

It's importing only a few functions 😕 https://github.com/MichalLytek/class-transformer-validator/blob/5d25d52e473f0280a3e7a354e0e141416f771ebb/src/index.ts#L1-L7

C0Nd3Mnd commented 4 years ago

Hm I see. I'm gonna have to dig deeper then. I'll post here if and when I find a possible solution.