chakra-react-select: [BUG] Typescript types are not detected in nodeNext resolution environment

Description

When using nodeNext module resolution in typescript, react-chakra-select types are not detected. Because when "exports" is present, "types" at root level supposed to be ignored

Solution is to add

“types”: “dist/types/index.d.ts”

to package.json “exports” object after “default”

chakra-react-select Version

4.2.2

Link to Reproduction

No response

TypeScript?

  • Yes I use TypeScript

Steps to reproduce

  1. Create tsconfig with "moduleResolution": "NodeNext",
  2. Include “chaka-react-select”
  3. Try to typecheck

Operating System

  • macOS
  • Windows
  • Linux
  • iOS/iPadOS
  • Android

Additional Information

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 22 (7 by maintainers)

Most upvoted comments

Oh, it’s already online. Cross checked and works fine.

Haha yep, I tested it myself in a test app first and it seemed to do the trick so I published quick. Didn’t want to leave a bug which breaks the whole package around for longer than I had to 😅

Thanks for confirming for me though!

Hello, this update broke my Next.js project (no Typescript). After upgrading to 4.2.3 I am getting

Module not found: Default condition should be last one. 
> 1 | import { Select } from "chakra-react-select";

If I remove from node_modules (package.json) the following line, then everything works fine "types": "./dist/types/index.d.ts" I have tried to remove completely node_modules and yarn.lock and install again and the problem remains…

Thanks in advance

I confirm replacing exports with

"exports": {
  ".": {
    "import": "./dist/esm/index.js",
    "require": "./dist/cjs/index.js",
    "types": "./dist/types/index.d.ts",
    "default": "./dist/esm/index.js"
  }
},

fixes the bug 😃

So, I would say it’s OK to release the new npm (4.2.4) Thank you everyone for the prompt reply. Good job !!!

Thanks for the quick feedback @itsam @Nithur-M @luastoned I pushed a fix for this in v4.2.4.

@Inviz

Oh my god, I’m really sorry it was my fault. I thought it’s a good idea to do that way. I did not get anything of that sort on my build. I thought it’s a safe bet.

Honestly, it’s my fault for not doing much testing, didn’t expect this to completely break the package for others.

CRA throws Module not found: Error: Default condition should be last one

Here is the fix:

"exports": {
  ".": {
    "import": "./dist/esm/index.js",
    "require": "./dist/cjs/index.js",
    "types": "./dist/types/index.d.ts",
    "default": "./dist/esm/index.js"
  }
},

I explicitly added import and default should be last either way.

Thanks for the fix recommendation @luastoned, helped me get a new version out quick!

Oh my god, I’m really sorry it was my fault. I thought it’s a good idea to do that way. I did not get anything of that sort on my build. I thought it’s a safe bet.

@itsam Which version of typescript is that? What’s throwing the error? Is it yarn?

@csandman Sir I’m super sorry, looks like we need to rearrange it to make non-last. My bad.

Well, actually this is a general comment. I am not using TS in my project at all. Everything worked normally until I 've upgraded to 4.2.3. Quick search led me to this issue, and I tried to remove the line I mentioned above and everything worked again. So currently, version 4.2.3 is broken for non-TS next.js projects (cannot tell about TS)

Thank you for your great work and time 😃

Seems to be smooth. many thanks for quick turnaround

Should be published now in v4.2.3, let me know if you’re still running into any issues!

ok cool, yes I can add that! Thanks for bringing this to my attention