1import * as NodeServices from "@effect/platform-node/NodeServices";
2import { expect, layer } from "alchemy-test";
3import * as Effect from "effect/Effect";
4import * as Path from "effect/Path";
5
6const describe = layer(NodeServices.layer);
7
8describe("Prisma optional peers", (it) => {
9 it.effect(
10 "keeps provider and schema entrypoints independent of ORM runtime packages",
11 () =>
12 Effect.gen(function* () {
13 const path = yield* Path.Path;
14 const entries = yield* Effect.forEach(
15 [
16 "../../../src/Prisma/index.ts",
17 "../../../src/Prisma/ORM/Schema.ts",
18 "../../../src/Prisma/ORM/generator.ts",
19 "./fixtures/psl/generated/schemas.ts",
20 ],
21 (entry) => path.fromFileUrl(new URL(entry, import.meta.url)),
22 );
23 const result = yield* Effect.promise(() =>
24 Bun.build({
25 entrypoints: entries,
26 target: "bun",
27 packages: "external",
28 plugins: [
29 {
30 name: "reject-optional-prisma-runtime",
31 setup(build) {
32 build.onResolve(
33 { filter: /^(@prisma\/orm-|arktype(?:\/|$))/ },
34 (args) => {
35 throw new Error(
36 `Unexpected optional runtime import: ${args.path}`,
37 );
38 },
39 );
40 },
41 },
42 ],
43 }),
44 );
45 expect(result.success).toBe(true);
46 expect(result.logs.filter((log) => log.level === "error")).toEqual([]);
47 }),
48 { tags: ["unit", "provider:prisma", "provider:prisma:orm", "local"] },
49 );
50});