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

dts resolve to CJS entry dts instead of ESM entry dts #53949

Closed
loynoir opened this issue Apr 21, 2023 · 4 comments
Closed

dts resolve to CJS entry dts instead of ESM entry dts #53949

loynoir opened this issue Apr 21, 2023 · 4 comments
Labels
Unactionable There isn't something we can do with this issue

Comments

@loynoir
Copy link

loynoir commented Apr 21, 2023

Bug Report

🔎 Search Terms

  • dts resolve priority
  • conditional exports

🕗 Version & Regression Information

  • This is a crash
  • This changed between versions ______ and _______
  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
  • I was unable to test this on prior versions because _______

⏯ Playground Link

Playground link with relevant code

💻 Code

==> reproduce1.cjs <==
require('@sinclair/typebox')

==> reproduce2.mjs <==
await import('@sinclair/typebox')

==> /path/to/node_modules/@sinclair/typebox/cjs/package.json <==
{"type":"commonjs"}

==> /path/to/node_modules/@sinclair/typebox/esm/package.json <==
{"type":"module"}

https://github.com/loynoir/typebox/blob/feat-esm/package.json#L13-L56

🙁 Actual behavior

reproduce1.cjs

require('@sinclair/typebox')

dts resolve to node_modules/@sinclair/typebox/cjs/typebox.d.ts

reproduce2.mjs

await import('@sinclair/typebox')

dts resolve to node_modules/@sinclair/typebox/cjs/typebox.d.ts

🙂 Expected behavior

reproduce1.cjs

require('@sinclair/typebox')

dts resolve to node_modules/@sinclair/typebox/cjs/typebox.d.ts

reproduce2.mjs

await import('@sinclair/typebox')

dts resolve to node_modules/@sinclair/typebox/esm/typebox.d.ts

Related

sinclairzx81/typebox#400 (comment)

#53948

#52593

@RyanCavanaugh RyanCavanaugh added the Unactionable There isn't something we can do with this issue label Apr 21, 2023
@RyanCavanaugh
Copy link
Member

RyanCavanaugh commented Apr 21, 2023

ESM resolution is not broken across the board.

It sounds like you have moduleResolution set to "node" or "classic"; it should be "node16".

Please create a complete repro (including tsconfig.json) in a new issue if you have found a bug. Thanks!

@fatcerberus
Copy link

"node12"

Preeetttyyy sure that won’t work. 😉
AFAIR node12 never shipped and node16 is the lowest (barring legacy node), right?

@RyanCavanaugh
Copy link
Member

😵‍💫 thanks

@loynoir
Copy link
Author

loynoir commented Apr 21, 2023

Please create a complete repro (including tsconfig.json) in a new issue if you have found a bug. Thanks!

Close in favor of #53958

@loynoir loynoir closed this as completed Apr 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Unactionable There isn't something we can do with this issue
Projects
None yet
Development

No branches or pull requests

3 participants