Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CommonJS support is broken #21

Open
ritave opened this issue Oct 15, 2024 · 1 comment
Open

CommonJS support is broken #21

ritave opened this issue Oct 15, 2024 · 1 comment

Comments

@ritave
Copy link

ritave commented Oct 15, 2024

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
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants