Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
Back to tool/Back to issues
#6204·react-datepicker

Timezone support broken in Vite due to dynamic require of date-fns-tz

Author: PurkkaKoodariCreated Jan 4, 2026Updated Aug 31, 2026

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. Image

To Reproduce Steps to reproduce the behavior:

  1. See the minimal Vite setup in https://codesandbox.io/p/devbox/fmvlts (use https://fmvlts-5173.csb.app/ to view outside the editor)
  2. Observe times are rendered in local time
  3. Observe the timeZone prop requires "date-fns-tz" package warning 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

View original on GitHubView discussion on GitHub