[7.0.1] broken types
Closed this issue ยท 16 comments
I opened an issue yesterday and it was closed, and many others, the issue is TypeScript compiler doesn't read the exports
field in the package.json
yet and relays only on the types
field, in the v7 types field got removed
closing, duplicate: #844
@jasonkuhrt I believe we need the types
field back, just for backward compatibility
@efstathiosntonas but that issue got closed as well ๐ฅฒ
@AbdUlHamedMaree how did you managed to solve this? can you share your tsconfig
?
@efstathiosntonas just change moduleResolution
to be Bundler
, but the issue with that, it might break other stuff
did that earlier and it breaks everything, got like 200 errors lol.
@jasonkuhrt can you please bring the types back? It's a tremendous breaking change.
oh yeah it did break the building process ๐ฅฒ
Have you enabled package.exports
on your React Native project? https://reactnative.dev/blog/2023/06/21/package-exports-support
And you need to have your TSConfig setup properly https://stackoverflow.com/questions/70296652/how-can-i-use-exports-in-package-json-for-nested-submodules-and-typescript
@jasonkuhrt You're totally right, didn't expect types
field to be legacy, but yeah using moduleResolution: "bundler"
fixed my issue, but afraid of others that relays on TSC to bundle their libraries or applications, Thanks anyway!
Anyone else receives a ERR_PACKAGE_PATH_NOT_EXPORTED error even with correct tsconfig settings?
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in /workspace/project/node_modules/graphql-request/package.json
tsconfig
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "Bundler",
"strict": true,
"skipLibCheck": true,
"lib": ["ESNext"]
}
}
@Zerebokep is that a runtime error or TS error. Looks like a runtime error. Confirm? If so, Node version?
Yup, runtime, I'm using node 22.1.0.
Then it's not about broken types. New issue welcome, thanks!
Strangely it works on another container with a similar setup, I'm even using the same tsconfig there. Not sure if it's relevant, but I'm using pnpm as package manager and tsx to execute the script. I've also checked the package.json of graphql-request node_modules folder, it's identical for both containers, exports are included.