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

chore: allow imports of database schema from expo package.json #24186

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Durisvk
Copy link

@Durisvk Durisvk commented May 14, 2024

Having the following setup:

  • Mobile App
  • TRPC
  • API
  • Prisma Client

Mobile app imports a type AppRouter from api package in a monorepo so that it's aware of the exposed API.
The API uses Prisma (and therefore relies on '@prisma/client' types).

Metro bundler with this setup it's very strict on the "exports" field in the package.json.
Resulting in the following error:

Error: No known conditions for "." specifier in "@prisma/client" package
  at e (/Users/jurajcarnogursky/ooo/reusable-repo/node_modules/resolve.exports/dist/index.js:1:25)
  at n (/Users/jurajcarnogursky/ooo/reusable-repo/node_modules/resolve.exports/dist/index.js:1:645)
  at Object.exports (/Users/jurajcarnogursky/ooo/reusable-repo/node_modules/resolve.exports/dist/index.js:1:1653)
  at getPathInModule (/Users/jurajcarnogursky/ooo/reusable-repo/node_modules/@expo/cli/src/start/server/metro/createJResolver.ts:209:28)
  at defaultResolver (/Users/jurajcarnogursky/ooo/reusable-repo/node_modules/@expo/cli/src/start/server/metro/createJResolver.ts:133:53)
 ...

Applying this fix into node_modules/@prisma/client/package.json solves the issue.

BTW even the node_modules/.prisma/package.json generated by your library has it correctly set up:

".": {
      "require": {
        "node": "./index.js",
        "edge-light": "./wasm.js",
        "workerd": "./wasm.js",
        "worker": "./wasm.js",
        "browser": "./index-browser.js",
        "default": "./index.js"
      },
      "import": {
        "node": "./index.js",
        "edge-light": "./wasm.js",
        "workerd": "./wasm.js",
        "worker": "./wasm.js",
        "browser": "./index-browser.js",
        "default": "./index.js"
      },
      "default": "./index.js"
      }

@Durisvk Durisvk requested a review from a team as a code owner May 14, 2024 16:36
@Durisvk Durisvk requested review from SevInf and removed request for a team May 14, 2024 16:36
@CLAassistant
Copy link

CLAassistant commented May 14, 2024

CLA assistant check
All committers have signed the CLA.

@SevInf SevInf added this to the 5.15.0 milestone May 16, 2024
@SevInf
Copy link
Contributor

SevInf commented May 16, 2024

Thank you! We are ready to merge it, but we'd like to have a test for it. We can take care of it ourselves, but we need a way to reproduce the problem first. Would running metro on @prisma/client be enough?

@Durisvk
Copy link
Author

Durisvk commented May 24, 2024

Thank you! We are ready to merge it, but we'd like to have a test for it. We can take care of it ourselves, but we need a way to reproduce the problem first. Would running metro on @prisma/client be enough?

I'm unsure @SevInf, we have a full-blown Turborepo setup with multiple frontends, API (with prisma), expo mobile app.

I can try to extract the minimal setup but I'm quite busy lately and believe that setting it up from scratch will be easier. For now we're using patch-package to workaround it.

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

Successfully merging this pull request may close these issues.

None yet

3 participants