Dev: `better-auth/client/plugins` fails to resolve when auth is enabled (the `better-auth/client` alias matches it as a prefix)
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 76/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- typescript, vite
- 領域
- devtools
調査の方向性
packages/void/src/plugin-routing.ts の616〜622行目にある Better Auth エイリアスの付近を読み、Vite が文字列エイリアスをサブパスとどのように照合するかを確認してください。認証を有効にし、better-auth/client/plugins からインポートして再現し、開発時の解決とビルド時の動作を比較してください。プラグインのインポートが void dev で解決され、既存の Better Auth エイリアスも引き続き機能すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Description
With auth enabled, void dev aliases better-auth/client (and /react, /vue, /svelte, /solid) to absolute file paths. A string alias in Vite also matches subpaths, so better-auth/client/plugins, where Better Auth's client plugins such as adminClient() live, is rewritten to …/better-auth/dist/client/index.mjs/plugins, which doesn't exist. Any app that passes a Better Auth client plugin to createAuthClient breaks in dev. void build is not affected, because the alias is only added for serve.
Steps to reproduce
-
Enable auth in
void.config.ts:auth: { providers: ['email'] }. -
Add
better-authas a dependency (the same version Void uses). -
Create a client with a plugin and import it from a page:
// src/lib/auth-client.ts import { adminClient } from 'better-auth/client/plugins'; import { createAuthClient } from 'void/client'; export const authClient = createAuthClient({ basePath: '/api/auth', plugins: [adminClient()], }); -
Run
void devand open that page.
Actual behavior
- Client:
Pre-transform error: Failed to resolve import "better-auth/client/plugins" from "src/lib/auth-client.ts". Does the file exist? - SSR: the page returns 500 with
Error: No such module "workers/runner-worker/file:/…/better-auth/dist/client/plugins/index.mjs".
Expected behavior
better-auth/client/plugins resolves to better-auth/dist/client/plugins/index.mjs, as it does in void build and in Node.
Cause
packages/void/src/plugin-routing.ts (main @ 6ba3dbcc3a, lines 616–622):
const betterAuthSubpaths = ['client', 'react', 'vue', 'svelte', 'solid'];
const resolvedAliases = betterAuthSubpaths.flatMap((sub) => {
try {
return [{ find: `better-auth/${sub}`, replacement: resolveFile(`better-auth/${sub}`) }];
} catch {
return [];
}
});
A string find matches the exact id and any id that starts with find + '/', replacing the prefix. resolveFile('better-auth/client') is …/dist/client/index.mjs, so better-auth/client/plugins becomes …/dist/client/index.mjs/plugins.
Possible fix
Anchor the patterns so they only match the exact specifier, and pre-resolve client/plugins too if it should avoid the lazy-discovery reload the comment mentions:
const betterAuthSubpaths = ['client', 'client/plugins', 'react', 'vue', 'svelte', 'solid'];
// …
return [{ find: new RegExp(`^better-auth/${sub}$`), replacement: resolveFile(`better-auth/${sub}`) }];
Workaround
A plugin listed after voidPlugin() adds an exact-match alias. Aliases from a later plugin's config hook are tried first, so this one wins:
// vite.config.ts
import { createRequire } from 'node:module';
import type { Plugin } from 'vite-plus';
const require = createRequire(import.meta.url);
function betterAuthClientPlugins(): Plugin {
return {
name: 'better-auth-client-plugins',
config: () => ({
resolve: {
alias: [
{
find: /^better-auth\/client\/plugins$/,
replacement: require.resolve('better-auth/client/plugins'),
},
],
},
}),
};
}
// plugins: [voidPlugin(), voidReact(), betterAuthClientPlugins()]
Related
#554 edits the same block (adds authConfigEnvironmentConfig to the returned config) but keeps the prefix aliases.
Environment
- void 1.2.1 (also on 1.1.12), better-auth 1.7.11
- vite-plus 1.3.0, Node 22.23.3, macOS 26.6
- 主要言語
- TypeScript
- スター
- 580
- フォーク
- 56
- 平均マージ
- 8時間 36分
- マージ済み PR(30日)
- 110
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
voidzero-dev/void のほかの issue
-
Static Cloudflare deploy ignores `cloudflare.assets.html_handling`対応中かも @0froq が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
voidzero-dev/void#580 ·
メンテナーはふだん 1 日以内に返信
-
`void/log` serializes `Error` fields as `{}`, losing message and stack対応中かも @RaphaelFakhri が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
voidzero-dev/void#577 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
voidzero-dev/void#576 ·
メンテナーはふだん 1 日以内に返信
-
prepareDeployArtifact omits worker.vars that the CLI managed deploy includes対応中かも @dvkam が 1 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
voidzero-dev/void#529 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 1/5 1〜3時間 初心者へのやさしさ 78/100
voidzero-dev/void#428 ·
メンテナーはふだん 1 日以内に返信
voidzero-dev/void の issue をすべて見る
似ている issue
-
[Bug]: Device screenshot fails with 500 on iPhone Duo (Xcode 27.2): serve-sim calls simctl without --display対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
pingdotgg/t3code#24900 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
inu-appcenter/UNIDorm-web#411 ·
メンテナーはふだん 1 日以内に返信
-
🐛 bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
ranxianglei/billion-context#4720 ·
メンテナーはふだん 1 日以内に返信
-
area:arcade game p3-medium ready-for-agent type:bug
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
fderuiter/deruiter.dev#2840 ·
メンテナーはふだん 1 日以内に返信