Skip to content

👑feat(#6): add @thexjs/adapter-vercel package for Vercel Build Output API v3 support - #6

Merged
abdelkabirouadoukou merged 5 commits into
mainfrom
@thexjs/adapter-vercel
Jul 29, 2026
Merged

abdelkabirouadoukou merged 5 commits into
mainfrom
@thexjs/adapter-vercel

Conversation

@abdelkabirouadoukou

@abdelkabirouadoukou abdelkabirouadoukou commented Jul 29, 2026 •

Copy link
Copy Markdown
Member
  • 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

Summary by CodeRabbit

  • New Features
    • Added Vercel deployment support through the CLI with the --adapter vercel option.
    • Generates Vercel Build Output API v3 files, including static assets, routing configuration, and server-rendered pages, APIs, actions, and middleware.
    • Added configuration options for output paths, project directories, static assets, and Node runtime.
  • Documentation
    • Added setup, usage, generated output, and known limitations documentation for Vercel deployments.

… 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
@vercel

vercel Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
x Ready Ready Preview, Comment Jul 29, 2026 9:54am

@coderabbitai

coderabbitai Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@abdelkabirouadoukou, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 22 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ce963810-86ac-4c5e-8724-95e03b38d605

📥 Commits

Reviewing files that changed from the base of the PR and between 03ffe37 and 2d5aced.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (11)
  • examples/landing/package.json
  • examples/landing/src/pages/docs/build-deploy.tsx
  • package.json
  • packages/adapter-vercel/README.md
  • packages/adapter-vercel/package.json
  • packages/adapter-vercel/src/bundle-function.ts
  • packages/adapter-vercel/src/generate-entry.ts
  • packages/adapter-vercel/src/scan.ts
  • packages/adapter-vercel/src/write-output.ts
  • packages/cli/package.json
  • packages/cli/src/index.ts
📝 Walkthrough

Walkthrough

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

Changes

Vercel adapter

Layer / File(s) Summary
Adapter contracts and output writers
packages/adapter-vercel/src/types.ts, packages/adapter-vercel/src/write-output.ts, packages/adapter-vercel/package.json, packages/adapter-vercel/tsconfig.json, packages/adapter-vercel/README.md
Defines adapter options and build manifest types, package configuration, Vercel output writers, and usage documentation.
Build manifest resolution
packages/adapter-vercel/src/scan.ts
Scans routes, layouts, middleware, and actions, classifies server-mode modules, and creates deduplicated compiled module references.
Render function compilation
packages/adapter-vercel/src/transpile.ts, packages/adapter-vercel/src/generate-entry.ts, packages/adapter-vercel/src/bundle-function.ts
Transpiles referenced modules, generates request dispatch and Node/Web bridge code, and bundles the render function as index.mjs.
Build Output assembly
packages/adapter-vercel/src/index.ts
Runs the core build, copies static assets, writes Vercel configuration, conditionally creates the render function, and removes temporary files.

CLI adapter selection

Layer / File(s) Summary
CLI adapter selection
packages/cli/src/index.ts, packages/cli/package.json
Adds --adapter, dynamically loads the Vercel adapter, validates adapter names, updates package metadata, and documents the option in help output.

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
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding the @thexjs/adapter-vercel package for Vercel Build Output API v3 support.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🛠️ Fix failing CI checks 💡
  • Fix failing CI checks
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch @thexjs/adapter-vercel

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 8

🧹 Nitpick comments (1)
packages/adapter-vercel/src/transpile.ts (1)

19-38: 🚀 Performance & Scalability | 🔵 Trivial | ⚖️ Poor tradeoff

Consider 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 with entrypoints: refs.map(r => r.sourcePath) plus a naming function mapping back to each ref.compiledPath would 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

📥 Commits

Reviewing files that changed from the base of the PR and between c78671d and 03ffe37.

📒 Files selected for processing (12)
  • packages/adapter-vercel/README.md
  • packages/adapter-vercel/package.json
  • packages/adapter-vercel/src/bundle-function.ts
  • packages/adapter-vercel/src/generate-entry.ts
  • packages/adapter-vercel/src/index.ts
  • packages/adapter-vercel/src/scan.ts
  • packages/adapter-vercel/src/transpile.ts
  • packages/adapter-vercel/src/types.ts
  • packages/adapter-vercel/src/write-output.ts
  • packages/adapter-vercel/tsconfig.json
  • packages/cli/package.json
  • packages/cli/src/index.ts

Comment thread packages/adapter-vercel/package.json Resolved
Comment thread packages/adapter-vercel/README.md Resolved
Comment thread packages/adapter-vercel/src/scan.ts Resolved
Comment thread packages/cli/src/index.ts Resolved
…d React dependency, and improve error handling in bundle function
@abdelkabirouadoukou
abdelkabirouadoukou merged commit 4a5fe95 into main Jul 29, 2026
1 of 2 checks passed
@abdelkabirouadoukou
abdelkabirouadoukou deleted the @thexjs/adapter-vercel branch August 1, 2026 04:37

This branch was successfully deployed

1 active deployment
Preview — 2d5acedb Deployed Jul 29, 2026 by vercel[bot]
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.

1 participant