Commit 9ca03c4
committed
Use dynamic import() to load Prisma client
The previous implementation used createRequire(import.meta.url) to
synchronously require() the Prisma client at options.clientPath.
This is incompatible with Prisma 7's `prisma-client` generator, which
outputs plain TypeScript (ESM) files that cannot be loaded by Node's
native CJS require().
Switch to await import(options.clientPath) so that:
- Under Vitest, clientPath can point at the generated TS source
directly (e.g. a file:// URL to `client.ts`), and Vite's transform
pipeline handles the TypeScript/ESM resolution.
- Under plain Node, any ESM-compatible specifier continues to work
(package names, file:// URLs, .js/.mjs paths).
`createContext` becomes async; callers must `await` it. The only
caller is `environment.setup`, which is already async.
Fixes #221 parent fc5b11e commit 9ca03c4
3 files changed
Lines changed: 5 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
| 22 | + | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | 1 | | |
3 | 2 | | |
4 | 3 | | |
5 | 4 | | |
6 | 5 | | |
7 | 6 | | |
8 | | - | |
9 | | - | |
10 | 7 | | |
11 | 8 | | |
12 | 9 | | |
13 | 10 | | |
14 | 11 | | |
15 | 12 | | |
16 | 13 | | |
17 | | - | |
| 14 | + | |
18 | 15 | | |
19 | 16 | | |
20 | 17 | | |
| |||
31 | 28 | | |
32 | 29 | | |
33 | 30 | | |
34 | | - | |
| 31 | + | |
35 | 32 | | |
36 | 33 | | |
37 | 34 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
0 commit comments