date-fns / tz

date-fns timezone utils
MIT License
84 stars 5 forks source link

CommonJS support is broken #21

Open ritave opened 1 month ago

ritave commented 1 month 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 3 weeks ago

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