Skip to content

Error when compiling for CJS: "The current file is a CommonJS module..." #1478

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

Closed
1 task done
darwish opened this issue Dec 4, 2023 · 0 comments · Fixed by #1479
Closed
1 task done

Error when compiling for CJS: "The current file is a CommonJS module..." #1478

darwish opened this issue Dec 4, 2023 · 0 comments · Fixed by #1479
Labels
bug Something isn't working openapi-fetch Relevant to the openapi-fetch library

Comments

@darwish
Copy link
Contributor

darwish commented Dec 4, 2023

Description

When including openapi-fetch from a CommonJS module, we get the following error:

node_modules/openapi-fetch/dist/cjs/index.d.cts:10:8 - 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("openapi-typescript-helpers")' call instead.

10 } from "openapi-typescript-helpers";
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Found 1 error in node_modules/openapi-fetch/dist/cjs/index.d.cts:10

Reproduction

See the following proof-of-concept repo: https://github.com/darwish/openapi-typescript-poc

Checklist

@darwish darwish added bug Something isn't working openapi-fetch Relevant to the openapi-fetch library labels Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working openapi-fetch Relevant to the openapi-fetch library
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant