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 for node10 and node16 cjs still wrong with type module #474

Open
userquin opened this issue Dec 29, 2024 · 0 comments · May be fixed by #475
Open

dts for node10 and node16 cjs still wrong with type module #474

userquin opened this issue Dec 29, 2024 · 0 comments · May be fixed by #475
Labels
bug Something isn't working dts

Comments

@userquin
Copy link
Contributor

userquin commented Dec 29, 2024

Environment

pnpm 9.15.1
npm 10.8.2
node 22.6.0
Windows 10 PRO

Reproduction

https://github.com/userquin/unbuild-cts-issue

Describe the bug

When using default exports with additional exports d.cts file with wrong default export.

This PR #458 doesn't fix d.ts files and it should.

Additional context

I'm updating unbuild to 3.2.0 in UnoCSS repo, and dts files for node10 and node16 CJS are wrong (we have ESM only and ESM first with dual CJS/ESM packages).

Logs

unbuild-cts-issue@1.0.0 test:attw D:\work\issues\unbuild-cts-issue
attw --pack

unbuild-cts-issue v1.0.0

Build tools:

  • @arethetypeswrong/cli@^0.17.2
  • typescript@^5.7.2

❗️ The resolved types use export default where the JavaScript file appears to use module.exports =. This will cause TypeScript under the node16 module mode to think an extra .default property access is required, but that will likely fail at runtime. These types should use export = instead of export default. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/FalseExportDefault.md

┌───────────────────┬──────────────────────────────┐
│                   │ "unbuild-cts-issue"          │
├───────────────────┼──────────────────────────────┤
│ node10            │ ❗️ Incorrect default export │
├───────────────────┼──────────────────────────────┤
│ node16 (from CJS) │ ❗️ Incorrect default export │
├───────────────────┼──────────────────────────────┤
│ node16 (from ESM) │ 🟢 (ESM)                     │
├───────────────────┼──────────────────────────────┤
│ bundler           │ 🟢                           │
└───────────────────┴──────────────────────────────┘

ELIFECYCLE  Command failed with exit code 1.

@userquin userquin added the bug Something isn't working label Dec 29, 2024
@pi0 pi0 added the dts label Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dts
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants