cloudflare / cloudflare/vinext

`vinext start` runs the Node server for Cloudflare projects and cannot find the Worker build (init advertises it as "Start the built Worker locally with Wrangler")

Open
#2,966 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
8.8k
Forks
406
Avg merge
2d 6h
Merged PRs (30d)
120

Description

## Problem

For a Cloudflare project, `vinext init` presents `start:vinext` as the way to run the built Worker locally:

```
pnpm run start:vinext Start the built Worker locally with Wrangler
```

but the script it writes is `vinext start`, which is the **Node** production server. It never invokes Wrangler, and it looks for build output that a Cloudflare build does not produce, so it fails immediately after a successful build:

```
$ vinext build
✓ built in 9.27s

$ vinext start
[vinext] No build output found in /path/to/app/dist
Run `vinext build` first.
```

`dist/` is populated — just not where the Node server looks.

## Cause

`startProdServer` (`dist/server/prod-server.js`) probes two fixed paths:

```js
const rscEntryPath = path.join(resolvedOutDir, "server", "index.js"); // App Router
const serverEntryPath = path.join(resolvedOutDir, "server", "entry.js"); // Pages Router
const isAppRouter = fs.existsSync(rscEntryPath);
if (!isAppRouter && !fs.existsSync(serverEntryPath)) {
console.error(`[vinext] No build output found in ${outDir}`);
```

With `@cloudflare/vite-plugin`, the Worker is emitted to `dist//index.js` per the plugin's convention, so neither path exists unless the Worker happens to be named `server`.

Even if the path were corrected, running a Cloudflare build under the Node server is the wrong runtime: the point of building for Workers is to exercise it on workerd, where the available APIs differ.

## Reproduction

```sh
vinext init --platform cloudflare --skip-check
vinext build
vinext start # -> "No build output found"
```

Running Wrangler directly against the emitted config does start the Worker:

```sh
wrangler dev --config dist//wrangler.json
```

## Expected

For a project configured for Cloudflare, `vinext start` runs the built Worker on workerd via Wrangler, using the emitted `dist//wrangler.json` — matching what `init` advertises. Node projects keep the current behaviour.

Detecting the platform from the presence of `@cloudflare/vite-plugin` in the Vite config (or a `wrangler.jsonc` in the project root) would let one command do the right thing for both targets. Failing that, `init` should at minimum scaffold a `start:vinext` that calls Wrangler for Cloudflare projects, and the "No build output found" message should mention the Cloudflare output location.

## Environment

- vinext `1.0.0-beta.6`
- `@cloudflare/vite-plugin`, `wrangler` `4.123.0`
- Vite `8.1.0`
- Pages Router, `vinext init --platform cloudflare`

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with the listed vinext init, build, and start commands, then inspect dist/server/prod-server.js and the Cloudflare output under dist/. Verify how the generated start script and emitted dist//wrangler.json are connected; done means Cloudflare projects run the built Worker through Wrangler while Node projects retain their current start behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vite
Domain
build-system, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.