Skip to content

The auth guide's @auth-schema alias passes typecheck and void db generate, but vp dev cannot resolve it #900

Closed

Description

@ashunar0

Version

void 1.11.0, vite-plus 1.7.0 (Vite 8.3.8), fresh void init --framework react --starter sqlite

Problem

The auth guide ("Querying Authentication Tables") says to reference users from your own tables through a tsconfig alias:

{ "compilerOptions": { "paths": { "@auth-schema": ["./.void/better-auth-schema.ts"] } } }
// db/schema.ts
import { userTable } from '@auth-schema';

export const posts = sqliteTable('posts', {
  id: integer('id').primaryKey({ autoIncrement: true }),
  userId: text('user_id').notNull().references(() => userTable.id),
});

With that, tsc --noEmit and void db generate pass, but the dev server does not start:

(!) Failed to run dependency scan. Skipping dependency pre-bundling. Error: The following dependencies are imported but could not be resolved:
  @auth-schema (imported by …/db/schema.ts)
error when starting dev server:
Error: Cannot find module '@auth-schema' imported from '…/db/schema.ts'

.void/better-auth-schema.ts exists at this point (void prepare has run), so this is not the fresh-clone case fixed in #823.

Reproduction

  1. npx void init --toolchain vite-plus --framework react --starter sqlite --deploy none
  2. Turn auth on: auth: { providers: ['email'] } in void.config.ts, then void prepare
  3. Add the paths above to the root tsconfig.json (keeping the ones from .void/tsconfig.json, as the guide says)
  4. Add the posts table above to db/schema.ts
  5. vp dev → the error above

Cause

The CLI loads modules with tsconfigPaths: true (projectAuthConfigImporter), so the alias resolves there. The dev server uses the app's vite.config.ts, and the one void init writes does not set resolve.tsconfigPaths, so nothing resolves @auth-schema. Void's plugin aliases only @schema.

Adding resolve: { tsconfigPaths: true } to vite.config.ts makes vp dev start. Void's own test/integration/auth-schema-startup.test.ts sets it in its Vite config too, so the test passes while the guide's steps do not.

Proposal

Either:

  • have voidPlugin() alias @auth-schema the way it aliases @schema, so the guide's steps work as written (and @auth-schema would no longer need a tsconfig entry that replaces the inherited paths), or
  • say in the guide that vite.config.ts needs resolve: { tsconfigPaths: true }.

Related: #823 (fresh clone), #872 (void db seed does not resolve tsconfig aliases).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions