Repository navigation
👑feat(#6): add @thexjs/adapter-vercel package for Vercel Build Output API v3 support - #6
Conversation
… API v3 support - Implemented buildVercelOutput function to generate .vercel/output structure - Added bundling for render functions with all dependencies inlined - Created configuration files for Vercel deployment - Introduced types for Vercel adapter options and build manifest - Added static asset copying and output directory resolution - Included transpilation of source files from TSX/TS to Node-compatible ESM - Established module registry for managing unique source files - Implemented route and action resolution at build time - Added README documentation for usage instructions
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Review limit reached
Next review available in: 22 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (11)
📝 WalkthroughWalkthroughAdds a Vercel adapter that builds Build Output API v3 artifacts, bundles server routes into a Node ESM function, copies static assets, and exposes the build through a new CLI adapter option. ChangesVercel adapter
CLI adapter selection
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant CLI
participant buildVercelOutput
participant resolveBuildManifest
participant bundleRenderFunction
participant VercelOutput
CLI->>buildVercelOutput: build with --adapter vercel
buildVercelOutput->>resolveBuildManifest: scan server routes and actions
resolveBuildManifest-->>buildVercelOutput: return BuildManifest
buildVercelOutput->>bundleRenderFunction: bundle server surface
bundleRenderFunction-->>buildVercelOutput: write render function
buildVercelOutput->>VercelOutput: write config and static assets
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 8
🧹 Nitpick comments (1)
packages/adapter-vercel/src/transpile.ts (1)
19-38: 🚀 Performance & Scalability | 🔵 Trivial | ⚖️ Poor tradeoffConsider batching all module entrypoints into a single
Bun.build()call.Each ref currently triggers its own
Bun.build()invocation sequentially. For apps with many routes/layouts/actions this adds per-invocation bundler overhead. Batching via one call withentrypoints: refs.map(r => r.sourcePath)plus anamingfunction mapping back to eachref.compiledPathwould cut build time, at the cost of a bit more bookkeeping.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/adapter-vercel/src/transpile.ts` around lines 19 - 38, Update transpileModules to batch all refs into one Bun.build call, using refs.map(ref => ref.sourcePath) for entrypoints and a naming function that maps each generated output back to its corresponding ref.compiledPath. Replace the per-ref build loop with output handling that creates parent directories and writes every result, while preserving failure logging with all build messages.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/adapter-vercel/package.json`:
- Around line 41-43: Add react as an explicit dependency in the adapter-vercel
package alongside `@thexjs/core`, matching the existing import and bundling usage
in generate-entry.ts; do not rely on `@thexjs/core`’s transitive dependency.
In `@packages/adapter-vercel/README.md`:
- Line 14: Add the text language identifier to the fenced code block containing
.vercel/output/ in the README, changing the opening fence to use text while
preserving the block contents.
In `@packages/adapter-vercel/src/bundle-function.ts`:
- Around line 16-53: The bundleRenderFunction flow currently creates entry.mjs
in an OS tmpdir and never removes scratchDir. Generate the entry under the
project build output tree (reuse the existing cleaned coreOutDir if available)
so module resolution uses the project context, and ensure that directory is
removed in a finally block or through the existing cleanup path after bundling
completes or fails.
In `@packages/adapter-vercel/src/generate-entry.ts`:
- Around line 100-106: Update routePatternToRegex to escape regex metacharacters
in literal route segments while preserving the existing :param and * wildcard
conversions. Ensure characters such as ., +, (, and ) are matched literally
rather than interpreted as regex syntax.
- Around line 225-236: Update sendWebResponse to preserve multiple Set-Cookie
values: retrieve them via response.headers.getSetCookie() and pass the resulting
array to res.setHeader for that header, while retaining the existing handling
for all other response headers.
In `@packages/adapter-vercel/src/scan.ts`:
- Around line 77-114: Update route layout assembly and the manifest rootLayout
selection so layouts from options.layoutsDir also wrap the 404 page, using
dedicatedLayouts when no pagesDir layout exists. Preserve dedicated layout scan
order when prepending them to each route’s layoutChain, including when multiple
entries are present; adjust the logic around findLayoutChain and
manifest.rootLayout rather than changing unrelated route handling.
In `@packages/adapter-vercel/src/write-output.ts`:
- Around line 15-25: Update writeConfigJson to create outputDir before
writeFileSync writes config.json, using the existing filesystem utilities and
ensuring recursive creation so fresh builds succeed when the directory is
absent.
In `@packages/cli/src/index.ts`:
- Around line 27-32: Update the argument parsing around the --adapter handling
to reject missing adapter names for both the separate-value form and the
--adapter= form. Validate that the consumed value and sliced value are
non-empty, and fail parsing instead of continuing with the default .x build.
---
Nitpick comments:
In `@packages/adapter-vercel/src/transpile.ts`:
- Around line 19-38: Update transpileModules to batch all refs into one
Bun.build call, using refs.map(ref => ref.sourcePath) for entrypoints and a
naming function that maps each generated output back to its corresponding
ref.compiledPath. Replace the per-ref build loop with output handling that
creates parent directories and writes every result, while preserving failure
logging with all build messages.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 35e406f4-9c06-4d1b-a54e-a3fb0079668a
📒 Files selected for processing (12)
packages/adapter-vercel/README.mdpackages/adapter-vercel/package.jsonpackages/adapter-vercel/src/bundle-function.tspackages/adapter-vercel/src/generate-entry.tspackages/adapter-vercel/src/index.tspackages/adapter-vercel/src/scan.tspackages/adapter-vercel/src/transpile.tspackages/adapter-vercel/src/types.tspackages/adapter-vercel/src/write-output.tspackages/adapter-vercel/tsconfig.jsonpackages/cli/package.jsonpackages/cli/src/index.ts
…d React dependency, and improve error handling in bundle function
… and update cli version to 0.1.4
… for adapter support
Summary by CodeRabbit
--adapter verceloption.