@@ -16,19 +16,21 @@ This approach avoids the critical issue of Rolldown creating shared chunks that
1616
1717### Copied Packages (` dist/@vitest/ ` )
1818
19- These 9 ` @vitest/* ` packages are ** copied** (not bundled) to preserve their original file structure:
20-
21- | Package | Purpose |
22- | ---------------------------- | ---------------------------------------------------- |
23- | ` @vitest/runner ` | Test runner core |
24- | ` @vitest/utils ` | Utilities (source-map, error, display, timers, etc.) |
25- | ` @vitest/spy ` | Spy/mock implementation |
26- | ` @vitest/expect ` | Assertion library |
27- | ` @vitest/snapshot ` | Snapshot testing |
28- | ` @vitest/mocker ` | Module mocking (node, browser, automock) |
29- | ` @vitest/pretty-format ` | Output formatting |
30- | ` @vitest/browser ` | Browser testing support |
31- | ` @vitest/browser-playwright ` | Playwright integration |
19+ These 11 ` @vitest/* ` packages are ** copied** (not bundled) to preserve their original file structure:
20+
21+ | Package | Purpose |
22+ | ----------------------------- | ---------------------------------------------------- |
23+ | ` @vitest/runner ` | Test runner core |
24+ | ` @vitest/utils ` | Utilities (source-map, error, display, timers, etc.) |
25+ | ` @vitest/spy ` | Spy/mock implementation |
26+ | ` @vitest/expect ` | Assertion library |
27+ | ` @vitest/snapshot ` | Snapshot testing |
28+ | ` @vitest/mocker ` | Module mocking (node, browser, automock) |
29+ | ` @vitest/pretty-format ` | Output formatting |
30+ | ` @vitest/browser ` | Browser testing support |
31+ | ` @vitest/browser-playwright ` | Playwright integration |
32+ | ` @vitest/browser-webdriverio ` | WebdriverIO integration |
33+ | ` @vitest/browser-preview ` | Preview (testing-library) integration |
3234
3335** Why copy instead of bundle?** Bundling would create shared chunks that mix browser-safe and Node.js-only code. Copying preserves the original separation.
3436
@@ -73,6 +75,7 @@ These packages are explicitly kept external in `EXTERNAL_BLOCKLIST` during the R
7375| Package | Reason |
7476| ------------------ | ----------------------------------------- |
7577| ` playwright ` | Native bindings, user must install |
78+ | ` webdriverio ` | Native bindings, user must install |
7679| ` debug ` | Environment detection breaks when bundled |
7780| ` happy-dom ` | Optional peer dependency |
7881| ` jsdom ` | Optional peer dependency |
@@ -102,13 +105,21 @@ For maintainers developing the vitest/vite migration feature, here are the trans
102105
103106### Import Rewrites
104107
105- | Original Import | Rewritten Import |
106- | ----------------------------------- | -------------------------------------------------------- |
107- | ` from "@vitest/browser-playwright" ` | ` from "@voidzero-dev/vite-plus-test/browser-playwright" ` |
108- | ` from "vite" ` | ` from "@voidzero-dev/vite-plus-core" ` |
109- | ` from "vite/module-runner" ` | ` from "@voidzero-dev/vite-plus-core/module-runner" ` |
108+ | Original Import | Rewritten Import |
109+ | ------------------------------------ | --------------------------------------------------------- |
110+ | ` from "@vitest/browser-playwright" ` | ` from "@voidzero-dev/vite-plus-test/browser-playwright" ` |
111+ | ` from "@vitest/browser-webdriverio" ` | ` from "@voidzero-dev/vite-plus-test/browser-webdriverio" ` |
112+ | ` from "@vitest/browser-preview" ` | ` from "@voidzero-dev/vite-plus-test/browser-preview" ` |
113+ | ` from "vite" ` | ` from "@voidzero-dev/vite-plus-core" ` |
114+ | ` from "vite/module-runner" ` | ` from "@voidzero-dev/vite-plus-core/module-runner" ` |
110115
111- ** Note:** pnpm overrides don't affect Node.js module resolution at config load time, so config files must use the ` @voidzero-dev/vite-plus-test/browser-playwright ` import path.
116+ ** Note:** When using pnpm overrides, you have three options for browser provider imports:
117+
118+ - ` vitest/browser-playwright ` (or ` vitest/browser-webdriverio ` , ` vitest/browser-preview ` ) - works when ` vitest ` is overridden to our package (Recommended)
119+ - ` @voidzero-dev/vite-plus-test/browser-playwright ` - direct import from test package
120+ - ` @voidzero-dev/vite-plus/test/plugins/browser-playwright ` - direct import from CLI package
121+
122+ Importing from ` @vitest/browser-* ` packages directly requires additional overrides for those specific packages.
112123
113124### package.json Changes
114125
@@ -118,7 +129,9 @@ For maintainers developing the vitest/vite migration feature, here are the trans
118129{
119130 "devDependencies" : {
120131 "@vitest/browser" : " ..." , // Remove
121- "@vitest/browser-playwright" : " ..." , // Remove
132+ "@vitest/browser-playwright" : " ..." , // Remove (if using playwright)
133+ "@vitest/browser-webdriverio" : " ..." , // Remove (if using webdriverio)
134+ "@vitest/browser-preview" : " ..." , // Remove (if using testing-library)
122135 "@vitest/ui" : " ..." // Remove (peer dep, not bundled but optional)
123136 }
124137}
@@ -133,6 +146,8 @@ overrides:
133146 vitest : ' file:path/to/vite-plus-test.tgz'
134147 ' @vitest/browser ' : ' file:path/to/vite-plus-test.tgz'
135148 ' @vitest/browser-playwright ' : ' file:path/to/vite-plus-test.tgz'
149+ ' @vitest/browser-webdriverio ' : ' file:path/to/vite-plus-test.tgz'
150+ ' @vitest/browser-preview ' : ' file:path/to/vite-plus-test.tgz'
136151` ` `
137152
138153Or using npm package names:
@@ -143,33 +158,55 @@ overrides:
143158 vitest : ' npm:@voidzero-dev/vite-plus-test'
144159 ' @vitest/browser ' : ' npm:@voidzero-dev/vite-plus-test'
145160 ' @vitest/browser-playwright ' : ' npm:@voidzero-dev/vite-plus-test'
161+ ' @vitest/browser-webdriverio ' : ' npm:@voidzero-dev/vite-plus-test'
162+ ' @vitest/browser-preview ' : ' npm:@voidzero-dev/vite-plus-test'
146163` ` `
147164
148165### Config File Updates
149166
150167` ` ` typescript
151- // Before
168+ // Before (playwright)
152169import { playwright } from '@vitest/browser-playwright';
153170
154- // After
171+ // After - Option 1 (Recommended) : Via vitest subpath (works when vitest is overridden)
172+ import { playwright } from 'vitest/browser-playwright';
173+
174+ // After - Option 2 : Direct import from test package
155175import { playwright } from '@voidzero-dev/vite-plus-test/browser-playwright';
176+
177+ // After - Option 3 : Direct import from CLI package
178+ import { playwright } from '@voidzero-dev/vite-plus/test/plugins/browser-playwright';
179+ ```
180+
181+ Similarly for WebdriverIO:
182+
183+ ``` typescript
184+ import { webdriverio } from ' vitest/browser-webdriverio' ;
185+ ```
186+
187+ And for Preview (testing-library):
188+
189+ ``` typescript
190+ import { preview } from ' vitest/browser-preview' ;
156191```
157192
158193### Plugin Exports for pnpm Overrides
159194
160195The package provides ` ./plugins/* ` exports to enable pnpm overrides for all ` @vitest/* ` packages:
161196
162197```
163- @vitest/runner -> @voidzero-dev/vite-plus-test/plugins/runner
164- @vitest/utils -> @voidzero-dev/vite-plus-test/plugins/utils
165- @vitest/utils/error -> @voidzero-dev/vite-plus-test/plugins/utils-error
166- @vitest/spy -> @voidzero-dev/vite-plus-test/plugins/spy
167- @vitest/expect -> @voidzero-dev/vite-plus-test/plugins/expect
168- @vitest/snapshot -> @voidzero-dev/vite-plus-test/plugins/snapshot
169- @vitest/mocker -> @voidzero-dev/vite-plus-test/plugins/mocker
170- @vitest/pretty-format -> @voidzero-dev/vite-plus-test/plugins/pretty-format
171- @vitest/browser -> @voidzero-dev/vite-plus-test/plugins/browser
172- @vitest/browser-playwright -> @voidzero-dev/vite-plus-test/plugins/browser-playwright
198+ @vitest/runner -> @voidzero-dev/vite-plus-test/plugins/runner
199+ @vitest/utils -> @voidzero-dev/vite-plus-test/plugins/utils
200+ @vitest/utils/error -> @voidzero-dev/vite-plus-test/plugins/utils-error
201+ @vitest/spy -> @voidzero-dev/vite-plus-test/plugins/spy
202+ @vitest/expect -> @voidzero-dev/vite-plus-test/plugins/expect
203+ @vitest/snapshot -> @voidzero-dev/vite-plus-test/plugins/snapshot
204+ @vitest/mocker -> @voidzero-dev/vite-plus-test/plugins/mocker
205+ @vitest/pretty-format -> @voidzero-dev/vite-plus-test/plugins/pretty-format
206+ @vitest/browser -> @voidzero-dev/vite-plus-test/plugins/browser
207+ @vitest/browser-playwright -> @voidzero-dev/vite-plus-test/plugins/browser-playwright
208+ @vitest/browser-webdriverio -> @voidzero-dev/vite-plus-test/plugins/browser-webdriverio
209+ @vitest/browser-preview -> @voidzero-dev/vite-plus-test/plugins/browser-preview
173210```
174211
175212---
@@ -247,21 +284,22 @@ When upgrading the vitest version:
247284### Build Flow
248285
249286```
250- 1. bundleVitest() Copy vitest-dev dist/ -> dist/
251- 2. copyVitestPackages() Copy @vitest/* -> dist/@vitest/
252- 3. convertTabsToSpaces() Normalize formatting for patches
253- 4. collectLeafDependencies() Parse imports with oxc-parser
254- 5. bundleLeafDeps() Bundle chai, pathe, etc -> dist/vendor/
255- 6. rewriteVitestImports() Rewrite @vitest/*, vitest/*, vite
256- 7. patchVitestPkgRootPaths() Fix distRoot for relocated files
287+ 1. bundleVitest() Copy vitest-dev dist/ -> dist/
288+ 2. copyVitestPackages() Copy @vitest/* -> dist/@vitest/
289+ 3. convertTabsToSpaces() Normalize formatting for patches
290+ 4. collectLeafDependencies() Parse imports with oxc-parser
291+ 5. bundleLeafDeps() Bundle chai, pathe, etc -> dist/vendor/
292+ 6. rewriteVitestImports() Rewrite @vitest/*, vitest/*, vite
293+ 7. patchVitestPkgRootPaths() Fix distRoot for relocated files
2572948. patchVitestBrowserPackage() Inject vendor-aliases plugin
258- 9. patchPlaywrightLocators () Fix browser-safe imports
295+ 9. patchBrowserProviderLocators () Fix browser-safe imports
25929610. Post-processing:
260297 - patchVendorPaths()
261298 - createBrowserCompatShim()
262299 - createModuleRunnerStub() Browser-safe stub
263300 - createNodeEntry() index-node.js with browser-provider
264301 - copyBrowserClientFiles()
302+ - createBrowserEntryFiles() browser/ entry files at package root
265303 - createPluginExports() dist/plugins/* for pnpm overrides
266304 - mergePackageJson()
267305 - validateExternalDeps()
@@ -270,6 +308,9 @@ When upgrading the vitest version:
270308### Output Structure
271309
272310```
311+ browser/ # Entry files for ./browser export
312+ ├── context.js # Runtime guard (throws if not in browser)
313+ └── context.d.ts # Re-exports from dist/@vitest/browser/context.d.ts
273314dist/
274315├── @vitest/ # Copied packages (browser/Node.js safe)
275316│ ├── runner/
@@ -315,7 +356,13 @@ This is achieved through:
3153561 . Conditional exports in package.json (` "node": "./dist/index-node.js" ` )
3163572 . Browser-safe stubs for ` module-runner `
3173583 . Import rewriting to prevent Node.js code from being pulled into browser bundles
318- 4 . ` vendor-aliases ` plugin injection to resolve imports at runtime
359+ 4 . ` vendor-aliases ` plugin injection to resolve imports at runtime:
360+ - Handles ` @vitest/* ` imports → resolves to copied ` dist/@vitest/ ` files
361+ - Handles ` vitest/* ` subpaths → resolves to dist files (enables ` vitest/browser-playwright ` usage)
362+ - Handles ` vitest/browser-playwright ` , ` vitest/browser-webdriverio ` , ` vitest/browser-preview ` → resolves to bundled browser providers
363+ - Handles ` @voidzero-dev/vite-plus-test/* ` subpaths → maps to equivalent vitest paths
364+ - Handles ` @voidzero-dev/vite-plus/test/* ` subpaths → maps to equivalent vitest paths (CLI package)
365+ - Intercepts ` vitest/browser ` , ` @voidzero-dev/vite-plus-test/browser ` , ` @voidzero-dev/vite-plus/test/browser ` → returns virtual module ID for BrowserContext plugin
319366
320367### Key Constants
321368
@@ -331,6 +378,8 @@ const VITEST_PACKAGES_TO_COPY = [
331378 ' @vitest/pretty-format' ,
332379 ' @vitest/browser' ,
333380 ' @vitest/browser-playwright' ,
381+ ' @vitest/browser-webdriverio' ,
382+ ' @vitest/browser-preview' ,
334383];
335384
336385// Packages that must NOT be bundled (from build.ts lines 131-158)
@@ -350,6 +399,7 @@ const EXTERNAL_BLOCKLIST = new Set([
350399 // Optional dependencies with bundling issues or native bindings
351400 ' debug' , // environment detection broken when bundled
352401 ' playwright' , // native bindings
402+ ' webdriverio' , // native bindings
353403
354404 // Runtime deps (in package.json dependencies) - not bundled, resolved at install time
355405 ' sirv' ,
0 commit comments