[GH-ISSUE #184] vinext build fails in CI (GitHub Actions): Dynamic require of @cloudflare/vite-plugin not supported in ESM context #40

Closed
opened 2026-05-06 12:36:45 +02:00 by BreizhHardware · 0 comments

Originally created by @justinfinnn on GitHub (Feb 28, 2026).
Original GitHub issue: https://github.com/cloudflare/vinext/issues/184

Bug

vinext build fails in GitHub Actions (Ubuntu runner) with:

failed to load config from /home/runner/work/.../apps/web/vite.config.ts
Error: Dynamic require of "file:///home/runner/work/.../node_modules/@cloudflare/vite-plugin/dist/index.mjs" is not supported
    at file:///.../apps/web/node_modules/.vite-temp/vite.config.ts.timestamp-xxx.mjs:5:9

Environment

  • vinext: 0.0.13
  • Node: 22.x (GitHub Actions ubuntu-latest)
  • React: 19.2.0
  • Next.js: 15.2.x
  • Package manager: Yarn 1 (monorepo workspaces)

Steps to reproduce

  1. Set up a Next.js app with vite.config.ts using @cloudflare/vite-plugin
  2. Run vinext build in a GitHub Actions CI environment (ubuntu-latest, Node 22)
  3. Build fails immediately — the vite config cannot be loaded

Root cause

The vite.config.ts generated/used by vinext imports @cloudflare/vite-plugin via CommonJS require(). In Node 22's strict ESM context on Linux CI runners, dynamic require() of an .mjs file is not supported.

Workaround

Use next build followed by wrangler deploy separately instead of vinext build / vinext deploy:

next build && wrangler deploy

This bypasses vinext's Vite layer for the build step entirely.

Expected behavior

vinext build should work in standard CI environments (GitHub Actions, ubuntu-latest, Node 22) without requiring workarounds.

Originally created by @justinfinnn on GitHub (Feb 28, 2026). Original GitHub issue: https://github.com/cloudflare/vinext/issues/184 ## Bug `vinext build` fails in GitHub Actions (Ubuntu runner) with: ``` failed to load config from /home/runner/work/.../apps/web/vite.config.ts Error: Dynamic require of "file:///home/runner/work/.../node_modules/@cloudflare/vite-plugin/dist/index.mjs" is not supported at file:///.../apps/web/node_modules/.vite-temp/vite.config.ts.timestamp-xxx.mjs:5:9 ``` ## Environment - vinext: 0.0.13 - Node: 22.x (GitHub Actions ubuntu-latest) - React: 19.2.0 - Next.js: 15.2.x - Package manager: Yarn 1 (monorepo workspaces) ## Steps to reproduce 1. Set up a Next.js app with `vite.config.ts` using `@cloudflare/vite-plugin` 2. Run `vinext build` in a GitHub Actions CI environment (ubuntu-latest, Node 22) 3. Build fails immediately — the vite config cannot be loaded ## Root cause The `vite.config.ts` generated/used by vinext imports `@cloudflare/vite-plugin` via CommonJS `require()`. In Node 22's strict ESM context on Linux CI runners, dynamic `require()` of an `.mjs` file is not supported. ## Workaround Use `next build` followed by `wrangler deploy` separately instead of `vinext build` / `vinext deploy`: ```bash next build && wrangler deploy ``` This bypasses vinext's Vite layer for the build step entirely. ## Expected behavior `vinext build` should work in standard CI environments (GitHub Actions, ubuntu-latest, Node 22) without requiring workarounds.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#40
No description provided.