fix(test): resolve ws CJS named export error with cloudflare preset#855
Open
fix(test): resolve ws CJS named export error with cloudflare preset#855
Conversation
✅ Deploy Preview for viteplus-preview canceled.
|
Member
Author
a33e566 to
8024203
Compare
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.
Member
Author
1 similar comment
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

closes #831
When Nuxt's cloudflare preset is active, vitest passes
--conditions browserto worker processes. This caused
wsto resolve to its browser stub(
ws/browser.js) instead of the ESM wrapper (ws/wrapper.mjs), becausethe test package's
nodeexport condition loadedindex-node.jswhichimports
@vitest/browser/index.js→ws.Fix by adding a
browserexport condition beforenodein the testpackage's main export. When
--conditions browseris active,browsermatches 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.tsto apply pnpm overrides forprojects that already use Vite+ (previously skipped by
vp migrate),and add the reproduction repo as an e2e test case.