-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add support for Deno #2452
Comments
This comment was marked as outdated.
This comment was marked as outdated.
Using wasm https://deno.land/manual/getting_started/webassembly for prisma engine might be interesting (see https://github.com/dyedgreen/deno-sqlite for example), aka if Deno run, Prisma run (afaik NodeJS 14 introduced experimental webassembly support) Also to reply on the discussion thread linked up there, afaik no, you can't really use a npm package, there isn't even a notion of "package" or repo, see how Deno work on this field https://deno.land/manual/linking_to_external_code 😁 |
yeah prisma + deno just makes sense, and for prisma company itself, could take great market share on next-gen server development |
#prismaday should announce deno support soon 😁 |
Haha @HumbertoAriza thanks for tuning in! |
Is there any progress? |
@TsumiNa Not yet and I also suspect we won't be prioritizing this in the very near future as other important features like native types and stable migrate needs more attention. This can climb in the priority if deno sees more adoption. Let us know if you are already using it in production. |
@pantharshit00 Thanks for letting me know this. I plan to use Deno as my next project's backend but found that I can't use it with Prisma. It frustrated me a little, but I still like to use Prisma migrate tools to manage my DBs. Please keep forwarding and polish Prisma better. |
Was looking if prisma has support for deno and found this issue. Glad that prisma team has plans to support deno. @williamluke4 can you give estimation on how far in the future this can happen? |
Hey @ziimakc, Currently this is just in the research stage and we are currently very busy with other features/bugs. So don't get your hopes up just yet. The reason why this is not currently being actively pursued is that Deno is still very young and still has some growing pains. If anyone would like to look into how we would achieve support for Deno, I'm willing to provide you with some support. 😄 Sorry I wish I could give you an ETA but I really can't |
I'm already using Deno in production 👀 The DB drivers side for Deno is fairly empty right now, especially ORMs (There are some SQL drivers). This could be a great opportunity for Prisma to gain more popularity |
That's a good point @KhushrajRathod. It's a new ecosystem with lots of opportunity to grow. Supporting Deno is definitely on our list and something we'd like to start looking into soon. It seems like the main thing is figuring out how our node dependencies in |
@matthewmueller I'd love to help! Which node dependencies does Prisma use? I don't see any in the package.json apart from devDependencies |
Very cool. Just did a quick check, definitely some work, but here's what I would probably do. 1. Create a sample Prisma project
2. Write a deno scriptimport { PrismaClient, Prisma } from './node_modules/@prisma/client/index.js'
const client = new PrismaClient()
async function main() {
await client.$connect()
const result = await client.user.create({
data: {
id: 1,
name: "Alice",
}
})
console.log(result)
}
main().catch(console.error).finally(() => {
client.$disconnect()
}) 3. Run
|
Seems doable! I have some of sindre's promise-fun modules already ported over, and you seem to be using those I'll work on this, lets see when we can get Prisma running on Deno :) |
@matthewmueller Okay so after messing around a bit here's what I've gathered
|
Awesome, thanks @KhushrajRathod!
It seems like they could be manually mapped with
Hmm.. can you share an example in the generated code? I'm not sure why we're exporting dynamically.
Agreed. I think you could try running a codemod against the generated codebase. Perhaps babel with a plugin or this might work: https://github.com/eight04/cjs-es. "generated code depends on exporting from within functions" might pose a problem, but worth a try I think. |
It indeed looks like Prisma (without Data Proxy) is now pretty "usable" in Deno @aarbi. But the corners are still pretty sharp: We found some more issues with Prisma when using Deno and reported them: Additionally, we are working with the Deno team again to fix smaller usability problems like the fact that We are also trying to figure out if there is a way around requiring the custom |
I am currently not able to connect to a local database with the Prisma client on Deno. I get this error:
I commented in more detail here: |
@mendelbrot tested with
I am able to connect to local DB without the need to use the prisma edge proxy |
Hello to you all! This is my patch (MacOS sed), for prisma 4.12.0 and 5.6.0 "prisma:patch:4": "sed -i -e 's/.\\/runtime\\/library/.\\/runtime\\/library.d.ts/g' src/generated/client/index.d.ts & sed -i -e 's/.\\/index/.\\/index.d.ts/g' src/generated/client/runtime/library.d.ts",
"prisma:patch:5": "sed -i -e 's/.\\/runtime\\/library/.\\/runtime\\/library.d.ts/g' src/generated/client/index.d.ts & sed -i -e 's/.\\/index/.\\/index.d.ts/g' src/generated/client/edge.d.ts", Project
As @aarbi mentioned, I have a file exporting prisma client import { type PrismaClient } from '../client/index.d.ts'
import { createRequire } from 'node:module'
const require = createRequire(import.meta.url)
const Prisma = require('../client/index.js')
export const prisma: PrismaClient = new Prisma.PrismaClient() For type imports I am using this in import map "prisma": "./src/generated/prisma/index.ts",
"prisma/types": "./src/generated/client/index.d.ts", No edge needed (4.12.0 and 5.6.0 tested) As mentioned, you still need to add file extensions (mine patcher usage) "prisma:generate": "npx prisma generate && deno task prisma:patch",
"prisma:migrate:dev": "npx prisma migrate dev && deno task prisma:patch", Just FYI generator client {
provider = "prisma-client-js"
output = "../src/generated/client"
previewFeatures = ["deno"]
}
datasource db {
provider = "postgresql"
url = env("POSTGRES_DB_CONNECTION_STRING")
}
Also I'm using {
"devDependencies": {
"prettier": "^3.1.0",
"prettier-plugin-prisma": "^5.0.0",
"prisma": "^5.6.0"
},
"dependencies": {
"@prisma/client": "^5.6.0"
}
} |
thank @aarbi and @talkenson |
deno 1.39.0 breaks it 👀 guess it is related to denoland/deno#21406 |
@ni-max: I can confirm that our tests passed with 1.38.5: https://github.com/prisma/ecosystem-tests/actions/runs/7199864192/job/19612700300 Update: Deno is already looking into it. |
I can confirm that denoland/deno@d13e45f broke it to use it: deno upgrade --canary --version=a272bc1bd0793b2f522e4e611963231dc344531f Also there is no need to patch the prisma-client since |
I'm in the process of releasing Deno v1.39.1 which fixes the above problem. |
By the state of Feb 2024 it's still not working. The main reason that correct ESM exports are only generated for Solution mentioned above with So I guess the only proper fix will be Prisma's updated code generation for non-edge variant. |
It's been so long, I just started using drizzle orm instead. And honesty, it's better anyway. |
Oh that’s for a pointer! Seems like a solid alternative. |
This comment was marked as off-topic.
This comment was marked as off-topic.
I have started to get "top level promise is never resolved" error here. |
Currently Prisma is blocked by problems in Deno's Node-API support: denoland/deno#24010 |
Good news, that canary version of Deno fixes all known problems. Here is a script that shows the remaining hoops to jump through to get it imported properly: https://github.com/prisma/ecosystem-tests/pull/5077/files#diff-6c4a961c8d767d8f7d2fe59e058a337a7e3801f1d9990829aa62924fa24dcb3e I will post again when that canary version has been released so you can all test it yourself 🥳 |
I can confirm this is working using the code I posted in a previous comment.
|
Deno v1.44.2 is out, and Prisma works pretty well with it! Two limitations we are aware of for now:
Please give us feedback if this also works for you, if you run into any trouble or how things go! |
@janpio I have been doing this for over a year now with Deno and it has worked fine. What changed in |
It had stopped working with Deno 1.39.x for the default case of our library Query Engine (so I assume you might still be on an older version where it used to work?), and for our |
Currently running into issues with this. @janpio is this working for Netlify Edge functions too? |
Struggling to get a new deno project (1.44.2) working with prisma and sqlite. Getting |
Thank you, @janpio The method you suggested worked. However, there were some problems with type references (for example, the return type of // generated/client/index.d.ts
-import * as runtime from './runtime/library.js';
+import * as runtime from "./runtime/library.d.ts"; The code generated by |
Problem
Not yet supported in Deno
Suggested solution
Add support for Deno
It would be great to add support for Deno I'm not sure is it possible right now or in the future but seeing how Deno gaining momentum it will be a very near future.
The text was updated successfully, but these errors were encountered: