Skip to content

fix(plugin-routing): improve better-auth client alias resolution in dev mode - #572

Open
MaxtuneLee wants to merge 1 commit into
voidzero-dev:mainfrom
MaxtuneLee:fix/better-auth-client-plugins-alias
Open

MaxtuneLee wants to merge 1 commit into
voidzero-dev:mainfrom
MaxtuneLee:fix/better-auth-client-plugins-alias

Conversation

@MaxtuneLee

Copy link
Copy Markdown

Summary

Close #565

better-auth/client/plugins fails to resolve in void dev when auth is enabled. This is because each alias used a string find, and vite matches a string find against the exact id and any id starting with find + '/', replacing only the prefix.

So better-auth/client/plugins -> …/dist/client/index.mjs/plugins, which doesn't exist.

I match the alias with a RegExp ^better-auth/<sub>$, so only the exact specifier is rewritten, other subpaths, including client/plugins, now fall through to normal resolution.

File touched

  • packages/void/src/plugin-routing.ts: Use exact-match alias patterns
  • packages/void/test/unit/plugin-routing.test.ts: Add a verification

Test plans

  • vp test run packages/void/test/unit/plugin-routing.test.ts: 56 passed
  • vp run --filter ./packages/void typecheck: clean.
  • vp fmt applied to the two changed files.

This branch has not been deployed

No deployments
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.

Dev: better-auth/client/plugins fails to resolve when auth is enabled (the better-auth/client alias matches it as a prefix)

1 participant