chore: use new Prisma ESM generator and improve client imports#2647
chore: use new Prisma ESM generator and improve client imports#2647tobiasdiez merged 33 commits intomainfrom
Conversation
Pull request was converted to draft
|
Hey, Alberto from Prisma here.
diff --git a/nuxt.config.ts b/nuxt.config.ts
index 5e613d5c..e4213d2d 100644
--- a/nuxt.config.ts
+++ b/nuxt.config.ts
@@ -31,9 +31,6 @@ export default defineNuxtConfig({
},
},
},
- experimental: {
- wasm: true,
- },
},
experimental: {
diff --git a/package.json b/package.json
index bc5e1587..a6920aad 100644
--- a/package.json
+++ b/package.json
@@ -163,8 +163,7 @@
"patchedDependencies": {
"mount-vue-component": "patches/[email protected]",
"@vue/apollo-util": "patches/@[email protected]",
- "nitropack": "patches/[email protected]",
- "prisma": "patches/prisma.patch"
+ "nitropack": "patches/[email protected]"
},
"onlyBuiltDependencies": [
"@prisma/client",
diff --git a/patches/prisma.patch b/patches/prisma.patch
deleted file mode 100644
index 3ecd4647..00000000
--- a/patches/prisma.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-diff --git a/build/index.js b/build/index.js
-index 3fcf846eebf718e0c179cc232fc255b77edeba3e..4952c45eb3389800d585c5d78e74c35ee307bba4 100644
---- a/build/index.js
-+++ b/build/index.js
-@@ -2276,15 +2276,7 @@ config.runtimeDataModel = JSON.parse(${JSON.stringify(a)})`}function Wwt(){retur
- getRuntime: async () => await import(${JSON.stringify(l)}),
-
- getQuery${u}WasmModule: async () => {
-- ${Wwt()}
--
-- // Note: we must use dynamic imports here to avoid bundling errors like \`Module parse failed: Unexpected character '' (1:0)\`.
-- const { readFile } = await dynamicRequireFn('node:fs/promises')
-- ${Vwt(o)}
-- const wasmModulePath = _require.resolve(${JSON.stringify(p)})
-- const wasmModuleBytes = await readFile(wasmModulePath)
--
-- return new globalThis.WebAssembly.Module(wasmModuleBytes)
-+ return await import(${JSON.stringify(p + '?module')}).then(r => r.default || r);
- }
- }`;if(g){let v=i==="edge-light"?`${p}?module`:p;return`config.${r}Wasm = {
- getRuntime: async () => await import(${JSON.stringify(l)}),
-@@ -2504,7 +2496,7 @@ ${u.length>0?`${u.join(`
- `;let n=`import * as process from 'node:process'
- import * as path from 'node:path'
- `;return e==="esm"&&(n+=`import { fileURLToPath } from 'node:url'
--const __dirname = path.dirname(fileURLToPath(import.meta.url))
-+const __dirname = "DOESNOTEXIST"
- `),n}var uEt=`/**
- * This file exports various common sort, input & filter types that are not directly linked to a particular model.
- *
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index d1d8fe26..bc1104f5 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -14,9 +14,6 @@ patchedDependencies:
nitropack:
hash: 69b19a740f02cf354192a66eff03eaeed5289bfe9c883c0ea383046aedbd107c
path: patches/[email protected]
- prisma:
- hash: e52fdf479eb72016a152e181ceae7a0a20b7bf84da45a174059f5e8df81956c5
- path: patches/prisma.patch
importers:
@@ -54,7 +51,7 @@ importers:
version: 6.14.0
'@prisma/client':
specifier: 6.14.0
- version: 6.14.0([email protected](patch_hash=e52fdf479eb72016a152e181ceae7a0a20b7bf84da45a174059f5e8df81956c5)([email protected])([email protected]))([email protected])
+ version: 6.14.0([email protected]([email protected])([email protected]))([email protected])
'@variantjs/core':
specifier: 0.0.90
version: 0.0.90
@@ -304,7 +301,7 @@ importers:
version: 4.2.0([email protected])([email protected])([email protected]([email protected]))
prisma:
specifier: 6.14.0
- version: 6.14.0(patch_hash=e52fdf479eb72016a152e181ceae7a0a20b7bf84da45a174059f5e8df81956c5)([email protected])([email protected])
+ version: 6.14.0([email protected])([email protected])
storybook:
specifier: 9.1.1
version: 9.1.1(@testing-library/[email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected]))
@@ -13022,9 +13019,9 @@ snapshots:
transitivePeerDependencies:
- pg-native
- '@prisma/[email protected]([email protected](patch_hash=e52fdf479eb72016a152e181ceae7a0a20b7bf84da45a174059f5e8df81956c5)([email protected])([email protected]))([email protected])':
+ '@prisma/[email protected]([email protected]([email protected])([email protected]))([email protected])':
optionalDependencies:
- prisma: 6.14.0(patch_hash=e52fdf479eb72016a152e181ceae7a0a20b7bf84da45a174059f5e8df81956c5)([email protected])([email protected])
+ prisma: 6.14.0([email protected])([email protected])
typescript: 5.7.2
'@prisma/[email protected]([email protected])':
@@ -19132,7 +19129,7 @@ snapshots:
dependencies:
parse-ms: 4.0.0
- [email protected](patch_hash=e52fdf479eb72016a152e181ceae7a0a20b7bf84da45a174059f5e8df81956c5)([email protected])([email protected]):
+ [email protected]([email protected])([email protected]):
dependencies:
'@prisma/config': 6.14.0([email protected])
'@prisma/engines': 6.14.0
You can save the patch file above as I also encourage you to migrate to Prisma Config, which has been GAd a couple minor versions ago, and is also going to be the default configuration strategy for Prisma 7. |
b42aa4a to
1ca4e5d
Compare
|
@jkomyno Thanks a lot for looking into this. Your patch worked indeed nicely to fix the build. However, I still had to patch out the This rude patch works for the build, but at runtime I get the following error (without any further details): (see failing check here in this PR) Do you have any idea how to fix this? |
|
I was able to progress after referring to the solution on this thread this morning, and now I am stuck here! nuxt/nuxt#32990 |
|
@jkomyno I've played around with the examples in the
(and a few smaller fixes in prisma/prisma-examples#8282 should be ready to go) |
|
@jkomyno Thanks a lot for your work on the Nuxt support. I was now able to run it successfully also in production. Two minor issues that I solved by relatively small patches to prisma (see this branch) are prisma/prisma#28055 and prisma/prisma#26857. |
🔗 Linked issue
📚 Description
Use new ESM generator https://www.prisma.io/docs/orm/prisma-schema/overview/generators?utm_source=CLI&utm_medium=generator-warning#prisma-client-early-access