cloudflare / cloudflare/vinext
Deploy fails with "No such module db" on 0.0.35+ (works on 0.0.33)
- Dominant language
- TypeScript
- Stars
- 8.8k
- Forks
- 406
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 120
Description
## Bug Description
Deploying to Cloudflare Workers fails with `No such module "db"` on vinext 0.0.35 and later (tested up to 0.0.38). The same project deploys successfully on vinext 0.0.33.
## Error Message
```
Uncaught Error: No such module "db".
```
This appears as a Workers validation error (error code 10021) after `wrangler deploy` succeeds in uploading.
## Environment
- **vinext**: 0.0.35, 0.0.36, 0.0.37, 0.0.38 (all fail)
- **vinext 0.0.33**: works perfectly
- **Node**: 22
- **wrangler**: 4.73.0
- **Vite**: 7.1.3
- **OS**: Windows 10
- **Platform**: Cloudflare Workers with D1, R2, KV, Durable Objects
## Reproduction
### Project structure
```
db/
index.ts # exports getDb(), Database type, schema
schema.ts # Drizzle ORM schema (SQLite/D1)
lib/
cron.ts # imports from "@/db"
actions/ # server actions import from "@/db"
worker-entry.ts # custom entry (re-exports vinext + cron + Durable Object)
```
### db/index.ts
```ts
import { drizzle } from "drizzle-orm/d1";
import * as schema from "./schema";
export function getDb(d1: D1Database) {
return drizzle(d1, { schema });
}
export type Database = ReturnType;
export { schema };
```
### tsconfig.json paths
```json
{
"paths": {
"@/*": ["./*"]
}
}
```
### worker-entry.ts (custom entry for cron + Durable Objects)
```ts
export { default } from "vinext/server/app-router-entry";
export { RateLimiter } from "@/lib/rate-limiter";
import { handleCron } from "@/lib/cron";
export const scheduled = async (event: { cron: string }): Promise => {
await handleCron({ cron: event.cron });
};
```
### wrangler.jsonc
```jsonc
{
"name": "arrangelist",
"compatibility_date": "2026-02-12",
"compatibility_flags": ["nodejs_compat"],
"main": "./worker-entry.ts",
// ... D1, R2, KV, Durable Objects bindings
}
```
### Steps to reproduce
1. Create a project with a `db/` directory using `@/db` path alias (Drizzle ORM + D1)
2. Use a custom `worker-entry.ts` that imports from `@/lib/cron` (which transitively imports `@/db`)
3. `npx vinext build` succeeds on all versions
4. `wrangler deploy` succeeds on 0.0.33 but fails on 0.0.35+ with "No such module db"
### Workaround
Pin to vinext 0.0.33:
```
npm install vinext@0.0.33
```
## Analysis
The build step succeeds on all versions, so TypeScript compilation and bundling work fine. The error occurs at Workers runtime validation, suggesting the `@/db` path alias is not being resolved correctly in the final Worker bundle starting from 0.0.35.
This may be related to the "Major App Router runtime refactor" in 0.0.35 that extracted modules into smaller per-route bundles, or the tsconfig alias transform fixes mentioned in the changelog.
The custom `worker-entry.ts` with `"main": "./worker-entry.ts"` in wrangler.jsonc may be a factor, as it creates a separate entry point that needs the same path resolution as the vinext-managed entry.
Contributor guide
Research direction
Start with worker-entry.ts, wrangler.jsonc, and the db/index.ts imports, then compare the final Worker bundle and deployment behavior between vinext 0.0.33 and 0.0.35+. Done means a project using the @/db alias and custom worker entry deploys without the Workers validation error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript, vite
- Domain
- backend, build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100