mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
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#381
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/197
Author: @yunus25jmi1
Created: 2/28/2026
Status: ✅ Merged
Merged: 3/8/2026
Merged by: @james-elicx
Base:
main← Head:fix/issue-184-cloudflare-plugin-esm-require📝 Commits (1)
c322986fix(cli): ensure type:module before Vite loads vite.config.ts (fixes #184)📊 Changes
3 files changed (+226 additions, -1 deletions)
View changed files
📝
packages/vinext/src/cli.ts(+39 -1)📝
packages/vinext/src/utils/project.ts(+52 -0)📝
tests/deploy.test.ts(+135 -0)📄 Description
Problem
Projects without
"type": "module"inpackage.jsoncause Vite to bundlevite.config.tsthrough esbuild's CJS path, producing a.vite-temp/*.timestamp.mjsfile that containsrequire()calls for the imported plugins. On Node 22 in CI (GitHub Actions, ubuntu-latest),require()-ing a.mjsfile is not supported and the build fails immediately:The affected user had set up their project manually (without
vinext init) or before theinitstep added"type": "module".vinext initalready adds this field, butvinext dev/vinext buildwere not enforcing it.Fix
Call
ensureESModule(root)+renameCJSConfigs(root)in both thedev()andbuildApp()CLI commands, before Vite is loaded. This reuses the same logic already used byvinext init.renameCJSConfigsrenamespostcss.config.js/tailwind.config.js/.eslintrc.jsetc. →.cjsfirst, preventing breakage in those files once"type": "module"is addedensureESModuleadds"type": "module"topackage.jsonvinext initto make it permanentTests
9 new unit tests added to
tests/deploy.test.tsunder the describe block "ensureESModule + renameCJSConfigs — issue #184 compatibility":type:modulewhen missingfalsewhen nopackage.jsonexistspostcss.config.js→postcss.config.cjsbefore addingtype:modulepostcss.config.js(nomodule.exportsorrequire())tailwind.config.jswhen CJS.eslintrc.jswhen CJSrequire()(not onlymodule.exports)All 169 tests pass (
pnpm exec vitest run tests/deploy.test.ts).Fixes #184
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.