Skip to content

fix(auth): resolve @auth-schema without app configuration - #901

Merged
cpojer merged 2 commits into
voidzero-dev:mainfrom
ashunar0:fix/auth-schema-alias
Nov 22, 2026
Merged

cpojer merged 2 commits into
voidzero-dev:mainfrom
ashunar0:fix/auth-schema-alias

Conversation

@ashunar0

Copy link
Copy Markdown
Contributor

Fixes #900

Resolve @auth-schema to .void/better-auth-schema.ts the way @schema already is, so apps can import the auth tables without any configuration:

  • Dev and builds: the Drizzle plugin's resolveId resolves @auth-schema, next to @schema.
  • Types: the generated .void/tsconfig.json maps @auth-schema while the generated file exists, and drops the mapping when it does not. syncAuthTypesInProjectTsconfig does the same after the routing plugin writes the auth files, so an existing tsconfig gets the path too.

The auth guide no longer asks apps to add the alias to their root tsconfig.json. That step was also what made apps copy every path from .void/tsconfig.json by hand, because their own paths replaced the inherited ones. Apps that already have the alias keep working: it points to the same file.

Checked:

  • auth-schema-startup.test.ts now writes no tsconfig paths and no resolve.tsconfigPaths. Without this change the dev-server case fails with Cannot find module '@auth-schema'; with it, both cases pass.
  • project-tsconfig.test.ts: the path is added and dropped with the generated file, and added to an existing tsconfig by syncAuthTypesInProjectTsconfig.
  • The reproduction from The auth guide's @auth-schema alias passes typecheck and void db generate, but vp dev cannot resolve it #900 (a fresh void init React + D1 app with auth on and db/schema.ts importing userTable from @auth-schema), with no tsconfig paths and no resolve.tsconfigPaths, linked to this branch: void prepare writes the path, tsc passes, and vp dev starts.
  • vp run check:sdk passes.

vp run test fails in 6 files under platform/packages/api/test/integration/ because Playwright's Chromium is not installed locally. They fail the same way on main. This PR adds no new failures.

Not in this PR: void db seed still does not resolve @auth-schema (#872, #873). I have not checked whether #873 covers the alias once it is in .void/tsconfig.json.

Fixes voidzero-dev#900

Resolve `@auth-schema` to `.void/better-auth-schema.ts` the way `@schema`
already is: in the Drizzle plugin's `resolveId` for dev and builds, and as
a path in the generated `.void/tsconfig.json` for types. The path is added
while the generated file exists and dropped when it does not, also when the
routing plugin writes the auth files into an existing tsconfig.

The auth guide no longer asks apps to add the alias to their root
tsconfig, which also replaced every path `.void/tsconfig.json` provides.
@cpojer

cpojer commented Nov 22, 2026

Copy link
Copy Markdown
Member

Thanks! It looks like there are a few issues still. Here is a slop review:

  • P2 The new documented setup works in dev and generates the migration, but deploy preflight fails with Cannot find module '@auth-schema'. The isolated check drops .void/tsconfig.json. This also affects the old manual alias when the project extends that file. Copying the generated tsconfig made all four local deploy-check cases pass. GitHub CI still shows action_required. Deploy preflight · CI run

The deploy drift check copies the app without .void/, so an app tsconfig
that extends .void/tsconfig.json could not resolve @auth-schema there.
@ashunar0

Copy link
Copy Markdown
Contributor Author

Thanks for the review! Confirmed: the deploy drift check copied the app without
.void/tsconfig.json, so @auth-schema could not resolve there when the app
tsconfig extends it — with or without a manual alias.

Fixed in 4745052: the drift check now copies the generated tsconfig along with
better-auth-schema.ts.

Checked:

  • New deploy-drift tests for both setups (extends only, extends + manual alias);
    both fail on the previous commit with Cannot find module '@auth-schema'.
  • vp test run packages/void/test/unit/deploy-drift.test.ts passes.

@ashunar0

Copy link
Copy Markdown
Contributor Author

@cpojer thanks for catching that! I fixed them.

@cpojer cpojer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@cpojer
cpojer merged commit a7b1b0c into voidzero-dev:main Nov 22, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants