ruimarinho / google-libphonenumber

The up-to-date and reliable Google's libphonenumber package for node.js.
https://ruimarinho.github.io/google-libphonenumber
Other
1.4k stars 145 forks source link

Way to do specific function imports #323

Closed akshay-devadiga-backup closed 2 years ago

akshay-devadiga-backup commented 2 years ago

Hi Thanks for this awesome plugin.

Is there any way to do specific function imports similar to what lodash supports? Currently, we use only two functions PhoneNumberFormat,PhoneNumberUtil and we dont use the rest of the functions. Noticed this possible usecase while trying to improve the overall performance of the app, this can really help reduce the overall build file sizes.

Eg: if you want to use only the 'debounce' method, we can do

  1. npm install lodash.debounce
  2. import debounce from 'lodash/debounce'

Something like, import PhoneNumberFormat from 'google-libphonenumber/PhoneNumberFormat'; import PhoneNumberUtil from 'google-libphonenumber/PhoneNumberUtil ';

image

ruimarinho commented 2 years ago

Hi @akshay-devadiga, thanks! Unfortunately Google has relied on Google Closure to bundle these modules, which would require it to be loaded in order to import them individually. This means this package is mostly recommended for server-side processing.

I've seen other modules implement the same metadata but with a more common ES2015 module-like approach.