Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

void/db imported from schema files outside db/schema.ts causes a circular import (sql is not a function)

Offen
#472 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
53/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
sqlite, typescript, vite

Rechercherichtung

Start with the Vite plugin logic in the dist/dispatch-*.mjs files mentioned in the report, then trace how it resolves void/db for db/schema.ts and re-exported schema files. Reproduce the cycle with the supplied D1/SQLite schema example in a Vite runtime. Done means the reported route can import the table without sql is not a function, or the project documents a supported alternative for sql in re-exported schema files.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Description

Importing sql from void/db in a table file that is re-exported from db/schema.ts, rather than defined in it, fails at runtime with:

TypeError: vite_ssr_import_0.sql is not a function

Reproduction

// db/schema.ts:
export * from "../src/resources/projects/projects.schema";

// src/resources/projects/projects.schema.ts:
import { sql } from 'void/db';
import { sqliteTable, text, integer } from 'void/schema-d1';

export const projects = sqliteTable('projects', {
  id: integer('id').primaryKey({ autoIncrement: true }),
  createdAt: text('created_at').notNull().default(sql`(datetime('now'))`),
});

Request any route that imports the table (e.g. via a repository).

Cause (from reading dist/dispatch-*.mjs)

The Vite plugin treats void/db as virtual:void-db-schema (no schema import) only when the importer is exactly db/schema.ts. Any other file gets virtual:void-db, which does import * as schema from db/schema.ts. That gives the cycle:

projects.schema.ts -> virtual:void-db -> db/schema.ts -> projects.schema.ts

sql is used at module top level while virtual:void-db is still evaluating, so it is undefined. tsc and void db generate don't catch it; only the Vite runtime does.

Similar to #50 (same error, caused by Windows path separators), but this one happens on Linux with a re-exported schema layout.

Expected

Either schema files reachable from db/schema.ts get the schema-free module too, or the docs say schema files other than db/schema.ts must not import void/db (and show an alternative for sql).

Environment

  • void 1.1.11
  • Linux
  • D1 / sqlite
Vorherrschende Sprache
TypeScript
Sterne
402
Forks
32
Ø Merge
13 Std. 14 Min.
Gemergte PRs (30 T.)
73

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus voidzero-dev/void

Alle Issues in voidzero-dev/void

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.