typesnippet / antd-phone-input

Advanced, highly customizable phone input component for Ant Design.
https://playground.typesnippet.org/antd-phone-input-5.x/
MIT License
60 stars 11 forks source link

🐛 Bug Report - default import doesn't work with Vite #49

Closed ir4y closed 12 months ago

ir4y commented 1 year ago

Bug description

The package is using default import to supply the component https://github.com/ArtyomVancyan/antd-phone-input/blob/master/src/index.tsx#L43 Unfortunately, this approach doesn't work when vite is used https://github.com/vitejs/vite/issues/2139

So, Vite users have to use hacks like this https://github.com/beda-software/fhir-emr/commit/ce5425837089fa9a83bb18ebe0cf2f79ec8a0d1c :

import PhoneInput from 'antd-phone-input';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const PhoneInputFixed: typeof PhoneInput = PI.default ? PI.default : PI;

I am not sure how to proceed with this bug, but it will inform Vite users and provide them with a workaround.

Reproduction URL

https://github.com/beda-software/fhir-emr/actions/runs/6348145345/job/17244243993

Reproduction steps

  1. Use Vite to build the production version of the app
ArtyomVancyan commented 1 year ago

Hi @ir4y, thanks for the report. I tested with both yarn build and yarn build-storybook, and they succeeded when using antd-phone-input. The actual problem is in tests, especially at Test storybook step as we can see in the provided reproduction URL. When I suggested the #192 PR, I did not expect the tests will fail. I am not familiar with the test-storybook, but phone-related cases need to be updated (I am assuming the types need to be changed from 'string' to 'object').