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

Issues when using ViteJS

Open army003 opened this issue 2 years ago • 3 comments

I am using ViteJS in my project. When I import elements from this library, it cause an error on production-mode, because lib not compatable with ViteJS. Could you please add UMD support?

army003 avatar Jan 12 '23 11:01 army003

It is possible, check https://github.com/vitejs/vite/issues/4704

The snippet:

import ReactPhoneInput, { PhoneInputProps } from 'react-phone-input-2'

const PhoneInput: typeof ReactPhoneInput = ReactPhoneInput.default
  ? ReactPhoneInput.default
  : ReactPhoneInput

ihmpavel avatar Jan 12 '23 20:01 ihmpavel

Thanks @ihmpavel!

mariocsantos avatar May 26 '23 21:05 mariocsantos

For non-typescript:

import P from 'react-phone-input-2';

const PhoneInput = P.default ? P.default : P;

jprosevear avatar Feb 24 '24 12:02 jprosevear