Commit 3009504
committed
Scope loadModule default-export unwrap to drizzle config imports
loadModule used to apply `mod?.default ?? mod` in all three branches
(Bun/Deno, jiti, ESM Node), so every caller silently received the
default export when present. Only drizzleConfigFromFile actually needs
that — drizzle.config.ts uses `export default defineConfig(...)` —
while the 11 schema-loading call sites in cli/commands/studio.ts and
dialects/*/drizzle.ts iterate `Object.entries(mod)` to find PgTable /
MySqlTable / Relations values, where the unwrap masks bugs and silently
rescues non-canonical `export default { tables }` schemas.
Add an explicit `{ defaultExport }` options flag, default false. All
three branches now return `defaultExport ? (mod?.default ?? mod) : mod`.
drizzleConfigFromFile passes `{ defaultExport: true }`; the schema-
loading call sites are unchanged and now receive the raw namespace.
Behavior change: schema files using `export default { users, posts }`
stop working — must switch to named exports (`export const users =
pgTable(...)`), the documented drizzle pattern.
- pnpm exec tsc --noEmit -p tsconfig.json → 0
- vitest run tests/other/ → 376/3761 parent dec6419 commit 3009504
2 files changed
Lines changed: 5 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
945 | 945 | | |
946 | 946 | | |
947 | 947 | | |
948 | | - | |
| 948 | + | |
949 | 949 | | |
950 | 950 | | |
951 | 951 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
428 | 428 | | |
429 | 429 | | |
430 | 430 | | |
| 431 | + | |
431 | 432 | | |
432 | 433 | | |
433 | 434 | | |
434 | 435 | | |
435 | | - | |
| 436 | + | |
436 | 437 | | |
437 | 438 | | |
438 | 439 | | |
| |||
466 | 467 | | |
467 | 468 | | |
468 | 469 | | |
469 | | - | |
| 470 | + | |
470 | 471 | | |
471 | 472 | | |
472 | 473 | | |
473 | | - | |
| 474 | + | |
474 | 475 | | |
0 commit comments