marnusw / date-fns-tz

Complementary library for date-fns v2 adding IANA time zone support
MIT License
1.05k stars 114 forks source link

node_modules\date-fns-tz\esm\formatInTimeZone\index.js depends on 'date-fns/_lib/cloneObject/index.js'. CommonJS or AMD dependencies can cause optimization bailouts in angular project #193

Open vamshi-rafcos opened 2 years ago

vamshi-rafcos commented 2 years ago

i am using date-fns and also for time zones date-fns-tz. But when using formatInTimeZone method , angular giving CommonJS or AMD dependencies can cause optimization bailouts warning as depends on date-fns/cloneObject.

i am importing like using suggestion given by date-fn-tz import formatInTimeZone from 'date-fns-tz/esm/formatInTimeZone'; but other methods in date-fns-tz working fine like utcToZonedTime,toDate,it doesn't giving any warnings

angular@14 node@16.15

phcent commented 2 years ago

The date-fns package referenced under date-fns-tz/esm is not a bug caused by esm

urielzen commented 2 years ago

Same issue for me when using import format from 'date-fns-tz/esm/format'

Looks like some date-fns-tz esmodules are importing non-esmodules in some instances.

image

tomstolarczuk commented 1 year ago

Importing as import { zonedTimeToUtc } from 'date-fns-tz'; gives the same error about CJS modules.