diff options
author | 2024-03-07 12:55:33 -0500 | |
---|---|---|
committer | 2024-03-07 12:55:33 -0500 | |
commit | 5a9dab286f3f436f3dce18f3b13a2cd9b774a8ef (patch) | |
tree | 03e5b3678eb40f20e1f0bfdbf31087b33bc675aa | |
parent | 652bd497dcb649126347780f0aebd9be3f8866b3 (diff) | |
download | astro-5a9dab286f3f436f3dce18f3b13a2cd9b774a8ef.tar.gz astro-5a9dab286f3f436f3dce18f3b13a2cd9b774a8ef.tar.zst astro-5a9dab286f3f436f3dce18f3b13a2cd9b774a8ef.zip |
Fix: drizzle vs. config runtime export conflict (#10357)
* fix: drizzle vs config export problem
* chore: remove drizzle runtime export
* chore: changeset
-rw-r--r-- | .changeset/chilly-cherries-appear.md | 5 | ||||
-rw-r--r-- | packages/db/package.json | 7 | ||||
-rw-r--r-- | packages/db/src/core/consts.ts | 1 | ||||
-rw-r--r-- | packages/db/src/core/integration/typegen.ts | 4 | ||||
-rw-r--r-- | packages/db/src/core/integration/vite-plugin-db.ts | 11 | ||||
-rw-r--r-- | packages/db/src/runtime/config.ts | 27 |
6 files changed, 35 insertions, 20 deletions
diff --git a/.changeset/chilly-cherries-appear.md b/.changeset/chilly-cherries-appear.md new file mode 100644 index 000000000..80fc9b123 --- /dev/null +++ b/.changeset/chilly-cherries-appear.md @@ -0,0 +1,5 @@ +--- +"@astrojs/db": patch +--- + +Fix runtime export error when building with the node adapter diff --git a/packages/db/package.json b/packages/db/package.json index 047843fc3..724c92318 100644 --- a/packages/db/package.json +++ b/packages/db/package.json @@ -20,10 +20,6 @@ "types": "./dist/runtime/index.d.ts", "import": "./dist/runtime/index.js" }, - "./runtime/drizzle": { - "types": "./dist/runtime/drizzle.d.ts", - "import": "./dist/runtime/drizzle.js" - }, "./runtime/config": { "types": "./dist/runtime/config.d.ts", "import": "./dist/runtime/config.js" @@ -41,9 +37,6 @@ "runtime": [ "./dist/runtime/index.d.ts" ], - "runtime/drizzle": [ - "./dist/runtime/drizzle.d.ts" - ], "runtime/config": [ "./dist/runtime/config.d.ts" ] diff --git a/packages/db/src/core/consts.ts b/packages/db/src/core/consts.ts index 54d766c0f..c0f5e2058 100644 --- a/packages/db/src/core/consts.ts +++ b/packages/db/src/core/consts.ts @@ -5,7 +5,6 @@ export const PACKAGE_NAME = JSON.parse( ).name; export const RUNTIME_IMPORT = JSON.stringify(`${PACKAGE_NAME}/runtime`); -export const RUNTIME_DRIZZLE_IMPORT = JSON.stringify(`${PACKAGE_NAME}/runtime/drizzle`); export const RUNTIME_CONFIG_IMPORT = JSON.stringify(`${PACKAGE_NAME}/runtime/config`); export const DB_TYPES_FILE = 'db-types.d.ts'; diff --git a/packages/db/src/core/integration/typegen.ts b/packages/db/src/core/integration/typegen.ts index 1c4834d13..7c046dbfd 100644 --- a/packages/db/src/core/integration/typegen.ts +++ b/packages/db/src/core/integration/typegen.ts @@ -1,6 +1,6 @@ import { existsSync } from 'node:fs'; import { mkdir, writeFile } from 'node:fs/promises'; -import { DB_TYPES_FILE, RUNTIME_DRIZZLE_IMPORT, RUNTIME_IMPORT } from '../consts.js'; +import { DB_TYPES_FILE, RUNTIME_CONFIG_IMPORT, RUNTIME_IMPORT } from '../consts.js'; import type { DBTable, DBTables } from '../types.js'; export async function typegen({ tables, root }: { tables: DBTables; root: URL }) { @@ -8,7 +8,7 @@ export async function typegen({ tables, root }: { tables: DBTables; root: URL }) declare module 'astro:db' { export const db: import(${RUNTIME_IMPORT}).SqliteDB; export const dbUrl: string; - export * from ${RUNTIME_DRIZZLE_IMPORT}; + export * from ${RUNTIME_CONFIG_IMPORT}; ${Object.entries(tables) .map(([name, collection]) => generateTableType(name, collection)) diff --git a/packages/db/src/core/integration/vite-plugin-db.ts b/packages/db/src/core/integration/vite-plugin-db.ts index 65a9fa6a0..ec512962d 100644 --- a/packages/db/src/core/integration/vite-plugin-db.ts +++ b/packages/db/src/core/integration/vite-plugin-db.ts @@ -1,13 +1,7 @@ import { fileURLToPath } from 'node:url'; import { normalizePath } from 'vite'; import { SEED_DEV_FILE_NAME } from '../../runtime/queries.js'; -import { - DB_PATH, - RUNTIME_CONFIG_IMPORT, - RUNTIME_DRIZZLE_IMPORT, - RUNTIME_IMPORT, - VIRTUAL_MODULE_ID, -} from '../consts.js'; +import { DB_PATH, RUNTIME_CONFIG_IMPORT, RUNTIME_IMPORT, VIRTUAL_MODULE_ID } from '../consts.js'; import type { DBTables } from '../types.js'; import { type VitePlugin, getDbDirectoryUrl, getRemoteDatabaseUrl } from '../utils.js'; @@ -116,7 +110,6 @@ ${ : '' } -export * from ${RUNTIME_DRIZZLE_IMPORT}; export * from ${RUNTIME_CONFIG_IMPORT}; ${getStringifiedCollectionExports(tables)}`; @@ -136,7 +129,7 @@ export const db = await createRemoteDatabaseClient(${JSON.stringify( appToken // Respect runtime env for user overrides in SSR )}, import.meta.env.ASTRO_STUDIO_REMOTE_DB_URL ?? ${JSON.stringify(getRemoteDatabaseUrl())}); -export * from ${RUNTIME_DRIZZLE_IMPORT}; + export * from ${RUNTIME_CONFIG_IMPORT}; ${getStringifiedCollectionExports(tables)} diff --git a/packages/db/src/runtime/config.ts b/packages/db/src/runtime/config.ts index 5fb87e7a5..f20887537 100644 --- a/packages/db/src/runtime/config.ts +++ b/packages/db/src/runtime/config.ts @@ -45,4 +45,29 @@ export function defineDB(userConfig: DBConfigInput) { return userConfig; } -export { sql, NOW, TRUE, FALSE } from './index.js'; +export { NOW, TRUE, FALSE } from './index.js'; + +export { + sql, + eq, + gt, + gte, + lt, + lte, + ne, + isNull, + isNotNull, + inArray, + notInArray, + exists, + notExists, + between, + notBetween, + like, + notIlike, + not, + asc, + desc, + and, + or, +} from 'drizzle-orm'; |