mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #198] [MERGED] feat: add CJS support via vite-plugin-commonjs #382
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#382
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/198
Author: @zebp
Created: 2/28/2026
Status: ✅ Merged
Merged: 2/28/2026
Merged by: @southpolesteve
Base:
main← Head:zeb/cjs-support📝 Commits (4)
6d28583feat: add CJS support via vite-plugin-commonjs0f4e129fix: use buildViteConfig() for Pages Router production builds06df250fix: move server-only-violation fixture to isolated directory2d13350fix: address review feedback from bonk📊 Changes
21 files changed (+392 additions, -11 deletions)
View changed files
📝
packages/vinext/package.json(+1 -0)📝
packages/vinext/src/cli.ts(+7 -11)📝
packages/vinext/src/index.ts(+4 -0)📝
pnpm-lock.yaml(+163 -0)➕
tests/cjs.test.ts(+59 -0)➕
tests/e2e/app-router/cjs.spec.ts(+28 -0)➕
tests/e2e/pages-router/cjs.spec.ts(+13 -0)➕
tests/fixtures/app-basic/app/cjs/basic/page.tsx(+5 -0)➕
tests/fixtures/app-basic/app/cjs/basic/random.ts(+3 -0)➕
tests/fixtures/app-basic/app/cjs/server-only/page.tsx(+5 -0)➕
tests/fixtures/app-cjs-violation/app/cjs/server-only-violation/client-component.tsx(+7 -0)➕
tests/fixtures/app-cjs-violation/app/cjs/server-only-violation/page.tsx(+10 -0)➕
tests/fixtures/app-cjs-violation/app/cjs/server-only-violation/server-lib.ts(+5 -0)➕
tests/fixtures/app-cjs-violation/app/global-error.tsx(+25 -0)➕
tests/fixtures/app-cjs-violation/app/layout.tsx(+15 -0)➕
tests/fixtures/app-cjs-violation/app/page.tsx(+3 -0)➕
tests/fixtures/app-cjs-violation/package.json(+13 -0)➕
tests/fixtures/app-cjs-violation/tsconfig.json(+12 -0)➕
tests/fixtures/app-cjs-violation/vite.config.ts(+6 -0)➕
tests/fixtures/pages-basic/pages/cjs/basic.tsx(+5 -0)...and 1 more files
📄 Description
Add vite-plugin-commonjs to handle require() and module.exports in both App Router and Pages Router. This enables CJS interop in server components and pages, including CJS require('server-only') boundary enforcement by @vitejs/plugin-rsc.
Fixes #164
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.