react-phone-number-input icon indicating copy to clipboard operation
react-phone-number-input copied to clipboard

(Possibly Webpack) Build locks and fails if using utility functions

Open zackdotcomputer opened this issue 2 years ago • 1 comments

I cannot fully explain this yet, but here's the observed behavior:

  • building in a [email protected] app
  • depending on [email protected]
  • no issues using PhoneInput component
  • However, if I add the following code to a file that is included by webpack in the final build (note, just including this code but not running it) then the build hangs and eventually fails. This fails both as a production next build and as a development next dev.
import { isPossiblePhoneNumber } from 'react-phone-number-input';
export const isPossiblePhone = (s: string) => isPossiblePhoneNumber(s);

This also happens if you use isValidPhoneNumber instead.

I'm unclear how this could be happening just from bringing those functions into scope even after having read through the code. If you have any ideas on how to debug further or fix please let me know.

zackdotcomputer avatar May 30 '22 17:05 zackdotcomputer

Hmm, that's weird.

See if using the original functions from libphonenumber-js works:

import {
	isValidPhoneNumber,
	isPossiblePhoneNumber,
	getCountryCallingCode,
	getCountries,
	isSupportedCountry
} from 'libphonenumber-js/min'

catamphetamine avatar May 30 '22 20:05 catamphetamine