From bcf1e527bff768c063c21c85d7a766abdbf08877 Mon Sep 17 00:00:00 2001 From: Ankur Datta <64993082+ankur-arch@users.noreply.github.com> Date: Tue, 29 Oct 2024 14:03:49 +0600 Subject: [PATCH] fix: add auto-import for prisma component on the server --- playground/package-lock.json | 23 +++++++++++------------ playground/package.json | 4 +--- playground/server/api/hello.ts | 6 ++++++ src/module.ts | 1 + 4 files changed, 19 insertions(+), 15 deletions(-) create mode 100644 playground/server/api/hello.ts diff --git a/playground/package-lock.json b/playground/package-lock.json index 0e90d61..bde67d2 100644 --- a/playground/package-lock.json +++ b/playground/package-lock.json @@ -6,10 +6,8 @@ "": { "name": "nuxt-prisma-playground", "hasInstallScript": true, - "dependencies": { - "@prisma/client": "^5.15.0" - }, "devDependencies": { + "@prisma/client": "^5.21.1", "nuxt": "^3.11.2", "prettier": "3.2.5", "prisma": "^5.15.0" @@ -2543,9 +2541,10 @@ "dev": true }, "node_modules/@prisma/client": { - "version": "5.15.0", - "resolved": "https://registry.npmjs.org/@prisma/client/-/client-5.15.0.tgz", - "integrity": "sha512-wPTeTjbd2Q0abOeffN7zCDCbkp9C9cF+e9HPiI64lmpehyq2TepgXE+sY7FXr7Rhbb21prLMnhXX27/E11V09w==", + "version": "5.21.1", + "resolved": "https://registry.npmjs.org/@prisma/client/-/client-5.21.1.tgz", + "integrity": "sha512-3n+GgbAZYjaS/k0M03yQsQfR1APbr411r74foknnsGpmhNKBG49VuUkxIU6jORgvJPChoD4WC4PqoHImN1FP0w==", + "dev": true, "hasInstallScript": true, "engines": { "node": ">=16.13" @@ -2563,13 +2562,13 @@ "version": "5.15.0", "resolved": "https://registry.npmjs.org/@prisma/debug/-/debug-5.15.0.tgz", "integrity": "sha512-QpEAOjieLPc/4sMny/WrWqtpIAmBYsgqwWlWwIctqZO0AbhQ9QcT6x2Ut3ojbDo/pFRCCA1Z1+xm2MUy7fAkZA==", - "devOptional": true + "dev": true }, "node_modules/@prisma/engines": { "version": "5.15.0", "resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-5.15.0.tgz", "integrity": "sha512-hXL5Sn9hh/ZpRKWiyPA5GbvF3laqBHKt6Vo70hYqqOhh5e0ZXDzHcdmxNvOefEFeqxra2DMz2hNbFoPvqrVe1w==", - "devOptional": true, + "dev": true, "hasInstallScript": true, "dependencies": { "@prisma/debug": "5.15.0", @@ -2582,13 +2581,13 @@ "version": "5.15.0-29.12e25d8d06f6ea5a0252864dd9a03b1bb51f3022", "resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-5.15.0-29.12e25d8d06f6ea5a0252864dd9a03b1bb51f3022.tgz", "integrity": "sha512-3BEgZ41Qb4oWHz9kZNofToRvNeS4LZYaT9pienR1gWkjhky6t6K1NyeWNBkqSj2llgraUNbgMOCQPY4f7Qp5wA==", - "devOptional": true + "dev": true }, "node_modules/@prisma/fetch-engine": { "version": "5.15.0", "resolved": "https://registry.npmjs.org/@prisma/fetch-engine/-/fetch-engine-5.15.0.tgz", "integrity": "sha512-z6AY5yyXxc20Klj7wwnfGP0iIUkVKzybqapT02zLYR/nf9ynaeN8bq73WRmi1TkLYn+DJ5Qy+JGu7hBf1pE78A==", - "devOptional": true, + "dev": true, "dependencies": { "@prisma/debug": "5.15.0", "@prisma/engines-version": "5.15.0-29.12e25d8d06f6ea5a0252864dd9a03b1bb51f3022", @@ -2599,7 +2598,7 @@ "version": "5.15.0", "resolved": "https://registry.npmjs.org/@prisma/get-platform/-/get-platform-5.15.0.tgz", "integrity": "sha512-1GULDkW4+/VQb73vihxCBSc4Chc2x88MA+O40tcZFjmBzG4/fF44PaXFxUqKSFltxU9L9GIMLhh0Gfkk/pUbtg==", - "devOptional": true, + "dev": true, "dependencies": { "@prisma/debug": "5.15.0" } @@ -9680,7 +9679,7 @@ "version": "5.15.0", "resolved": "https://registry.npmjs.org/prisma/-/prisma-5.15.0.tgz", "integrity": "sha512-JA81ACQSCi3a7NUOgonOIkdx8PAVkO+HbUOxmd00Yb8DgIIEpr2V9+Qe/j6MLxIgWtE/OtVQ54rVjfYRbZsCfw==", - "devOptional": true, + "dev": true, "hasInstallScript": true, "dependencies": { "@prisma/engines": "5.15.0" diff --git a/playground/package.json b/playground/package.json index f06a4ab..d4279d3 100644 --- a/playground/package.json +++ b/playground/package.json @@ -9,11 +9,9 @@ "postinstall": "nuxi prepare" }, "devDependencies": { + "@prisma/client": "^5.21.1", "nuxt": "^3.11.2", "prettier": "3.2.5", "prisma": "^5.15.0" - }, - "dependencies": { - "@prisma/client": "^5.15.0" } } diff --git a/playground/server/api/hello.ts b/playground/server/api/hello.ts new file mode 100644 index 0000000..2725559 --- /dev/null +++ b/playground/server/api/hello.ts @@ -0,0 +1,6 @@ +export default defineEventHandler(async (event) => { + const firstUser = await prisma.user.findFirst(); + return { + firstPost: firstUser, + }; +}); diff --git a/src/module.ts b/src/module.ts index 9d63325..ae7a56f 100644 --- a/src/module.ts +++ b/src/module.ts @@ -81,6 +81,7 @@ export default defineNuxtModule({ // Auto-import from runtime/server/utils addServerImportsDir(resolver(runtimeDir, "utils")); + addServerImportsDir(resolver(runtimeDir, "server/utils")); nuxt.options.vite.optimizeDeps ||= {}; nuxt.options.vite.optimizeDeps = {