Timezone support broken in Vite due to dynamic require of date-fns-tz
Describe the bug
When developing with Vite with the default React config, the new timeZone prop fails to work.
This seems to be due to the code dynamically using require to import date-fns-tz, which apparently isn't supported by Vite:
https://github.com/Hacker0x01/react-datepicker/blob/644f2f512d2efcc83885811b0faa3de7fc111350/src/date_utils.ts#L118-L120
Screenshot from debugger, inside the require call in the above code.
To Reproduce Steps to reproduce the behavior:
- See the minimal Vite setup in https://codesandbox.io/p/devbox/fmvlts (use https://fmvlts-5173.csb.app/ to view outside the editor)
- Observe times are rendered in local time
- Observe the
timeZone prop requires "date-fns-tz" packagewarning in console
Expected behavior
Dates rendered in configured timeZone (Pacific/Auckland in example to make it clear).
If this requires specific configuration on the Vite side, it would be a good idea to document in timezone.md (but I couldn't find anything to enable dynamic require in Vite).
Screenshots N/A
Desktop (please complete the following information):
- OS: Debian testing
- Browser: Firefox 147.0b9
Source: Hacker0x01/react-datepicker