Skip to content

perf(void): keep auth codegen and CLI output out of the plugin entry - #503

Merged
cpojer merged 2 commits into
voidzero-dev:mainfrom
yangshun:claude/lazy-plugin-entry-imports
Oct 20, 2026
Merged

cpojer merged 2 commits into
voidzero-dev:mainfrom
yangshun:claude/lazy-plugin-entry-imports

Conversation

@yangshun

@yangshun yangshun commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Issue

Every vp dev and vp build imports the plugin entry before anything else. It statically loaded:

  • Better Auth's schema helpers (auth/drizzle.ts → better-auth/db and zod), used only by the routing plugin's auth codegen.
  • The CLI's terminal-link stack (cli/output.ts), used only by printSuccess at the end of the interactive AI setup prompt.

Fix

Both are now lazily-imported where they are used. Apps without auth, and dev sessions that never run the AI prompt, no longer load them.

Impact

  • Void's own import graph, measured after Vite and @cloudflare/vite-plugin are loaded: 231 → 80 modules, ~54 → ~30ms.
  • import('void') overall: ~510 → ~480ms (6 interleaved runs). Most of what remains is @cloudflare/vite-plugin importing wrangler and miniflare.

Small improvements, but every ms counts 😎

Verification

  • vp run --filter ./packages/void typecheck
  • packages/void/test/unit/plugin-routing.test.ts
  • packages/void/test/integration/kitchen-sink-build.test.ts (an auth app, so it runs the lazily loaded codegen in a real build)

Every `vp dev` and `vp build` imports the plugin entry before doing anything
else. It statically loaded Better Auth's schema helpers (with zod) for the
routing plugin's auth codegen and the CLI's terminal-link stack for the AI
setup prompt, although only auth apps and that prompt use them. Import both
where they are used.

This drops 151 modules from the entry's own import graph and about 25ms
from `import('void')`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@yangshun
yangshun force-pushed the claude/lazy-plugin-entry-imports branch from 01f378d to 35c6fec Compare October 20, 2026 09:07
…LI output

Every vp dev and vp build imports the plugin entry first. The test mocks
auth/drizzle.ts, cli/output.ts, better-auth/db and terminal-link, imports
the entry, and expects none of them to load. It fails on main, where the
entry loads both modules statically. AGENTS.md points to the test.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@Brooooooklyn

Copy link
Copy Markdown
Member

Thanks! Verified: on the built dist, void loads 238 → 77 modules after Vite + the Cloudflare plugin (median 70.8 → 37.7 ms), and nothing from better-auth, zod or terminal-link is reachable from dist/index.mjs anymore. Rolldown emits each dynamic import as its own chunk. The cli/output.ts change also keeps out an ~80 KB prompt chunk (@clack/core, vite-plus-prompts, …).

I pushed 46fcb55 with a guard test, test/unit/plugin-entry-imports.test.ts. It mocks auth/drizzle.ts, cli/output.ts, better-auth/db and terminal-link, imports the plugin entry, and expects none of them to load. It passes here in ~0.7 s and fails on main. The AGENTS.md bullet now points to it.

@Brooooooklyn

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T10:08:41.157791Z 46fcb55 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 46fcb55c1b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@yangshun

Copy link
Copy Markdown
Contributor Author

Thanks! Verified: on the built dist, void loads 238 → 77 modules after Vite + the Cloudflare plugin (median 70.8 → 37.7 ms), and nothing from better-auth, zod or terminal-link is reachable from dist/index.mjs anymore. Rolldown emits each dynamic import as its own chunk. The cli/output.ts change also keeps out an ~80 KB prompt chunk (@clack/core, vite-plus-prompts, …).

I pushed 46fcb55 with a guard test, test/unit/plugin-entry-imports.test.ts. It mocks auth/drizzle.ts, cli/output.ts, better-auth/db and terminal-link, imports the plugin entry, and expects none of them to load. It passes here in ~0.7 s and fails on main. The AGENTS.md bullet now points to it.

Thanks! Claude actually added a test but I removed it as I felt it was superflous 😅

@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.

Sick.

@cpojer
cpojer merged commit 3390c12 into voidzero-dev:main Oct 20, 2026
18 checks passed
@yangshun
yangshun deleted the claude/lazy-plugin-entry-imports branch October 20, 2026 11:41
@Brooooooklyn

Copy link
Copy Markdown
Member

Let's respect Claude's behavior 🫡

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.

3 participants