Repository navigation
fix(auth): resolve @auth-schema without app configuration - #901
Merged
Merged
Conversation
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.
Member
|
Thanks! It looks like there are a few issues still. Here is a slop review:
|
The deploy drift check copies the app without .void/, so an app tsconfig that extends .void/tsconfig.json could not resolve @auth-schema there.
Contributor
Author
|
Thanks for the review! Confirmed: the deploy drift check copied the app without Fixed in 4745052: the drift check now copies the generated tsconfig along with Checked:
|
Contributor
Author
|
@cpojer thanks for catching that! I fixed them. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #900
Resolve
@auth-schemato.void/better-auth-schema.tsthe way@schemaalready is, so apps can import the auth tables without any configuration:resolveIdresolves@auth-schema, next to@schema..void/tsconfig.jsonmaps@auth-schemawhile the generated file exists, and drops the mapping when it does not.syncAuthTypesInProjectTsconfigdoes 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.jsonby hand, because their ownpathsreplaced the inherited ones. Apps that already have the alias keep working: it points to the same file.Checked:
auth-schema-startup.test.tsnow writes no tsconfigpathsand noresolve.tsconfigPaths. Without this change the dev-server case fails withCannot 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 bysyncAuthTypesInProjectTsconfig.@auth-schemaalias passes typecheck andvoid db generate, butvp devcannot resolve it #900 (a freshvoid initReact + D1 app with auth on anddb/schema.tsimportinguserTablefrom@auth-schema), with no tsconfigpathsand noresolve.tsconfigPaths, linked to this branch:void preparewrites the path,tscpasses, andvp devstarts.vp run check:sdkpasses.vp run testfails in 6 files underplatform/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 seedstill does not resolve@auth-schema(#872, #873). I have not checked whether #873 covers the alias once it is in.void/tsconfig.json.