mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #536] feat: precompile next.config matchers at build time #655
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#655
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/536
Author: @SeolJaeHyeok
Created: 3/14/2026
Status: 🔄 Open
Base:
main← Head:feat/issue-389-precompile-config-patterns📝 Commits (7)
711e283refactor: extract reusable config pattern compilers893bf15feat: emit precompiled config matchers in generated entriesd74e266feat: use precompiled config matchers in request handlers37125bdfix: address precompiled config code review feedbackd057788docs: clarify compileConfigPattern null return semantics3fa8cdfMerge branch 'main' into feat/issue-389-precompile-config-patterns94be940PR approved, two minor formatting nits.📊 Changes
16 files changed (+703 additions, -119 deletions)
View changed files
➕
examples/fumadocs-docs-template/.source/browser.ts(+12 -0)➕
examples/fumadocs-docs-template/.source/dynamic.ts(+8 -0)➕
examples/fumadocs-docs-template/.source/server.ts(+12 -0)➕
examples/fumadocs-docs-template/.source/source.config.mjs(+24 -0)📝
packages/vinext/src/config/config-matchers.ts(+112 -67)➕
packages/vinext/src/config/precompiled-config.ts(+76 -0)📝
packages/vinext/src/deploy.ts(+30 -6)📝
packages/vinext/src/entries/app-rsc-entry.ts(+20 -5)📝
packages/vinext/src/entries/pages-server-entry.ts(+11 -0)📝
packages/vinext/src/index.ts(+33 -5)📝
packages/vinext/src/server/prod-server.ts(+19 -5)📝
tests/__snapshots__/entry-templates.test.ts.snap(+113 -30)📝
tests/app-router.test.ts(+6 -1)📝
tests/entry-templates.test.ts(+31 -0)➕
tests/precompiled-config.test.ts(+165 -0)📝
tests/shims.test.ts(+31 -0)📄 Description
Closes #389
summary
compileConfigPatternandcompileHeaderSourcePatternhelpers fromconfig-matcherswhat changed
packages/vinext/src/config/precompiled-config.tsto build and serialize precompiled config matcher statepackages/vinext/src/config/config-matchers.tsto expose reusable compile helpers and optional compiled matcher inputs for redirects, rewrites,and headers
generateRscEntry()to emit__compiledRedirects,__compiledRewrites, and__compiledHeadersalongside the existing config payloadsgenerateServerEntry()to exportvinextCompiledConfigfor Pages Router production and deploy pathsindex.ts,server/prod-server.ts, anddeploy.tsto thread the precompiled matcher state through the existing config matching flowwhy
PR #387 removed the steady-state bottleneck by caching compiled config patterns per isolate. That keeps warm isolates fast, but low-traffic routes can still
pay the compilation cost on the first request after a cold start.
This PR moves that work out of the request path by compiling config patterns ahead of time for generated entries, and once during dev startup for the live
config path. Matching behavior stays the same, but the first matching request no longer needs to tokenize patterns, run the safe-regex check, and construct
RegExpinstances.test plan
pnpm test tests/shims.test.ts tests/app-router.test.ts tests/entry-templates.test.tspnpm run typecheckpnpm run lint🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.