Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/date_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,12 @@ function getDateFnsTz(): DateFnsTz | null {

try {
// Dynamic require for date-fns-tz
// Use a variable to prevent webpack from statically analyzing the require
// and showing warnings when the optional dependency is not installed
// See: https://github.com/Hacker0x01/react-datepicker/issues/6154
const dateFnsTzModuleName = "date-fns-tz";
// eslint-disable-next-line @typescript-eslint/no-require-imports
dateFnsTz = require("date-fns-tz") as DateFnsTz;
dateFnsTz = require(dateFnsTzModuleName) as DateFnsTz;
} catch {
/* istanbul ignore next - only executes when date-fns-tz is not installed */
dateFnsTz = null;
Expand Down
Loading