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

Documentation for using Prisma with honox #260

Open
dan-massey opened this issue Feb 7, 2025 · 0 comments
Open

Documentation for using Prisma with honox #260

dan-massey opened this issue Feb 7, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@dan-massey
Copy link

What is the feature you are proposing?

I have successfully updated my vite.config.ts file to work with Cloudflare D1 and Prisma.

import build from "@hono/vite-build/cloudflare-workers";
import adapter from "@hono/vite-dev-server/cloudflare";
import honox from "honox/vite";
import { defineConfig } from "vite";
import { getPlatformProxy } from "wrangler";

export default defineConfig(async ({ command }) => {
  const platformProxy =
    command === "serve"
      ? await getPlatformProxy({
          environment: "prod",
          configPath: "wrangler.json",
        })
      : null;

  const devServerConfig = platformProxy
    ? {
        adapter: {
          env: platformProxy.env,
          onServerClose: platformProxy.dispose,
        },
      }
    : {
        adapter,
      };

  return {
    plugins: [
      honox({
        devServer: devServerConfig,
      }),
      build(),
    ],
    ssr: {
      external: [
        "@prisma/adapter-d1",
        "@prisma/debug",
        "@prisma/driver-adapter-utils",
        "@prisma/client",
        "@auth/prisma-adapter",
      ],
    },
  };
});

This works locally in development, but when I try to deploy to Cloudflare Workers I get an error:

 [ERROR] A request to the Cloudflare API (/accounts/b74ef356e795bbe93a6c96f17a1d0e37/workers/scripts/sutro-admin/versions) failed.

  Uncaught Error: No such module "@prisma/client".
    imported from "index.js"
   [code: 10021]

I've used D1 + Prisma + Hono + Cloudflare Workers successfully in the past. Is there a trick to getting Prisma to work with Vite/honox?

@dan-massey dan-massey added the enhancement New feature or request label Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant