date-fns / tz

date-fns timezone utils
MIT License
76 stars 6 forks source link

CommonJS support is broken #21

Open ritave opened 3 weeks ago

ritave commented 3 weeks ago

When I import TZDate like so:

import { TZDate } from '@date-fns/tz/date';

I get the following error:

node_modules/@date-fns/tz/date/index.d.cts:1:37 - error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("../constants/index.ts")' call instead.

1 import { constructFromSymbol } from "../constants/index.ts";

Modifying the line from

import { constructFromSymbol } from "../constants/index.ts";

to

import { constructFromSymbol } from "../constants/index.cts";

fixes the error.

kossnocorp commented 1 week ago

Please share your TS settings and steps on how you got this error so that I can fix it.