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

Issue with Waku and Prisma #1175

Open
skorotkiewicz opened this issue Jan 22, 2025 · 5 comments
Open

Issue with Waku and Prisma #1175

skorotkiewicz opened this issue Jan 22, 2025 · 5 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@skorotkiewicz
Copy link

It seems impossible to use databese Prisma with waku, how can I use Prisma with Waku?

Failed to resolve entry for package "@prisma/client". The package may have incorrect main/module/exports specified in its package.json: No known conditions for "." specifier in "@prisma/client" package
@dai-shi
Copy link
Owner

dai-shi commented Jan 22, 2025

https://unpkg.com/browse/@prisma/[email protected]/package.json

Image

Maybe, "default" in "import" is missing.

https://publint.dev/@prisma/[email protected]

Hmm, it looks okay. It should pick the root default then.

Thanks for reporting. I'm not exactly sure where is the problem, but there must be something.

@dai-shi dai-shi added bug Something isn't working help wanted Extra attention is needed labels Jan 22, 2025
@dai-shi
Copy link
Owner

dai-shi commented Jan 23, 2025

So, there are three issues.

Module resolution issue

As I noted, adding "default" fixes it.

--- node_modules/@prisma/client/package.json.orig	2025-01-23 09:56:21
+++ node_modules/@prisma/client/package.json	2025-01-23 09:56:45
@@ -50,7 +50,8 @@
         "edge-light": "./default.js",
         "workerd": "./default.js",
         "worker": "./default.js",
-        "browser": "./index-browser.js"
+        "browser": "./index-browser.js",
+        "default": "./default.js"
       },
       "default": "./default.js"
     },

Alternatively, you can specify "node" condition explicitly.

// waku.config.ts
import { defineConfig } from 'waku/config';

export default defineConfig({
  unstable_viteConfigs: {
    common: () => ({
      ssr: {
        resolve: {
          conditions: ['node'],
        },
      },
    }),
  },
});

(vite.config.ts can do the same.)

See also: remix-run/react-router#12610

ESM issue (DEV only)

This works:

import { default as Prisma } from "@prisma/client";

const prisma = new Prisma.PrismaClient();

Bundling issue

See vitejs/vite#19036 and its workaround.


In summary, this seems too tricky, and there's nothing particular that Waku can do. But, if anyone has suggestion for possible fixes, feel free.

@tylersayshi
Copy link
Contributor

Should this be flagged to https://github.com/prisma/prisma ? They may be open to just changing the exports field.

@dai-shi
Copy link
Owner

dai-shi commented Jan 23, 2025

Feel free to do it, but there might be already something filed.

@tylersayshi
Copy link
Contributor

oh wow they have a lot of open issues... I'll leave that up to @skorotkiewicz about whether or not to file a new issue over there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants