-
-
Notifications
You must be signed in to change notification settings - Fork 894
feat(build): update prisma extension to work with generated clients and rust-free clients #2689
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
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: eaeb102 The changes in this PR will be included in the next version bump. This PR includes changesets to release 24 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughThis PR redesigns the Prisma extension into three explicit modes (Legacy, Engine‑Only, Modern) and makes the mode parameter required. It adds prisma.config.ts support and enhanced Prisma version detection (externals → option → filesystem), plus multi‑file schema and migrations handling. Engine‑Only mode installs engine binaries and sets runtime env vars. New helper utilities for version/config resolution and filesystem path resolution were added, and mlly is re-exported (ESM + CJS). package.json for packages/build gained dependencies/devDependencies. Externals matching regex was broadened. CI Node.js versions and .nvmrc bumped to v20.19.0. Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/build/src/extensions/prisma.ts (1)
500-602: RespecttypedSql.pathconfiguration fromprisma.config.tsto prevent build failures with custom SQL pathsThis is a functional issue for users adopting
prisma.config.tswith customtypedSql.path. The codebase verification confirms:
- Prisma's config supports custom
typedSql.pathinprisma.config.tsloadPrismaConfig()receivesconfigResult.configcontaining the full Prisma config (includingtypedSql), but only extractsschemaandmigrationsPath(line 333), ignoringtypedSql.path_loadedConfig(line 408) lacks atypedSqlPathproperty, so the loaded config value is never storedonBuildComplete()hardcodes the SQL path as${prismaDirForSql}/sql(line 543), causingreaddir()to throwENOENTif the user has configured a differenttypedSql.path(e.g.,db/queries)Required fixes:
- Update
loadPrismaConfig()to extract and returntypedSql.pathfromconfigResult.config.typedSql?.path- Add
typedSqlPath?: stringto the_loadedConfigtype (line 408)- In
onBuildComplete(), preferthis._loadedConfig?.typedSqlPathwhen available; otherwise fall back to the inferred/sqldirectory- Wrap the
readdir()call in a try-catch to gracefully handle missing directories instead of throwing
🧹 Nitpick comments (2)
packages/build/src/extensions/prisma.ts (2)
11-150: API shape for the three modes looks solid; add a guard for unknownmodeThe new
PrismaLegacyModeExtensionOptions/PrismaEngineOnlyModeExtensionOptions/PrismaEngineModernModeExtensionOptionstypes and theprismaExtension(options)dispatcher are a clean way to expose the three modes, and the JSDoc matches what’s described in the changeset.One small robustness improvement: in
prismaExtension, ifoptions.modeis an unexpected string (e.g. from plain JS config), the function currently returnsundefined. Adding a default branch that throws a clear error (listing valid modes) would produce a much better failure mode for misconfigurations, especially for non-TypeScript consumers.export function prismaExtension(options: PrismaExtensionOptions): BuildExtension { switch (options.mode) { case "legacy": return new PrismaLegacyModeExtension(options); case "engine-only": return new PrismaEngineOnlyModeExtension(options); case "modern": return new PrismaEngineModernModeExtension(options); + default: { + const mode: never = options.mode as never; + throw new Error( + `Unknown Prisma extension mode "${String( + mode + )}". Expected one of "legacy" | "engine-only" | "modern".` + ); + } } }Also applies to: 358-400, 884-896
604-688: Multi-file schema copying works; filter is slightly Unix-centricThe multi-file vs schema-folder vs single-file branching looks correct:
- Directory schemas (
./prisma) are copied recursively, skippingmigrationsandsql(which are handled separately) and omitting--schemaon the generate command.prisma/schema/*.prismaschemas copy only the.prismafiles and also skip--schema.- Single-file schemas copy
schema.prismato the output and pass--schema=./prisma/schema.prisma.Two minor details:
- In the multi-file case, the filter uses
relativePath.startsWith("/migrations")and/sql. On Windows,relativePathwill likely start with\\migrations, so these directories won’t be filtered and will be copied twice (once here, once in the explicit migrations/sql handling). It’s harmless but noisy. Usingpath.seporpath.relativewith a split on separators would make this platform-independent.- When
generatorFlagsis empty, thegeneratecommand strings end with a trailing space, which is harmless but could be trimmed when building commands.Both are small polish items; behavior is correct as-is.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (68)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yamlreferences/prisma-6-client/.env.exampleis excluded by!references/**references/prisma-6-client/.gitignoreis excluded by!references/**references/prisma-6-client/package.jsonis excluded by!references/**references/prisma-6-client/prisma/migrations/20251114141701_add_initial_migration/migration.sqlis excluded by!references/**references/prisma-6-client/prisma/migrations/20251114143739_add_product_model/migration.sqlis excluded by!references/**references/prisma-6-client/prisma/migrations/migration_lock.tomlis excluded by!references/**references/prisma-6-client/prisma/schema.prismais excluded by!references/**references/prisma-6-client/src/db.tsis excluded by!references/**references/prisma-6-client/src/trigger/tasks.tsis excluded by!references/**references/prisma-6-client/trigger.config.tsis excluded by!references/**references/prisma-6-client/tsconfig.jsonis excluded by!references/**references/prisma-6-config/.env.exampleis excluded by!references/**references/prisma-6-config/.gitignoreis excluded by!references/**references/prisma-6-config/package.jsonis excluded by!references/**references/prisma-6-config/prisma.config.tsis excluded by!references/**references/prisma-6-config/prisma/migrations/20251117171313_add_initial_migration/migration.sqlis excluded by!references/**references/prisma-6-config/prisma/migrations/migration_lock.tomlis excluded by!references/**references/prisma-6-config/prisma/schema.prismais excluded by!references/**references/prisma-6-config/src/db.tsis excluded by!references/**references/prisma-6-config/src/trigger/tasks.tsis excluded by!references/**references/prisma-6-config/trigger.config.tsis excluded by!references/**references/prisma-6-config/tsconfig.jsonis excluded by!references/**references/prisma-6-multi-file/.env.exampleis excluded by!references/**references/prisma-6-multi-file/package.jsonis excluded by!references/**references/prisma-6-multi-file/prisma/migrations/20251113161257_add_initial_migration/migration.sqlis excluded by!references/**references/prisma-6-multi-file/prisma/migrations/migration_lock.tomlis excluded by!references/**references/prisma-6-multi-file/prisma/models/posts.prismais excluded by!references/**references/prisma-6-multi-file/prisma/models/users.prismais excluded by!references/**references/prisma-6-multi-file/prisma/schema.prismais excluded by!references/**references/prisma-6-multi-file/prisma/sql/getUserByEmail.sqlis excluded by!references/**references/prisma-6-multi-file/src/db.tsis excluded by!references/**references/prisma-6-multi-file/src/trigger/tasks.tsis excluded by!references/**references/prisma-6-multi-file/trigger.config.tsis excluded by!references/**references/prisma-6-multi-file/tsconfig.jsonis excluded by!references/**references/prisma-6-output/.env.exampleis excluded by!references/**references/prisma-6-output/.gitignoreis excluded by!references/**references/prisma-6-output/package.jsonis excluded by!references/**references/prisma-6-output/prisma/migrations/20251113213202_add_initial_migration/migration.sqlis excluded by!references/**references/prisma-6-output/prisma/migrations/migration_lock.tomlis excluded by!references/**references/prisma-6-output/prisma/schema.prismais excluded by!references/**references/prisma-6-output/prisma/sql/getUserByEmail.sqlis excluded by!references/**references/prisma-6-output/src/db.tsis excluded by!references/**references/prisma-6-output/src/trigger/tasks.tsis excluded by!references/**references/prisma-6-output/trigger.config.tsis excluded by!references/**references/prisma-6-output/tsconfig.jsonis excluded by!references/**references/prisma-6/.env.exampleis excluded by!references/**references/prisma-6/package.jsonis excluded by!references/**references/prisma-6/prisma/migrations/20251113155334_add_initial_migration/migration.sqlis excluded by!references/**references/prisma-6/prisma/migrations/migration_lock.tomlis excluded by!references/**references/prisma-6/prisma/schema.prismais excluded by!references/**references/prisma-6/prisma/sql/getUserByEmail.sqlis excluded by!references/**references/prisma-6/src/db.tsis excluded by!references/**references/prisma-6/src/trigger/tasks.tsis excluded by!references/**references/prisma-6/trigger.config.tsis excluded by!references/**references/prisma-6/tsconfig.jsonis excluded by!references/**references/prisma-7/.env.exampleis excluded by!references/**references/prisma-7/.gitignoreis excluded by!references/**references/prisma-7/.nvmrcis excluded by!references/**references/prisma-7/package.jsonis excluded by!references/**references/prisma-7/prisma.config.tsis excluded by!references/**references/prisma-7/prisma/migrations/20251113162106_add_initial_migration/migration.sqlis excluded by!references/**references/prisma-7/prisma/migrations/migration_lock.tomlis excluded by!references/**references/prisma-7/prisma/schema.prismais excluded by!references/**references/prisma-7/src/db.tsis excluded by!references/**references/prisma-7/src/trigger/tasks.tsis excluded by!references/**references/prisma-7/trigger.config.tsis excluded by!references/**references/prisma-7/tsconfig.jsonis excluded by!references/**
📒 Files selected for processing (7)
.changeset/six-vans-rhyme.md(1 hunks).nvmrc(1 hunks)packages/build/package.json(1 hunks)packages/build/src/extensions/prisma.ts(7 hunks)packages/build/src/imports/mlly-cjs.cts(1 hunks)packages/build/src/imports/mlly.ts(1 hunks)packages/cli-v3/src/build/externals.ts(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
packages/build/src/imports/mlly-cjs.cts (1)
packages/build/src/imports/mlly.ts (1)
resolvePathSync(5-5)
packages/build/src/extensions/prisma.ts (1)
packages/core/src/v3/build/extensions.ts (2)
BuildExtension(14-22)BuildContext(37-50)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
- GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - pnpm)
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (11)
.nvmrc (1)
1-1: Node version bump looks finev20.19.0 is compatible with the existing
engines.node >=18.20.0; just make sure CI images and deploy runtime are also on 20.19 so local/CI behavior matches..changeset/six-vans-rhyme.md (1)
1-383: Changeset documentation is thorough and consistent with the implementationThe changeset does a good job documenting the new
mode-based API, the three modes, and the configFile vs schema behavior, and it matches the exported options and classes inprisma.tsat a high level. This should give users enough context to migrate without surprises.packages/build/src/extensions/prisma.ts (6)
402-498: Legacy modeonBuildStart: schema/config validation and resolution look correctThe legacy mode’s
onBuildStart:
- Enforces exactly one of
schemaorconfigFile, which matches the documented behavior.- When
configFileis provided, usesloadPrismaConfigto obtain the schema and optional migrations path and logs them, then resolves the schema path relative toworkingDir.- Verifies the resolved schema path exists and throws a clear error if not.
This matches the changeset description and provides the right guardrails for both direct schema paths and
prisma.config.tssetups. (prisma.io)No changes needed here from a correctness standpoint.
692-755: Migrations handling is correct and respects config, with good loggingThe migration flow in legacy mode:
- Only runs when
options.migrateis truthy.- Prefers
migrations.pathfrom the loaded config (resolved againstworkingDir), and otherwise defaults to${prismaDir}/migrations.- Checks existence before copying, logging a warning and skipping if the directory is missing instead of failing the build.
- Prepends
prisma migrate deployto the command list when migrations are present.This matches Prisma’s config semantics and the behavior described in the changeset, and the logs will make it clear which path is used. (prisma.io)
No changes needed here.
756-805: Env wiring for DATABASE_URL and direct URLs is aligned with expectationsThe handling of
env.DATABASE_URL,directUrlEnvVarName, and fallbacks forDIRECT_URL/DIRECT_DATABASE_URLmatches how Prisma expects these variables to be wired, and the warnings emitted when they’re missing are explicit and actionable.This is consistent with Prisma’s environment-variable guidance and should be helpful in debugging misconfigured deployments. (prisma.io)
877-882: Helper for engine copy commands is correct
generateCpCommandsForLocationcorrectly uses the current@prisma/enginesfilename patterns:libquery_engine-<binaryTarget>.so.nodefor the query engine andschema-engine-<binaryTarget>for the schema engine. These filenames match the current @prisma/engines package layout (e.g., libquery_engine-debian-openssl-3.0.x.so.node, schema-engine-debian-openssl-3.0.x). The helper remains the central place to update if Prisma ever renames these binaries.
153-257: Version resolution helper behavior is reasonable
resolvePrismaClientVersionandtryResolvePrismaPackageVersionusemlly'sresolvePathSyncpluspkg-typesto find and read thepackage.jsonfor@prisma/clientorprisma, skipping markerpackage.jsonfiles with onlytypeand minimal fields. This aligns with how Prisma's CLI resolves the applicable npm project by searching the current directory and parent directories.No blocking issues here; just keep in mind:
- This logic assumes a filesystem layout where
@prisma/client/prismaare resolvable fromworkingDir. If users run builds from a different cwd in a monorepo, that may affect detection until they pass an explicitversionin options.- If you ever need to support custom package names for the Prisma client,
tryResolvePrismaPackageVersioncan be easily extended to accept overrides.
884-896: Modern mode externals behavior is appropriately minimalModern mode correctly marks
@prisma/clientas external for all targets viaexternalsForTarget, matching the documented "zero configuration" behavior where users manage client generation and adapters themselves. The new prisma-client generator still relies on the @prisma/client runtime, with generated code importing from "@prisma/client/runtime/library", so marking @prisma/client as external is the correct behavior.packages/cli-v3/src/build/externals.ts (1)
16-20: mllyurloption supports both plain strings and file:// URLs—code is correct as-isThe web search confirms mlly's
resolvePathSyncdocumentation explicitly acceptsurlas either a URL or plain string (defaulting topwd()), and mlly handles path string conversion internally. Your current approach of passingresolveDiras a plain string is fully supported and requires no changes.The optional suggestion to use
pathToFileURL(resolveDir)would be a stylistic choice only—not a requirement—since both forms work correctly per mlly's documented behavior.packages/build/src/imports/mlly.ts (1)
1-5: Remove unnecessary@ts-ignoredirectives — mlly has proper TypeScript typesmlly publishes TypeScript types (package.json points "types" to dist/index.d.ts) and the type declarations include resolvePathSync. The current
// @ts-ignorecomments on both the import and export are unnecessary. The recommended import form is a named import:import { resolvePathSync } from "mlly";, which is what your code already uses.Simply remove both
@ts-ignoredirectives:import { resolvePathSync } from "mlly"; export { resolvePathSync };packages/build/package.json (1)
79-87: Dependencies verified as Node 20.19.0 compatibleThe added runtime dependencies (
@prisma/config,mlly,resolve) and dev dependencies (@arethetypeswrong/cli,@types/resolve,esbuild) align with the new code paths and have no documented engine constraints blocking Node 20.19.0. Maintain version consistency with other monorepo consumers ofesbuild,mlly, andresolveto avoid resolution drift.
285eea8 to
3592646
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/build/src/extensions/prisma.ts (1)
563-601: Ensureprisma/sqlexists before copying TypedSQL artifactsIn the
typedSqlbranch, the code computesprismaDirForSqlandsqlDestinationPath = join(manifest.outputPath, "prisma", "sql"), then loops through.sqlfiles callingawait cp(source, destination)for each.fs.promises.cp does not create missing parent directories for the destination, so if
manifest.outputPath/prisma/sqldoes not already exist, the copy operation will throw an ENOENT error at build time.Add the destination directory before the loop:
-import { cp, readdir, readFile } from "node:fs/promises"; +import { cp, mkdir, readdir, readFile } from "node:fs/promises"; @@ - const sqlDestinationPath = join(manifest.outputPath, "prisma", "sql"); + const sqlDestinationPath = join(manifest.outputPath, "prisma", "sql"); + await mkdir(sqlDestinationPath, { recursive: true }); @@ - const destination = join(sqlDestinationPath, file); + const destination = join(sqlDestinationPath, file);This ensures TypedSQL artifacts can be copied robustly regardless of prior steps.
🧹 Nitpick comments (2)
packages/build/src/extensions/prisma.ts (2)
82-87: AligndirectUrlEnvVarName“required for migrations” wording with actual behaviourThe JSDoc says
directUrlEnvVarNameis required for migrations, butonBuildCompletehappily runsprisma migrate deploywhenevermigrateis true, even ifdirectUrlEnvVarNameis undefined (it falls back toDATABASE_URLand optionalDIRECT_URL/DIRECT_DATABASE_URL).To avoid confusing users:
- Either enforce the requirement (e.g., throw or at least warn strongly when
migrate: trueanddirectUrlEnvVarNameis missing), or- Relax the wording in the option docs/comments to “recommended when your schema uses a direct URL” and explain the fallback behaviour.
Right now the docs and runtime behaviour diverge slightly.
Also applies to: 692-779
391-399: Fail fast on unknownmodevalues inprismaExtensionThe factory currently switches on
options.modeand returns an extension for"legacy" | "engine-only" | "modern", but there’s nodefaultcase. If somebody passes an invalidmodefrom JS (or via a future refactor), the function will returnundefinedand the misconfiguration will only surface later.It’d be safer to throw immediately with a clear error:
export function prismaExtension(options: PrismaExtensionOptions): BuildExtension { switch (options.mode) { case "legacy": return new PrismaLegacyModeExtension(options); case "engine-only": return new PrismaEngineOnlyModeExtension(options); case "modern": return new PrismaEngineModernModeExtension(options); - } + default: { + // Exhaustive check so TS yells if a new mode is added + const _exhaustive: never = options.mode as never; + throw new Error(`Unsupported prismaExtension mode: ${options.mode}`); + } + } }This keeps runtime behaviour explicit and guards against accidental new/invalid mode strings.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (33)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yamlreferences/prisma-6-client/.env.exampleis excluded by!references/**references/prisma-6-client/.gitignoreis excluded by!references/**references/prisma-6-client/package.jsonis excluded by!references/**references/prisma-6-client/prisma/migrations/20251114141701_add_initial_migration/migration.sqlis excluded by!references/**references/prisma-6-client/prisma/migrations/20251114143739_add_product_model/migration.sqlis excluded by!references/**references/prisma-6-client/prisma/migrations/migration_lock.tomlis excluded by!references/**references/prisma-6-client/prisma/schema.prismais excluded by!references/**references/prisma-6-client/src/db.tsis excluded by!references/**references/prisma-6-client/src/trigger/tasks.tsis excluded by!references/**references/prisma-6-client/trigger.config.tsis excluded by!references/**references/prisma-6-client/tsconfig.jsonis excluded by!references/**references/prisma-6-config/.env.exampleis excluded by!references/**references/prisma-6-config/.gitignoreis excluded by!references/**references/prisma-6-config/package.jsonis excluded by!references/**references/prisma-6-config/prisma.config.tsis excluded by!references/**references/prisma-6-config/prisma/migrations/20251117171313_add_initial_migration/migration.sqlis excluded by!references/**references/prisma-6-config/prisma/migrations/migration_lock.tomlis excluded by!references/**references/prisma-6-config/prisma/schema.prismais excluded by!references/**references/prisma-6-config/src/db.tsis excluded by!references/**references/prisma-6-config/src/trigger/tasks.tsis excluded by!references/**references/prisma-6-config/trigger.config.tsis excluded by!references/**references/prisma-6-config/tsconfig.jsonis excluded by!references/**references/prisma-6-multi-file/package.jsonis excluded by!references/**references/prisma-6-multi-file/trigger.config.tsis excluded by!references/**references/prisma-6-output/package.jsonis excluded by!references/**references/prisma-6-output/prisma/schema.prismais excluded by!references/**references/prisma-6-output/trigger.config.tsis excluded by!references/**references/prisma-6/package.jsonis excluded by!references/**references/prisma-6/trigger.config.tsis excluded by!references/**references/prisma-7/package.jsonis excluded by!references/**references/prisma-7/prisma/schema.prismais excluded by!references/**references/prisma-7/trigger.config.tsis excluded by!references/**
📒 Files selected for processing (13)
.changeset/six-vans-rhyme.md(1 hunks).github/workflows/e2e.yml(1 hunks).github/workflows/release.yml(1 hunks).github/workflows/typecheck.yml(1 hunks).github/workflows/unit-tests-internal.yml(2 hunks).github/workflows/unit-tests-packages.yml(2 hunks).github/workflows/unit-tests-webapp.yml(2 hunks).nvmrc(1 hunks)packages/build/package.json(1 hunks)packages/build/src/extensions/prisma.ts(7 hunks)packages/build/src/imports/mlly-cjs.cts(1 hunks)packages/build/src/imports/mlly.ts(1 hunks)packages/cli-v3/src/build/externals.ts(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (8)
- .github/workflows/e2e.yml
- packages/build/src/imports/mlly.ts
- packages/build/src/imports/mlly-cjs.cts
- .github/workflows/unit-tests-internal.yml
- .nvmrc
- .github/workflows/unit-tests-webapp.yml
- packages/build/package.json
- .github/workflows/typecheck.yml
🧰 Additional context used
🧬 Code graph analysis (1)
packages/build/src/extensions/prisma.ts (1)
packages/core/src/v3/build/extensions.ts (2)
BuildExtension(14-22)BuildContext(37-50)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (23)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (8, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (3, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (2, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (7, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (5, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (4, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (6, 8)
- GitHub Check: units / internal / 🧪 Unit Tests: Internal (1, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (7, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (8, 8)
- GitHub Check: units / packages / 🧪 Unit Tests: Packages (1, 1)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (5, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (1, 8)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (2, 8)
- GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - pnpm)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (6, 8)
- GitHub Check: typecheck / typecheck
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (4, 8)
- GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
- GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (3, 8)
- GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - pnpm)
- GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - npm)
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (6)
.github/workflows/release.yml (1)
47-47: Node.js version aligned consistently.The bump from 20.11.1 to 20.19.0 is consistent with the coordinated Node.js version alignment across the project's CI/CD workflows.
.github/workflows/unit-tests-packages.yml (2)
61-61: Node.js version bump in unitTests job — consistent with project alignment.The upgrade to 20.19.0 in the unitTests workflow step aligns with the coordinated Node.js version strategy.
119-119: Node.js version bump in merge-reports job — consistent with project alignment.The upgrade to 20.19.0 in the merge-reports workflow step aligns with the coordinated Node.js version strategy.
packages/cli-v3/src/build/externals.ts (2)
178-180: LGTM! Good observability improvement.The debug logging addition helps trace which external packages are being registered for resolution, improving debuggability of the externals system.
531-531: LGTM! Regex pattern is now more permissive and standard.The change from
[^'"]to.removes an unnecessary restriction on quote characters in subpaths. Since esbuild'sargs.pathcontains unquoted import paths and valid import statements don't include quotes, this simplification is appropriate and aligns with the PR's goal to broaden external matching..changeset/six-vans-rhyme.md (1)
5-383: Changelog & migration guide look consistent with the implementationThe three-mode description, examples, and version matrix line up with the new Prisma extension code and options; nothing blocking here from a behaviour/accuracy standpoint.
3592646 to
eaeb102
Compare
The
prismaExtensionhas been completely redesigned to support multiple Prisma versions and deployment strategies. This update introduces three distinct modes to handle the evolving Prisma ecosystem, from legacy setups to the upcoming Prisma 7.Highlights:
prisma.config.tsfiles (Legacy Mode)Breaking Changes
The
prismaExtensionnow requires an explicitmodeparameter. Existing configurations without amodewill need to be updated.Note: All other existing options remain backward compatible. The new
configFileoption is optional and doesn't affect existing setups using theschemaoption.Before
After
New Features
1. Legacy Mode
Use when: You're using Prisma 6.x or earlier with the
prisma-client-jsprovider.Features:
prisma generateduring deploymentprisma/schema.prisma)prisma.config.ts) via@prisma/configpackagemigrate: truetypedSql: trueSchema Configuration:
Extension Configuration:
Tested Versions:
2. Engine-Only Mode
Use when: You have a custom Prisma client output path and want to manage
prisma generateyourself.Features:
@prisma/clientprisma generaterunsSchema Configuration:
Extension Configuration:
Important Notes:
prisma generateyourself (typically in a prebuild script)binaryTargetsfor deployment to the trigger.dev cloud. The binary target isdebian-openssl-3.0.x.PRISMA_QUERY_ENGINE_LIBRARYandPRISMA_QUERY_ENGINE_SCHEMA_ENGINEenvironment variables to the correct paths for the binary targets.package.json Example:
{ "scripts": { "prebuild": "prisma generate", "dev": "trigger dev", "deploy": "trigger deploy" } }Tested Versions:
3. Modern Mode
Use when: You're using Prisma 6.16+ with the new
prisma-clientprovider (withengineType = "client") or preparing for Prisma 7.Features:
@prisma/clientas externalSchema Configuration (Prisma 6.16+ with engineType):
Schema Configuration (Prisma 7):
Extension Configuration:
Prisma Config (Prisma 7):
Important Notes:
prisma generateyourselfprisma-clientprovider generates plain TypeScript (no Rust binaries)@prisma/adapter-pgfor PostgreSQL)Tested Versions:
engineType = "client"✅Migration Guide
From Old prismaExtension to Legacy Mode
If you were using the previous
prismaExtension, migrate to Legacy Mode:From Managing Your Own Prisma Setup
If you previously handled Prisma generation yourself and just needed engine binaries, use Engine-Only Mode:
Preparing for Prisma 7
If you want to adopt the new Prisma architecture, use Modern Mode:
prisma-clientproviderVersion Compatibility Matrix
engineType = "client"Prisma Config File Support (Prisma 6+)
NEW: Legacy Mode now supports loading configuration from a
prisma.config.tsfile using the official@prisma/configpackage.Use when: You want to use Prisma's new config file format (Prisma 6+) to centralize your Prisma configuration.
Benefits:
prisma.config.ts:
trigger.config.ts:
What gets extracted:
schema- The schema file or directory pathmigrations.path- The migrations directory path (if specified)Note: Either
schemaorconfigFilemust be specified, but not both.When to use which:
schemaoptionconfigFileoptionprisma.config.tsfileMulti-File Schema Support (Prisma 6.7+)
Prisma 6.7 introduced support for splitting your schema across multiple files in a directory structure.
Example Structure:
Configuration:
package.json:
{ "prisma": { "schema": "./prisma" } }TypedSQL Support
TypedSQL is available in Legacy Mode for Prisma 5.19.0+ with the
typedSqlpreview feature.Schema Configuration:
Extension Configuration:
Usage in Tasks:
Database Migration Support
Migrations are supported in Legacy Mode only.
Extension Configuration:
What This Does:
prisma/migrations/to the build outputprisma migrate deploybefore generating the clientdirectUrlEnvVarNamefor unpooled connections (required for migrations)NEW: When using
configFile, the migrations path is automatically extracted from yourprisma.config.ts:Binary Targets and Deployment
Trigger.dev Cloud
The default binary target is
debian-openssl-3.0.xfor Trigger.dev Cloud deployments.Legacy Mode: Handled automatically ✅
Engine-Only Mode: Specify in schema like so:
Modern Mode: Handled by database adapters ✅
Self-Hosted / Local Deployment
For local deployments (e.g., Docker on macOS), you may need a different binary target like so:
Environment Variables
Required Variables
All modes:
DATABASE_URL: Your database connection stringLegacy mode with migrations:
DATABASE_URL_UNPOOLED(or your customdirectUrlEnvVarName): Direct database connection for migrationsAuto-Set Variables
Engine-Only mode sets:
PRISMA_QUERY_ENGINE_LIBRARY: Path to the query enginePRISMA_QUERY_ENGINE_SCHEMA_ENGINE: Path to the schema engineTroubleshooting
"Could not find Prisma schema"
Legacy Mode: Ensure the
schemapath is correct relative to your working directory."Could not determine @prisma/client version"
NEW: The extension now includes improved version detection that tries multiple strategies:
@prisma/clientis imported in your code (externals)versionoption if specified@prisma/clientorprismainnode_modulesLegacy Mode: The extension will automatically detect the version from your installed packages. If it still fails, specify the version explicitly:
Engine-Only Mode: Specify the version explicitly:
"Binary target not found"
Engine-Only Mode: Make sure your schema includes the deployment binary target:
"Module not found: @prisma/client/sql"
Legacy Mode: Make sure
typedSql: trueis set and you have Prisma 5.19.0+:"Config file not found" or Config Loading Errors
Legacy Mode with configFile: Ensure the config file path is correct:
Requirements:
prismapackage installed (Prisma 6+)schemapathDebugging: Use
--log-level debugin yourtrigger deploycommand to see detailed logs:Then grep for
[PrismaExtension]in your build logs to see detailed information about config loading, schema resolution, and migrations setup.Complete Examples
Example 1: Standard Prisma 6 Setup (Legacy Mode)
prisma/schema.prisma:
trigger.config.ts:
Example 2: Multi-File Schema (Legacy Mode)
prisma/schema.prisma:
prisma/models/users.prisma:
prisma/models/posts.prisma:
package.json:
{ "prisma": { "schema": "./prisma" } }trigger.config.ts:
Example 3: Using Prisma Config File (Legacy Mode)
NEW: Use a
prisma.config.tsfile to centralize your Prisma configuration.prisma.config.ts:
prisma/schema.prisma:
trigger.config.ts:
src/db.ts:
Example 4: Custom Output Path (Engine-Only Mode)
prisma/schema.prisma:
package.json:
{ "scripts": { "generate": "prisma generate", "dev": "pnpm generate && trigger dev", "deploy": "trigger deploy" } }trigger.config.ts:
src/db.ts:
Example 5: Prisma 7 Beta (Modern Mode)
prisma/schema.prisma:
prisma.config.ts:
package.json:
{ "dependencies": { "@prisma/client": "6.20.0-integration-next.8", "@prisma/adapter-pg": "6.20.0-integration-next.8" }, "scripts": { "generate": "prisma generate", "dev": "pnpm generate && trigger dev", "deploy": "trigger deploy" } }trigger.config.ts:
src/db.ts: