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

next-auth are not exported correctly for ES modules #5288

Closed
joshuaavalon opened this issue Sep 5, 2022 · 1 comment
Closed

next-auth are not exported correctly for ES modules #5288

joshuaavalon opened this issue Sep 5, 2022 · 1 comment
Labels
triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.

Comments

@joshuaavalon
Copy link

joshuaavalon commented Sep 5, 2022

Environment

  • next-auth: 4.10.3
  • typescript: 4.8.2
  • node: v16.14.2

Reproduction URL

https://github.com/joshuaavalon/next-auth-es-bug

Describe the issue

From the typescript definitions provided by next-auth, most of the functions are export via default.

However, it is not the case. It is export at default.default

I try to wrap next-auth in a local package and import it in next.js

How to reproduce

  1. Clone https://github.com/joshuaavalon/next-auth-es-bug
  2. Run npm i
  3. Run npm run build
  4. Run npm run start

Expected behavior

import { default as NextAuth } from "next-auth";

console.log(NextAuth);

It prints

{ default: [Getter], unstable_getServerSession: [Getter] }

It is expected to print

[Function: NextAuth]
@joshuaavalon joshuaavalon added the triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime. label Sep 5, 2022
@joshuaavalon
Copy link
Author

This is related to microsoft/TypeScript#22851.

When you compile to esnext module, esModuleInterop does not work.

My workaround is creating a CommonJs package, and export the default as named.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.
Projects
None yet
Development

No branches or pull requests

1 participant