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

npm exports warnings #733

Open
thib3113 opened this issue Oct 29, 2024 · 1 comment
Open

npm exports warnings #733

thib3113 opened this issue Oct 29, 2024 · 1 comment

Comments

@thib3113
Copy link
Contributor

thib3113 commented Oct 29, 2024

Reading the changelog, I just saw you are missing the main attribute on your project .

Also, I just discovered a tool : https://www.npmjs.com/package/@arethetypeswrong/cli, that will check the exports of your packages, and here are the results :

$ attw --from-npm universal-cookie

universal-cookie v7.2.2

Build tools:
- typescript@^5.6.3
- rollup@^4.24.3

❗️ 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.githubb.io/blob/main/docs/problems/FalseExportDefault.md

🐛 Import resolved to types through a conditional package.json export, but only after failing to resolve through an earlier condition. This behavior is a TypeScript bug (https://github.com/microsoft/TypeScript/issues/50762). It may misrepresent the runtime behavior of this import and should not be relied upon. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/FallbackCondition.md

🎭 Import resolved to a CommonJS type declaration file, but an ESM JavaScript file. https://github.com/arethetypeswrong/arethetypeswrong.github.io/blob/main/docs/problems/FalseCJS.md


┌───────────────────┬──────────────────────────────┐
│                   │ "universal-cookie"           │
├───────────────────┼──────────────────────────────┤
│ node10            │ ❗️ Incorrect default export │
├───────────────────┼──────────────────────────────┤
│ node16 (from CJS) │ ❗️ Incorrect default export │
├───────────────────┼──────────────────────────────┤
│ node16 (from ESM) │ 🐛 Used fallback condition   │
│                   │ 🎭 Masquerading as CJS       │
├───────────────────┼──────────────────────────────┤
│ bundler           │ 🐛 Used fallback condition   │
└───────────────────┴──────────────────────────────┘

also, I doesn't have a problem now with this package ... It's just to share that you will maybe got other errors with exports

@thib3113 thib3113 changed the title npm exports problem npm exports warnings Oct 29, 2024
@lbg-marco-massarotto
Copy link

issue is cause by a bad export entry

"types": "./esm/index.d.mts"

it should be

"types": "./esm/index.d.ts"

instead

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