Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

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

Offen Anfängerfreundlich
#565 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@MaxtuneLee arbeitet bereits daran.

Seit 23.10.2026.

  • #572 von @MaxtuneLee — offen

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
76/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
typescript, vite
Bereich
devtools

Rechercherichtung

Lies packages/void/src/plugin-routing.ts im Bereich der Better Auth-Aliase in den Zeilen 616–622 und prüfe, wie Vite String-Aliase mit Unterpfaden abgleicht. Reproduziere das Problem mit aktivierter Authentifizierung und einem Import aus better-auth/client/plugins; vergleiche die Auflösung im Entwicklungsmodus mit dem Build-Verhalten. Erledigt, wenn der Plugin-Import in void dev aufgelöst wird und die vorhandenen Better Auth-Aliase weiterhin funktionieren.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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

  1. Enable auth in void.config.ts: auth: { providers: ['email'] }.

  2. Add better-auth as a dependency (the same version Void uses).

  3. 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()],
    });
    
  4. Run void dev and 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
Vorherrschende Sprache
TypeScript
Sterne
402
Forks
32
Ø Merge
8 Std. 32 Min.
Gemergte PRs (30 T.)
111

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus voidzero-dev/void

Alle Issues in voidzero-dev/void

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.