Skip to content

fix: pin vite ^5 to restore vitest CJS compatibility (fixes test + smoke CI)#117

Merged
chrismaz11 merged 1 commit intomasterfrom
fix/vitest-vite-cjs-compat
Apr 11, 2026
Merged

fix: pin vite ^5 to restore vitest CJS compatibility (fixes test + smoke CI)#117
chrismaz11 merged 1 commit intomasterfrom
fix/vitest-vite-cjs-compat

Conversation

@chrismaz11
Copy link
Copy Markdown
Collaborator

Problem

Both test and signed-receipt-smoke CI jobs fail with:

Error [ERR_REQUIRE_ESM]: require() of ES Module ...node_modules/vite/dist/node/index.js
from ...node_modules/vitest/dist/config.cjs not supported.

Root cause: The project is "type": "commonjs". Vitest 3.x uses a CJS entry (vitest/dist/config.cjs) to bootstrap the config loader, which internally require()s vite. Vite 7 dropped its CJS Node.js API — dist/node/index.js is now pure ESM, so require() fails.

Fix

Add "vite": "^5" to package.json overrides. Vite 5 (5.4.21) retains the CJS compatibility shim that vitest's CJS loader needs. The lockfile is regenerated.

Both serialize-javascript (7.0.5) and vite (5.4.21) overrides coexist cleanly.

Test plan

  • test job passes
  • signed-receipt-smoke job passes
  • All other CI jobs remain green

🤖 Generated with Claude Code

Vite 7 dropped its CJS Node.js API. Since the project is type:commonjs,
vitest's CJS config loader (vitest/dist/config.cjs) fails to require()
vite 7's ESM-only dist/node/index.js with ERR_REQUIRE_ESM.

Pinning vite to ^5 (5.4.21) restores the CJS shim that vitest needs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 11, 2026 19:49
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 11, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
trustsignal Ready Ready Preview, Comment Apr 11, 2026 7:49pm

@chrismaz11 chrismaz11 merged commit c0e1cf4 into master Apr 11, 2026
18 checks passed
@chrismaz11 chrismaz11 deleted the fix/vitest-vite-cjs-compat branch April 11, 2026 19:50
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Pins Vite to the v5 major line via npm overrides to restore Vitest’s CJS config-loader compatibility in this CommonJS repo, resolving the CI failures caused by Vite v7’s ESM-only Node API.

Changes:

  • Add an npm overrides entry to force vite to ^5 (compatible with Vitest’s CJS bootstrap path).
  • Regenerate package-lock.json to resolve vite to 5.4.21 and update related transitive dependencies.

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated no comments.

File Description
package.json Adds overrides.vite = "^5" alongside the existing serialize-javascript override.
package-lock.json Updates the resolved Vite version to 5.4.21 and adjusts Vite’s transitive dependency graph accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants