Skip to content

Tracking: vinext dev is unusable for this app — every route 404s (workerd/no-fs) or 500s (dev module-runner can't CJS-interop the per-request MDX compile chain) #16

Description

@hyf0

Tracking issue for vinext dev being unusable on this app (reactjs/react.dev, Pages Router). vinext build && vinext start works perfectly; only the dev server is broken. There are two stacked failure modes depending on whether @cloudflare/vite-plugin is active. Related: #6 (a narrow slice of the CJS issue below), #14 (the cloudflare-in-dev half), #15 (why the compile chain runs per-request at all).

Symptom A — with cloudflare() in vite.config (the config vinext deploy requires): every route 404s

vinext deploy requires cloudflare() in a custom vite.config, and it runs unconditionally, so it's active in dev too. @cloudflare/vite-plugin runs the app in workerd, which has no fs. This app's catch-all getStaticProps reads content from disk (see #15), so every page throws and the dev server returns:

GET /                    -> 404   (content-length: 0, no error in the log)
GET /learn               -> 404
GET /learn/installation  -> 404
GET /api/md              -> 404
GET /robots.txt          -> 200   (static assets still serve)
GET /favicon.ico         -> 200

A bare 404 with an empty body and no log line makes this very hard to trace — it looks like routing is half-broken rather than "the page handler threw in workerd".

Symptom B — with cloudflare() gated off (dev runs in Node): cascading CJS-interop crashes

Because vinext doesn't prerender in dev (#15), every request runs the full build-time MDX compile chain (remark/retext/babel + metro-cache). vinext's dev SSR module-runner inlines those (old, CJS) packages without CJS interop, so each one throws require/exports/module is not defined. They surface one at a time; each can be silenced by adding it to optimizeDeps.include (+ ssr.optimizeDeps.include), which just reveals the next:

node_modules/parse-numeric-range/index.js   ReferenceError: exports is not defined   (fatal — dev server exits)
node_modules/tailwindcss/defaultTheme.js    ReferenceError: require is not defined    (fatal)
node_modules/debounce/index.js              ReferenceError: module is not defined     (now per-request 500)
node_modules/metro-cache/src/index.js       ReferenceError: require is not defined
node_modules/remark/index.js                ReferenceError: require is not defined
… still ahead: remark-external-links, remark-images, remark-unwrap-images,
   remark-html, retext, retext-smartypants, mdast-util-to-string, unist-util-visit, …

Getting dev to boot this way needs an ~18-entry optimizeDeps.include list that is fragile (breaks whenever any of those transitive packages changes), and dev would still recompile all MDX on every request (slow). Note the first two crashes are fatal (the dev server process exits), not per-request errors.

Root cause

  1. cloudflare() can't be scoped to the deploy build, so dev inherits workerd (no fs) → vinext deploy with a custom vite.config fails on missing cloudflare() (and the local-vs-deploy wrangler.jsonc story) #14.
  2. vinext dev executes getStaticProps per request instead of prerendering (Pages Router: getStaticProps runs per-request instead of prerendering → fs-backed SSG apps 500 on Cloudflare Workers (needs --prerender-all) #15), dragging the entire build-time compile chain onto the request path, where the dev module-runner can't CJS-interop it (vinext dev SSR module-runner doesn't CJS-interop UMD/CJS deps (classnames window, parse-numeric-range exports) #6 is the first two entries of the list above).

What works today

vinext build --prerender-all && vinext start — all routes 200, real content, no per-request compilation. So the recommended local workflow is vinext start, and this issue tracks making vinext dev actually usable.

Suggestions

Related upstream (cloudflare/vinext)

Environment

vinext 0.1.8, Vite 8.1, Node 24, Pages Router, macOS.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1: highReal bug, cheap fix, do soonarea: devvinext dev experience

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions