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

google-libphonenumber dependency adds 366Kb to my vendor file! #39

Closed
demetrio812 opened this issue Apr 29, 2017 · 8 comments
Closed

google-libphonenumber dependency adds 366Kb to my vendor file! #39

demetrio812 opened this issue Apr 29, 2017 · 8 comments

Comments

@demetrio812
Copy link

Hello,
I was doing some check with source-map-explorer and just saw that ngx-validator contributed for more than 26% of the size of my vendor file (just to compare, the whole material library contributed about 313Kb)...

I think this is not acceptable for a validator library and it's probably better to find an alternative for phone number validations as many ppl will not notice that the size of the vendor file is due to the google-libphonenumber dependency...

At the moment unfortunately the library becomes unusable...

Let me know what you think, I attach a screenshot from source-map-explorer

google_libphonenumber-size

Thanks,
Dem

@Nightapes
Copy link
Owner

Hello Dem,

yes this is the disadvantage of the google-libphonenumber. Maybe i can extract the important parts. But i checked the lib and 50% are the regex for the phone validation. So it will not get that much smaller.

Else we can make a basic phone check and building with AOT should remove the google-libphonenumber lib.
So the user can decide if the lib should be included or not.

@demetrio812
Copy link
Author

The AOT treeshaking doesn't really work properly at the moment (I've tested with the Material 2 library - angular/components#4137 (comment)). I've also tried removing the dependencies and compile it with AOT but it didn't remove the library...

What I'd do is to build a basic version and include it in the library and then create another library (ngx-advanced-phone-number-validator or similar) just with the phone validator, for advanced use cases...

@Nightapes
Copy link
Owner

I'm using Angular 4 with AOT and this lib without the PhoneValidator, and the AOT removes the lib. But i use angular-seed

But i will think about extracting the phone validator in a extra lib.

@demetrio812
Copy link
Author

I'm using Angular 4 with AOT on an angular-cli project and I think they still have got problems with it (WebPack tree shaking with Typescript has a lot of issues at the moment)...I'm following the tickets there and will do some more tests and comment here if there are good news, even if tree shaking will work properly, I still think a basic version of the phone number checker would be good so dev can choose depending on their needs...

@jcphlux
Copy link

jcphlux commented Jun 24, 2017

It would be nice is this was separated out to a separate project like ngx-validators-google-libphonenumber. I am not validating phone number and this size increase has me second guessing if I should use this lib.
I have not messed with tree shaking much is it easy to do?

@vincent
Copy link

vincent commented Mar 28, 2018

Hi @Nightapes,
Any news about this ?

@danierdev
Copy link

Maybe you can use this one: libphonenumber-js is more smaller and support typescript

@Nightapes
Copy link
Owner

I moved the phone validator to a own package https://github.com/Nightapes/ngx-phone-validators

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants