Skip to content

fix(test): resolve ws CJS named export error with cloudflare preset#855

Merged
fengmk2 merged 1 commit intomainfrom
fix-bug-831
Mar 16, 2026
Merged

fix(test): resolve ws CJS named export error with cloudflare preset#855
fengmk2 merged 1 commit intomainfrom
fix-bug-831

Conversation

@fengmk2
Copy link
Member

@fengmk2 fengmk2 commented Mar 14, 2026

closes #831

When Nuxt's cloudflare preset is active, vitest passes --conditions browser
to worker processes. This caused ws to resolve to its browser stub
(ws/browser.js) instead of the ESM wrapper (ws/wrapper.mjs), because
the test package's node export condition loaded index-node.js which
imports @vitest/browser/index.jsws.

Fix by adding a browser export condition before node in the test
package's main export. When --conditions browser is active, browser
matches first and resolves to dist/index.js (which doesn't pull in
@vitest/browser), avoiding the ws resolution issue.

Also fix ecosystem-ci patch-project.ts to apply pnpm overrides for
projects that already use Vite+ (previously skipped by vp migrate),
and add the reproduction repo as an e2e test case.

@netlify
Copy link

netlify bot commented Mar 14, 2026

Deploy Preview for viteplus-preview canceled.

Name Link
🔨 Latest commit e8f85d8
🔍 Latest deploy log https://app.netlify.com/projects/viteplus-preview/deploys/69b78698d4b84a0008345f5d

@fengmk2 fengmk2 self-assigned this Mar 14, 2026
Copy link
Member Author

fengmk2 commented Mar 14, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@fengmk2 fengmk2 marked this pull request as ready for review March 14, 2026 08:40
@fengmk2 fengmk2 requested a review from Brooooooklyn March 14, 2026 08:40
Copy link
Member Author

fengmk2 commented Mar 14, 2026

@fengmk2 fengmk2 force-pushed the fix-bug-831 branch 3 times, most recently from 8024203 to 0f68087 Compare March 14, 2026 13:09
Copy link
Member Author

fengmk2 commented Mar 14, 2026

1 similar comment
Copy link
Member Author

fengmk2 commented Mar 14, 2026

closes #831

When Nuxt's cloudflare preset is active, vitest passes `--conditions browser`
to worker processes. This caused `ws` to resolve to its browser stub
(`ws/browser.js`) instead of the ESM wrapper (`ws/wrapper.mjs`), because
the test package's `node` export condition loaded `index-node.js` which
imports `@vitest/browser/index.js` → `ws`.

Fix by adding a `browser` export condition before `node` in the test
package's main export. When `--conditions browser` is active, `browser`
matches first and resolves to `dist/index.js` (which doesn't pull in
`@vitest/browser`), avoiding the ws resolution issue.

Also fix ecosystem-ci `patch-project.ts` to apply pnpm overrides for
projects that already use Vite+ (previously skipped by `vp migrate`),
and add the reproduction repo as an e2e test case.
Copy link
Member Author

fengmk2 commented Mar 16, 2026

Merge activity

  • Mar 16, 4:27 AM UTC: Graphite rebased this pull request as part of a merge.
  • Mar 16, 4:35 AM UTC: @fengmk2 merged this pull request with Graphite.

@fengmk2 fengmk2 merged commit 708734d into main Mar 16, 2026
39 checks passed
@fengmk2 fengmk2 deleted the fix-bug-831 branch March 16, 2026 04:35
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.

vp test fails with ws CJS named export error when nitro.preset is cloudflare_module

2 participants