void/db imported from schema files outside db/schema.ts causes a circular import (sql is not a function)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 53/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- sqlite, typescript, vite
- 領域
- backend, build-system
調査の方向性
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 を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
voidzero-dev/void のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
voidzero-dev/void#484 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
voidzero-dev/void#463 ·
メンテナーはふだん 1 日以内に返信
-
Deploy after a secret change fails for Workers over ~750 KB: source read-back capped at 1 MiB対応中かも @Brooooooklyn が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
voidzero-dev/void#459 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 1/5 1〜3時間 初心者へのやさしさ 78/100
voidzero-dev/void#428 ·
メンテナーはふだん 1 日以内に返信
-
Allow `npm create void` and `void init` to run without prompts対応中かも @ashunar0 が今日担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 57/100
voidzero-dev/void#491 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
voidzero-dev/void の issue をすべて見る
似ている issue
-
[测试] 等待仓库加载后再记录多仓库排序基线対応中かも @myot233 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
area:arcade p3-medium ready-for-agent testing type:docs
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
fderuiter/deruiter.dev#2369 ·
メンテナーはふだん 1 日以内に返信
-
area:devenv origin:agent type:bug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
overengineeringstudio/effect-utils#1949 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
ccch1mneyyy/dsh-TUI#1631 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
MiniMax-AI/minimax-code#507 ·
メンテナーはふだん 1 日以内に返信