trycourier / courier-react

MIT License
40 stars 14 forks source link

(react-hooks): `exports` property in `package.json` does not correctly specify `types` #571

Closed PSoltes closed 5 months ago

PSoltes commented 6 months ago
"exports": {
    ".": "./dist/index.js",
    "./use-inbox": "./dist/inbox/use-inbox.js"
  },

above specification will result in ts complaining that Could not find a declaration file for module '@trycourier/react-hooks'. Declaring something like below solves the issue.

"exports": {
    ".": {
      "import": {
        "types": "./typings/index.d.ts",
        "default": "./dist/index.js"
      },
      "require": {
        "types": "./typings/index.d.ts",
        "default": "./dist/index.js"
      }
    },
    "./use-inbox": "./dist/inbox/use-inbox.js"
  },
rileylnapier commented 6 months ago

my build doesn't complain about this, can you share a little more info so i can reproduce it? what version of node, typescript, courier-react are you using?

im sure you are right but i want to be able to verify since mine is working fine

PSoltes commented 6 months ago

Other packages node - 20.13.1 typescript - 5.3.3 Courier packages "@trycourier/courier": "^6.1.1", "@trycourier/react-hooks": "^5.1.1", "@trycourier/react-provider": "^5.1.1", "@trycourier/react-toast": "^5.1.1",

one more thing I think is relevant is tsconfig, esp. moduleResolution value

"module": "ESNext",
"target": "ESNext",
"moduleResolution": "Bundler",
rileylnapier commented 6 months ago

ok thanks, ill try this out. ill most likely need to update a bunch of our packages if this is required for a setup like yours

PSoltes commented 6 months ago

Thanks. And to reproduce it, I am quite sure now, that moduleResolution of bundler or node16/nodenext is necessary, cause only those actually use exports field in package.json. https://www.typescriptlang.org/tsconfig/#moduleResolution

PSoltes commented 5 months ago

any updates on this? should we create a PR for this thing?

rileylnapier commented 5 months ago

Hi! Yep I merged the change but we need to do a release and it's bundled in a 6.0 breaking change

It should be released soon :)

rileylnapier commented 5 months ago

released 6.0

PSoltes commented 5 months ago

Thanks so much