Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン
#472 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
53/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
sqlite, typescript, vite

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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
主要言語
TypeScript
スター
402
フォーク
32
平均マージ
12時間 1分
マージ済み PR(30日)
80

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

voidzero-dev/void のほかの issue

voidzero-dev/void の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。