-
Notifications
You must be signed in to change notification settings - Fork 37
feat: Support prisma >6.7 in standard starter #457
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Deploying redwood-sdk-docs with
|
Latest commit: |
3c685aa
|
Status: | ✅ Deploy successful! |
Preview URL: | https://dfc273eb.redwood-sdk-docs.pages.dev |
Branch Preview URL: | https://prisma-6-8-2.redwood-sdk-docs.pages.dev |
This reverts commit 0a22fb8.
justinvdm
added a commit
that referenced
this pull request
May 22, 2025
## Context Takes several changes from #457 for us to use to fix general WASM support. * We had configuration for supporting Prisma WASM, most of which predated our move to `@cloudflare/vite-plugin`, or were around in the early stages while the CF team were still working on WASM support in the plugin. `@cloudflare/vite-plugin` is now able to support WASM without these hacks and workarounds * Those workarounds we had also accidentally prevented us from using any other packages that had WASM in them * With these changes, we now should be able to support **both Prisma <6.7 and >6.7**, as well as unblock supporting other packages that have WASM * **note:** While Prisma >6.7 is supported, if you're is using the new `prisma-client` generator and `pnpm`, there is an edge case with a fix (cloudflare/workers-sdk#9322) that first needs to be released * We'll also be updating the standard starter to use >6.7 Prisma once this same fix has been released and we have upgraded `@cloudflare/vite-plugin` ## Other changes * Also upgrades * @cloudflare/vite-plugin:1.1.0 -> 0.0.0.0-1bae8618b (so we can use cloudflare/workers-sdk#9322 already) * wrangler:4.14.1 -> 4.16.0
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
prisma-client
generator: prisma will now generate code to a gitignoredgenerated/prisma
dirqueryCompiler
flag to reduce the size of the WASM (by around ~350KB)🔁 Prisma >6.7 migration guide for existing projects
Prisma introduced a new client generator (
prisma-client
) that lets us generate a client specific to Cloudflare workers (via workerd runtime) and ESM - this makes for much simpler and less error prone Vite integration.This guide walks you through upgrading an existing RedwoodSDK Standard Starter project.
1. ✅ Update Dependencies
Update the following packages in your package.json:
Also upgrade wrangler to at least ^4.16.0.
**2. 🧬 Update **
schema.prisma
Change the generator block to use the new prisma-client:
3. 🗂️ Adjust TypeScript Paths
In tsconfig.json:
Then update imports from
@prisma/client
to@/db.
4. 🛠️ Refactor DB Client Usage
Replace your
src/db.ts
with the latest in the standard starter:https://github.com/redwoodjs/sdk/blob/main/starters/standard/src/db.ts
5. 📁 Add to .gitignore
6. 📦 Re-generate Client
After updating schema.prisma:
7. 🧪 Test Everything
Check your queries work in development and deployments.
Notes
Steps taken
https://gist.github.com/justinvdm/24a9f316f7c5148be852c4660e5f0481
Update: 22 May 2025
Update: 21 May 2025
@cloudflare/vite-plugin
: fix(vite-plugin): Support__
in additional module IDs cloudflare/workers-sdk#9322__
in additional module IDs cloudflare/workers-sdk#9322 fix is in and PR upgraded to use it)Update: 19 May 2025
Goal: ==Upgrade to Prisma >=6.7, remove Prisma-specific Vite logic from RedwoodSDK, avoid WASM if possible, and maintain backwards compatibility.
Steps Taken:
Upgraded to Prisma 6.8.2 with queryCompiler and driverAdapters.
Tried out different vite configurations and aliases to target new Prisma client structure.
Tested various entry points (edge.js, index.js, wasm.js) and generation configs
Validated new
prisma-client
generator forworkerd
+esm
output.Current Status: Generated client works and loads in dev with SDK changes. DB client instantiation succeeds. Queries fail due to WASM module resolution error during runtime.
Blocking Issue: Cloudflare's Vite plugin fails to resolve Prisma's WASM module path, likely due to pnpm's path format (
__
) interfering with Cloudflare's module detection regex. Investigating patch to regex logic in@cloudflare/vite-plugin
.Findings:
Not WASM free (yet?): Prisma is not WASM free yet, but they're gradually moving the components out of rust into ts. There's still a 1.66MB wasm file we must work with. Previously it was 2MB.
Cloudflare's plugin appears to mangle WASM imports when the file path includes double underscores (__), likely due to greedy regex
Switching to Prisma's new ESM generator is promising for us to avoid complexities - e.g. we can avoid having to get optimizeDeps to esm-ify the
require
s in the generated prisma client (though we'll still need some logic for <6.7)Next Step: Investigate patch, then corresponding PR for Cloudflare's Vite plugin to fix its WASM module resolution regex handling for __ in paths.