vite-plus 0.1.24 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/LICENSE +30 -0
  2. package/README.md +8 -6
  3. package/bin/oxfmt +5 -2
  4. package/bin/oxlint +12 -2
  5. package/binding/index.cjs +84 -67
  6. package/binding/index.d.cts +155 -4
  7. package/dist/{agent-Nuk-9l77.js → agent--cKmgD_n.js} +941 -70
  8. package/dist/bin.js +22 -30
  9. package/dist/{compat-DXZgnEyq.js → compat-Cql3K40m.js} +1 -1
  10. package/dist/config/bin.js +30 -14
  11. package/dist/constants-CrfJQIUX.js +66 -0
  12. package/dist/create/bin.d.ts +6 -0
  13. package/dist/create/bin.js +508 -232
  14. package/dist/define-config-2tfJoXr1.d.ts +305 -0
  15. package/dist/define-config-BGSjF6Xp.cjs +488 -0
  16. package/dist/define-config-DJUehepE.js +445 -0
  17. package/dist/define-config.cjs +8 -1
  18. package/dist/define-config.d.ts +2 -2
  19. package/dist/define-config.js +2 -2
  20. package/dist/dist-DRJUd9bL.js +3 -0
  21. package/dist/{dist-BgQuvbtq.js → dist-Oxo16Y0q.js} +4 -4
  22. package/dist/index.cjs +9 -4
  23. package/dist/index.d.ts +3 -3
  24. package/dist/index.js +3 -3
  25. package/dist/{main-DpJl3LoU.js → json-Dn87fvjk.js} +137 -1
  26. package/dist/migration/bin.js +292 -76
  27. package/dist/{oxlint-plugin-config-B89iKTKN.js → oxlint-plugin-config-q8a5PFch.js} +1 -1
  28. package/dist/oxlint-plugin.js +11 -3
  29. package/dist/pack-bin.js +44 -15
  30. package/dist/{package-PmBUZ-ve.js → package-BHirM1_v.js} +3 -138
  31. package/dist/{report-DgSBQUdz.js → report-BHSkWqRR.js} +2 -0
  32. package/dist/{resolve-vite-config-TTvhycU1.js → resolve-vite-config-CmdsfQzS.js} +13 -4
  33. package/dist/staged/bin.js +5 -5
  34. package/dist/test/_at-vitest-browser/context.d.ts +2 -0
  35. package/dist/test/_at-vitest-browser.d.ts +2 -0
  36. package/dist/test/browser/context.d.ts +2 -2
  37. package/dist/test/browser/context.js +1 -1
  38. package/dist/test/browser/providers/playwright/context.d.ts +1 -0
  39. package/dist/test/browser/providers/playwright/context.js +1 -0
  40. package/dist/test/browser/providers/playwright.d.ts +124 -2
  41. package/dist/test/browser/providers/playwright.js +1 -1
  42. package/dist/test/browser/providers/preview/context.d.ts +1 -0
  43. package/dist/test/browser/providers/preview/context.js +1 -0
  44. package/dist/test/browser/providers/preview.d.ts +32 -2
  45. package/dist/test/browser/providers/preview.js +1 -1
  46. package/dist/test/browser/providers/webdriverio/context.d.ts +1 -0
  47. package/dist/test/browser/providers/webdriverio/context.js +1 -0
  48. package/dist/test/browser/providers/webdriverio.d.ts +77 -2
  49. package/dist/test/browser/providers/webdriverio.js +1 -1
  50. package/dist/test/browser-compat.d.ts +2 -0
  51. package/dist/test/browser-compat.js +1 -1
  52. package/dist/test/browser-playwright/context.d.ts +1 -0
  53. package/dist/test/browser-playwright/context.js +1 -0
  54. package/dist/test/browser-playwright.d.ts +124 -2
  55. package/dist/test/browser-playwright.js +1 -1
  56. package/dist/test/browser-preview/context.d.ts +1 -0
  57. package/dist/test/browser-preview/context.js +1 -0
  58. package/dist/test/browser-preview.d.ts +32 -2
  59. package/dist/test/browser-preview.js +1 -1
  60. package/dist/test/browser-webdriverio/context.d.ts +1 -0
  61. package/dist/test/browser-webdriverio/context.js +1 -0
  62. package/dist/test/browser-webdriverio.d.ts +77 -2
  63. package/dist/test/browser-webdriverio.js +1 -1
  64. package/dist/test/browser.d.ts +2 -2
  65. package/dist/test/browser.js +1 -1
  66. package/dist/test/client.js +1 -1
  67. package/dist/test/config.cjs +1 -1
  68. package/dist/test/config.d.ts +2 -2
  69. package/dist/test/config.js +1 -1
  70. package/dist/test/context.d.ts +942 -2
  71. package/dist/test/context.js +1 -1
  72. package/dist/test/coverage.d.ts +2 -2
  73. package/dist/test/coverage.js +1 -1
  74. package/dist/test/environments.d.ts +2 -2
  75. package/dist/test/environments.js +1 -1
  76. package/dist/test/globals.d.ts +2 -2
  77. package/dist/test/import-meta.d.ts +2 -2
  78. package/dist/test/importMeta.d.ts +2 -2
  79. package/dist/test/index.cjs +1 -1
  80. package/dist/test/index.d.cts +2 -2
  81. package/dist/test/index.d.ts +2 -2
  82. package/dist/test/index.js +1 -1
  83. package/dist/test/internal/browser.d.ts +2 -2
  84. package/dist/test/internal/browser.js +1 -1
  85. package/dist/test/jsdom.d.ts +2 -2
  86. package/dist/test/locators.d.ts +294 -0
  87. package/dist/test/locators.js +1 -1
  88. package/dist/test/matchers.d.ts +29 -0
  89. package/dist/test/matchers.js +1 -1
  90. package/dist/test/node.d.ts +2 -2
  91. package/dist/test/node.js +1 -1
  92. package/dist/test/optional-runtime-types.js.d.ts +2 -2
  93. package/dist/test/optional-types.js.d.ts +2 -2
  94. package/dist/test/plugins/browser-client.js +1 -1
  95. package/dist/test/plugins/browser-context.js +1 -1
  96. package/dist/test/plugins/browser-locators.js +1 -1
  97. package/dist/test/plugins/browser-playwright.js +1 -1
  98. package/dist/test/plugins/browser-preview.js +1 -1
  99. package/dist/test/plugins/browser-webdriverio.js +1 -1
  100. package/dist/test/plugins/browser.js +1 -1
  101. package/dist/test/plugins/expect.js +1 -1
  102. package/dist/test/plugins/mocker-automock.js +1 -1
  103. package/dist/test/plugins/mocker-browser.js +1 -1
  104. package/dist/test/plugins/mocker-node.js +1 -1
  105. package/dist/test/plugins/mocker-redirect.js +1 -1
  106. package/dist/test/plugins/mocker-register.js +1 -1
  107. package/dist/test/plugins/mocker-transforms.js +1 -1
  108. package/dist/test/plugins/mocker.js +1 -1
  109. package/dist/test/plugins/pretty-format.js +1 -1
  110. package/dist/test/plugins/runner-types.js +1 -1
  111. package/dist/test/plugins/runner-utils.js +1 -1
  112. package/dist/test/plugins/runner.js +1 -1
  113. package/dist/test/plugins/snapshot-environment.js +1 -1
  114. package/dist/test/plugins/snapshot-manager.js +1 -1
  115. package/dist/test/plugins/snapshot.js +1 -1
  116. package/dist/test/plugins/spy.js +1 -1
  117. package/dist/test/plugins/utils-constants.js +1 -1
  118. package/dist/test/plugins/utils-diff.js +1 -1
  119. package/dist/test/plugins/utils-display.js +1 -1
  120. package/dist/test/plugins/utils-error.js +1 -1
  121. package/dist/test/plugins/utils-helpers.js +1 -1
  122. package/dist/test/plugins/utils-offset.js +1 -1
  123. package/dist/test/plugins/utils-resolver.js +1 -1
  124. package/dist/test/plugins/utils-serialize.js +1 -1
  125. package/dist/test/plugins/utils-source-map-node.js +1 -1
  126. package/dist/test/plugins/utils-source-map.js +1 -1
  127. package/dist/test/plugins/utils-timers.js +1 -1
  128. package/dist/test/plugins/utils.js +1 -1
  129. package/dist/test/reporters.d.ts +2 -2
  130. package/dist/test/reporters.js +1 -1
  131. package/dist/test/runners.d.ts +2 -2
  132. package/dist/test/runners.js +1 -1
  133. package/dist/test/runtime.d.ts +2 -2
  134. package/dist/test/runtime.js +1 -1
  135. package/dist/test/snapshot.d.ts +2 -2
  136. package/dist/test/snapshot.js +1 -1
  137. package/dist/test/suite.d.ts +2 -2
  138. package/dist/test/suite.js +1 -1
  139. package/dist/test/utils.js +1 -1
  140. package/dist/test/worker.d.ts +2 -2
  141. package/dist/test/worker.js +1 -1
  142. package/dist/{tsconfig-DFb5BKyT.js → tsconfig-BWQPmGKz.js} +565 -231
  143. package/dist/tsgolint-path-B-yOos8p.js +32 -0
  144. package/dist/tsgolint-path.d.ts +8 -0
  145. package/dist/tsgolint-path.js +2 -0
  146. package/dist/version.js +3 -3
  147. package/dist/versions.d.ts +1 -1
  148. package/dist/versions.js +6 -6
  149. package/dist/{workspace-NL-m9wgM.js → workspace-D0AVy4fu.js} +11 -9
  150. package/docs/_data/team.ts +2 -1
  151. package/docs/config/create.md +36 -1
  152. package/docs/config/index.md +7 -5
  153. package/docs/guide/commit-hooks.md +9 -0
  154. package/docs/guide/create.md +106 -2
  155. package/docs/guide/env.md +33 -5
  156. package/docs/guide/index.md +5 -3
  157. package/docs/guide/install.md +31 -12
  158. package/docs/guide/migrate.md +13 -3
  159. package/docs/guide/troubleshooting.md +2 -2
  160. package/docs/guide/upgrade.md +26 -7
  161. package/docs/package.json +3 -3
  162. package/docs/pnpm-lock.yaml +298 -395
  163. package/package.json +103 -55
  164. package/templates/generator/bin/index.ts +6 -3
  165. package/templates/generator/package.json +2 -3
  166. package/templates/generator/src/template.ts +0 -2
  167. package/templates/monorepo/package.json +1 -1
  168. package/dist/constants-DCBWlNrn.js +0 -33
  169. package/dist/define-config-BR1Y88zz.cjs +0 -84
  170. package/dist/define-config-BRC7qPNE.js +0 -21
  171. package/dist/define-config-COdn-tsn.d.ts +0 -177
  172. package/dist/dist-Bapm49IR.js +0 -3
  173. package/dist/test/plugins/utils-highlight.js +0 -1
  174. /package/dist/{chunk-DnnnRqeS.js → rolldown-runtime-DnnnRqeS.js} +0 -0
@@ -0,0 +1,445 @@
1
+ import { a as VITEST_VERSION } from "./constants-CrfJQIUX.js";
2
+ import { createRequire } from "node:module";
3
+ import path from "node:path";
4
+ import { readFileSync } from "node:fs";
5
+ import { fileURLToPath } from "node:url";
6
+ import { defineConfig, defineProject } from "vitest/config";
7
+ //#region ../../node_modules/.pnpm/tsdown@0.22.3_@arethetypeswrong+core@0.18.2_@tsdown+css@0.22.3_@tsdown+exe@0.22.3_@type_701dbb346589e2d965113664da5ac600/node_modules/tsdown/esm-shims.js
8
+ const getFilename = () => fileURLToPath(import.meta.url);
9
+ const getDirname = () => path.dirname(getFilename());
10
+ const __dirname = /* @__PURE__ */ getDirname();
11
+ //#endregion
12
+ //#region src/define-config.ts
13
+ /**
14
+ * `require` anchored at THIS module's location so `require.resolve` reaches
15
+ * the `vitest` / `@vitest/*` family that the `vite-plus` package directly
16
+ * depends on — even from a consumer project where they are only transitive.
17
+ * Used to locate the bundled `vitest` package (its `package.json`), NOT to
18
+ * resolve module ENTRIES: `require.resolve` applies the `require` export
19
+ * condition, which selects Vitest's CJS entries — for the bare `vitest` root
20
+ * a throw-stub (`index.cjs` — "Vitest cannot be imported … using require()"),
21
+ * and for subpaths the CJS build (e.g. `vitest/config` → `config.cjs`) rather
22
+ * than the ESM entry the test server's module graph needs. Module entries are
23
+ * resolved through Vite's own resolver instead (see
24
+ * [[vitePlusVitestResolverPlugin]]), which honours ESM conditions.
25
+ *
26
+ * `define-config.ts` is bundled by tsdown in BOTH formats: ESM (`shims: true`,
27
+ * which defines a module-scoped `__dirname`) and CJS (where `__dirname` is the
28
+ * Node global). The guard picks `__dirname` whenever it exists and otherwise
29
+ * falls back to `import.meta.url`; tsdown rewrites the latter to
30
+ * `pathToFileURL(__filename).href` in the CJS bundle, so it is safe in both.
31
+ */
32
+ const vitePlusRequire = createRequire(typeof __dirname !== "undefined" ? __dirname : import.meta.url);
33
+ /**
34
+ * Absolute path to THIS module, used as a `this.resolve` importer so Vite's
35
+ * resolver roots the `vitest` / `@vitest/*` family at `vite-plus`'s own
36
+ * location — reaching its direct deps (`vitest`, `vitest/*`, `@vitest/browser*`)
37
+ * even from a consumer project where they are only transitive.
38
+ *
39
+ * `import.meta.url` is native in the ESM bundle and rewritten by tsdown to
40
+ * `pathToFileURL(__filename).href` in the CJS bundle, so it is a valid file URL
41
+ * in both.
42
+ */
43
+ const vitePlusModuleFile = fileURLToPath(import.meta.url);
44
+ /**
45
+ * Absolute path to the bundled `vitest` package's `package.json`, used as a
46
+ * second `this.resolve` importer. The nested `@vitest/*` family (`@vitest/expect`,
47
+ * `@vitest/runner`, `@vitest/snapshot`, …) are dependencies of `vitest` itself —
48
+ * not direct deps of `vite-plus` — so under pnpm's isolated layout they are
49
+ * reachable from `vitest`'s location but not from [[vitePlusModuleFile]].
50
+ * Resolving `package.json` is condition-agnostic, so this is safe with
51
+ * `require.resolve`. Cached; `null` once an attempt has failed so we never retry.
52
+ */
53
+ let vitestAnchor;
54
+ function getVitestAnchor() {
55
+ if (vitestAnchor !== void 0) return vitestAnchor;
56
+ try {
57
+ vitestAnchor = vitePlusRequire.resolve("vitest/package.json");
58
+ } catch {
59
+ vitestAnchor = null;
60
+ }
61
+ return vitestAnchor;
62
+ }
63
+ /**
64
+ * Match the `vitest` / `@vitest/*` family of bare specifiers — the imports a
65
+ * browser-mode Vite dev server must resolve. Any query string is stripped
66
+ * first; relative (`./`), absolute (`/`), and virtual (`\0`) ids never match.
67
+ *
68
+ * Exported for unit testing.
69
+ */
70
+ function isVitestFamilySpecifier(id) {
71
+ const bare = id.split("?")[0];
72
+ if (bare.startsWith(".") || bare.startsWith("/") || bare.startsWith("\0")) return false;
73
+ return bare === "vitest" || bare.startsWith("vitest/") || bare === "@vitest/browser" || bare.startsWith("@vitest/");
74
+ }
75
+ /**
76
+ * Rescue `vitest` / `@vitest/*` resolution for browser-mode tests.
77
+ *
78
+ * In an established project that depends only on `vite-plus`, both `vitest`
79
+ * and `@vitest/browser` are transitive deps. pnpm's isolated layout only
80
+ * exposes a package's *direct* deps, so the browser-mode Vite dev server
81
+ * (rooted at the consumer project) cannot resolve `vitest/internal/browser`,
82
+ * `@vitest/expect`, etc. Non-browser tests are unaffected — vitest's own
83
+ * module runner handles resolution there.
84
+ *
85
+ * This plugin re-resolves the `vitest` / `@vitest/*` family through Vite's OWN
86
+ * resolver, but ROOTED at `vite-plus`'s location ([[vitePlusModuleFile]]) and
87
+ * then the bundled `vitest`'s location ([[getVitestAnchor]]) BEFORE the
88
+ * project. So every such import binds to the same physical (pinned) Vitest that
89
+ * `vp test` spawns as the runner (see `resolveBundled` in `resolve-test.ts`)
90
+ * and that the `vite-plus/test*` shims re-export. Were a project-local Vitest
91
+ * preferred instead, a project that keeps its own `vitest` dependency would
92
+ * split the run across two physical Vitest module instances — the runner
93
+ * (bundled) vs. the test files' `vi`/`expect`/runner internals (project) — a
94
+ * classic source of internal-state and mock-hoisting mismatches. For the common
95
+ * migrated layout (a project depending only on `vite-plus`) nothing in this
96
+ * family is resolvable from the project root under pnpm's isolated layout
97
+ * anyway, so default resolution would return `null` there regardless;
98
+ * bundle-first only changes the project-keeps-its-own-`vitest` case, which is
99
+ * exactly the case we want pinned.
100
+ *
101
+ * Resolution goes through `this.resolve` (NOT [[vitePlusRequire]].resolve) so
102
+ * Vite's ESM export conditions are honoured: a raw `require.resolve` would pick
103
+ * Vitest's CJS `require`-condition entry — a throw-stub for the bare `vitest`
104
+ * root (`index.cjs`), and the CJS build for subpaths (e.g. `vitest/config` →
105
+ * `config.cjs`) instead of the ESM entry. Two bundled anchors are tried because `@vitest/browser*` are
106
+ * direct deps of `vite-plus` (reachable from [[vitePlusModuleFile]]) while the
107
+ * nested `@vitest/*` family are deps of `vitest` (reachable only from the
108
+ * `vitest` anchor). The project root remains the last resort for any family id
109
+ * the bundled tree cannot resolve, so this is never worse than deferring first.
110
+ *
111
+ * Two intentional limits of routing through `this.resolve`:
112
+ * - An EXPLICIT project `resolve.alias` / `resolve.dedupe` on the vitest
113
+ * family takes precedence (Vite's pipeline applies it even from a bundled
114
+ * anchor). Neither is set by default in Vitest 4.x, so this only affects
115
+ * projects that deliberately re-point the family — treated as an opt-out of
116
+ * pinning, not defeated silently.
117
+ * - Coverage providers (`@vitest/coverage-v8` / `-istanbul`) are NOT shipped
118
+ * with `vite-plus`, so they hit the project fallback below. Under
119
+ * `--coverage`, a project-installed provider of a different version pairs
120
+ * with the bundled runner; Vitest only WARNS on the version skew and then
121
+ * runs mixed versions (its provider `_initialize` logs and continues, it
122
+ * does not throw), which silently yields unreliable coverage — so
123
+ * [[vitePlusCoverageVersionGuardPlugin]] fails fast on a mismatch instead.
124
+ */
125
+ function vitePlusVitestResolverPlugin() {
126
+ return {
127
+ name: "vite-plus:vitest-resolver",
128
+ enforce: "pre",
129
+ async resolveId(id, importer, options) {
130
+ if (!isVitestFamilySpecifier(id)) return null;
131
+ if (id.includes("?")) return null;
132
+ const vitestAnchorPath = getVitestAnchor();
133
+ const bundledAnchors = vitestAnchorPath ? [vitePlusModuleFile, vitestAnchorPath] : [vitePlusModuleFile];
134
+ for (const anchor of bundledAnchors) {
135
+ const resolved = await this.resolve(id, anchor, {
136
+ ...options,
137
+ skipSelf: true
138
+ });
139
+ if (resolved) return resolved;
140
+ }
141
+ return this.resolve(id, importer, {
142
+ ...options,
143
+ skipSelf: true
144
+ });
145
+ }
146
+ };
147
+ }
148
+ /**
149
+ * Packages that register Vitest `expect` matchers via `expect.extend()` from
150
+ * a side-effect import. When Vite serves these from a separate module graph
151
+ * than the test runtime, the matchers register on a different `expect`
152
+ * instance and `expect(...).<matcher>` is undefined at call time (vitest
153
+ * issue #897). Inlining them into the test server's module graph forces
154
+ * registration on the same instance.
155
+ *
156
+ * Only packages that are **installed** in the consumer project are inlined.
157
+ * Absent packages are silently skipped so the server-deps optimizer never
158
+ * tries to resolve a name that does not exist in the project's node_modules.
159
+ *
160
+ * The check is deferred to a `configResolved` plugin hook so that
161
+ * `resolvedConfig.root` points at the actual project root (the value vite has
162
+ * already normalised), rather than relying on `process.cwd()` at config-load
163
+ * time (which can differ in workspace / monorepo setups).
164
+ *
165
+ * Exported for unit testing.
166
+ */
167
+ const AUTO_INLINE_DEPS = [
168
+ "@testing-library/jest-dom",
169
+ "@storybook/test",
170
+ "jest-extended"
171
+ ];
172
+ /**
173
+ * Compute the merged `test.server.deps.inline` list for a given project root,
174
+ * appending only those entries from [[AUTO_INLINE_DEPS]] that are actually
175
+ * installed in the project.
176
+ *
177
+ * Returns `null` when nothing needs to change (either `inline: true` or an
178
+ * empty result), so the caller can skip the mutation step.
179
+ *
180
+ * Exported for unit testing. The `_createRequire` parameter lets tests inject
181
+ * a controlled resolver without needing to spy on Node's ESM module namespace.
182
+ */
183
+ function computeAutoInlineList(existingInline, projectRoot, _createRequire = createRequire) {
184
+ if (existingInline === true) return null;
185
+ const projectRequire = _createRequire(`${projectRoot}/package.json`);
186
+ const merged = Array.isArray(existingInline) ? [...existingInline] : [];
187
+ for (const pkg of AUTO_INLINE_DEPS) {
188
+ if (merged.some((entry) => entry === pkg || entry instanceof RegExp && entry.test(pkg))) continue;
189
+ try {
190
+ projectRequire.resolve(pkg);
191
+ } catch {
192
+ continue;
193
+ }
194
+ merged.push(pkg);
195
+ }
196
+ const hadEntries = Array.isArray(existingInline) ? existingInline.length : 0;
197
+ if (merged.length === hadEntries) return null;
198
+ return merged;
199
+ }
200
+ function vitePlusAutoInlineMatcherPlugin() {
201
+ return {
202
+ name: "vite-plus:auto-inline-matcher-deps",
203
+ enforce: "pre",
204
+ configResolved(resolvedConfig) {
205
+ const testConfig = resolvedConfig.test;
206
+ const merged = computeAutoInlineList(testConfig?.server?.deps?.inline, resolvedConfig.root);
207
+ if (merged === null) return;
208
+ if (!testConfig) resolvedConfig.test = { server: { deps: { inline: merged } } };
209
+ else {
210
+ if (!testConfig.server) testConfig.server = {};
211
+ if (!testConfig.server.deps) testConfig.server.deps = {};
212
+ testConfig.server.deps.inline = merged;
213
+ }
214
+ }
215
+ };
216
+ }
217
+ /** Coverage providers vite-plus can version-check against the bundled runner. */
218
+ const KNOWN_COVERAGE_PROVIDERS = new Set(["v8", "istanbul"]);
219
+ /**
220
+ * Resolve the coverage provider package name that should be version-checked, or
221
+ * `null` when no check applies (coverage off, or a `custom`/unknown provider
222
+ * vite-plus does not bundle a runner for).
223
+ *
224
+ * Takes Vitest's OWN resolved coverage options (`enabled`/`provider`), which the
225
+ * `configureVitest` hook exposes AFTER Vitest's CLI parser has run — so the
226
+ * `--coverage` family of flags is already folded into `enabled`/`provider` and
227
+ * we never re-parse `process.argv` ourselves. Unset `provider` defaults to `v8`
228
+ * (Vitest's default).
229
+ *
230
+ * Exported for unit testing.
231
+ */
232
+ function resolveCoverageProviderToCheck(coverage) {
233
+ if (!coverage?.enabled) return null;
234
+ const name = coverage.provider ?? "v8";
235
+ return KNOWN_COVERAGE_PROVIDERS.has(name) ? `@vitest/coverage-${name}` : null;
236
+ }
237
+ /**
238
+ * vite-plus bundles `vitest@VITEST_VERSION` as the test runner, but coverage
239
+ * providers (`@vitest/coverage-v8` / `-istanbul`) are project-installed peer
240
+ * deps it does not ship. Vitest only PRINTS A WARNING on a provider/runner
241
+ * version skew and then runs mixed versions (verified in 4.1.9: the provider's
242
+ * `_initialize` calls `logger.warn`, it never throws), silently producing
243
+ * unreliable coverage. Fail fast instead.
244
+ *
245
+ * Exported for unit testing.
246
+ */
247
+ function assertCoverageProviderVersionMatch(providerPackageName, installedVersion, expectedVersion = VITEST_VERSION) {
248
+ if (installedVersion && installedVersion !== expectedVersion) throw new Error(`vite-plus bundles vitest@${expectedVersion}, but ${providerPackageName}@${installedVersion} is installed. A coverage provider must match the test runner version: Vitest only prints a warning on a mismatch and then runs mixed versions, which produces unreliable coverage. Pin ${providerPackageName} to ${expectedVersion} in your dependencies.`);
249
+ }
250
+ /**
251
+ * The bundled vitest's `package.json` path — the SAME anchor Vitest's own
252
+ * `import('@vitest/coverage-*')` resolves against (its dist walks up from here).
253
+ * Used as a fallback resolution anchor for the coverage guard. Lazily computed
254
+ * and cached; `null` when the bundled vitest is somehow unreachable, in which
255
+ * case the guard simply relies on the project-root anchor.
256
+ */
257
+ let bundledVitestAnchorCache;
258
+ function bundledVitestAnchor() {
259
+ if (bundledVitestAnchorCache === void 0) try {
260
+ bundledVitestAnchorCache = createRequire(import.meta.url).resolve("vitest/package.json");
261
+ } catch {
262
+ bundledVitestAnchorCache = null;
263
+ }
264
+ return bundledVitestAnchorCache;
265
+ }
266
+ /**
267
+ * Read a project-installed coverage provider's version, mirroring how Vitest
268
+ * itself resolves the provider. Vitest install-checks it from BOTH the runner
269
+ * root AND its own bundled dir (`isPackageExists(dep, {paths:[root, vitestDir]})`)
270
+ * and then loads it via a bare `import('@vitest/coverage-*')` anchored at that
271
+ * bundled dir. So the guard tries the project root FIRST — the supported layout
272
+ * where a directly-declared provider is symlinked at the root, the same copy the
273
+ * bundled vitest walks up to — then falls back to the bundled-vitest anchor,
274
+ * which catches hoisted / pnpm peer-set layouts where the provider lives next to
275
+ * vitest but is not resolvable from the project root (a silent skip otherwise).
276
+ * `@vitest/coverage-*`'s exports map has a `"./*": "./*"` catch-all, so
277
+ * `./package.json` is resolvable. Returns `null` when no anchor can resolve it —
278
+ * Vitest then emits its own (already clear) missing-provider error.
279
+ *
280
+ * The `_createRequire` / `_readFile` parameters let tests inject controlled
281
+ * resolvers without spying on Node's module/fs namespaces.
282
+ */
283
+ function readInstalledCoverageProviderVersion(providerPackageName, projectRoot, _createRequire = createRequire, _readFile = (path) => readFileSync(path, "utf8")) {
284
+ const anchors = [`${projectRoot}/package.json`, bundledVitestAnchor()];
285
+ for (const anchor of anchors) {
286
+ if (!anchor) continue;
287
+ try {
288
+ const pkgJsonPath = _createRequire(anchor).resolve(`${providerPackageName}/package.json`);
289
+ const parsed = JSON.parse(_readFile(pkgJsonPath));
290
+ if (parsed.version) return parsed.version;
291
+ } catch {}
292
+ }
293
+ return null;
294
+ }
295
+ /**
296
+ * Orchestrates the coverage version guard: detect the active provider from
297
+ * Vitest's resolved coverage options, read its installed version from the
298
+ * project root, and throw on a mismatch. A no-op when coverage is off or the
299
+ * provider is not installed.
300
+ *
301
+ * Exported (with injectable `deps`) for unit testing.
302
+ */
303
+ function checkCoverageProviderVersion(coverage, projectRoot, deps = {}) {
304
+ const providerPackageName = resolveCoverageProviderToCheck(coverage);
305
+ if (!providerPackageName) return;
306
+ assertCoverageProviderVersionMatch(providerPackageName, readInstalledCoverageProviderVersion(providerPackageName, projectRoot, deps.createRequire, deps.readFile));
307
+ }
308
+ /**
309
+ * Vitest instances the guard has already handled. The `configureVitest` hook
310
+ * fires once PER PROJECT but `vitest` is shared and coverage is global, so this
311
+ * runs the whole guard exactly once per instance (and never leaks, since it is
312
+ * keyed weakly on identity).
313
+ */
314
+ const coverageGuardedVitestInstances = /* @__PURE__ */ new WeakSet();
315
+ function vitePlusCoverageVersionGuardPlugin() {
316
+ return {
317
+ name: "vite-plus:coverage-version-guard",
318
+ configureVitest(context) {
319
+ const { vitest } = context;
320
+ if (coverageGuardedVitestInstances.has(vitest)) return;
321
+ coverageGuardedVitestInstances.add(vitest);
322
+ checkCoverageProviderVersion(vitest.config.coverage, vitest.config.root);
323
+ const enableCoverage = vitest.enableCoverage.bind(vitest);
324
+ vitest.enableCoverage = async () => {
325
+ checkCoverageProviderVersion({
326
+ enabled: true,
327
+ provider: vitest.config.coverage?.provider
328
+ }, vitest.config.root);
329
+ return enableCoverage();
330
+ };
331
+ }
332
+ };
333
+ }
334
+ /**
335
+ * Inject the vitest resolver plugin, the auto-inline matcher plugin, and the
336
+ * coverage version guard into a single inline project config. Used both for
337
+ * root configs and for object-shaped entries inside `test.projects`.
338
+ *
339
+ * The shapes overlap (both have an optional top-level `plugins` array and
340
+ * an optional `test.server.deps.inline`), so a shared helper keeps the
341
+ * wiring consistent.
342
+ */
343
+ function injectPluginIntoInlineConfig(config) {
344
+ return {
345
+ ...config,
346
+ plugins: [
347
+ vitePlusVitestResolverPlugin(),
348
+ vitePlusAutoInlineMatcherPlugin(),
349
+ vitePlusCoverageVersionGuardPlugin(),
350
+ ...config.plugins ?? []
351
+ ]
352
+ };
353
+ }
354
+ /**
355
+ * Walk `config.test?.projects` and inject the vite-plus plugins into each
356
+ * project entry. Vitest spins up an independent Vite pipeline per project, so
357
+ * root-level plugins do NOT propagate — without this, files matched by a
358
+ * project's `include` glob never get the vitest resolver / auto-inline plugins.
359
+ *
360
+ * Entry shapes (from `TestProjectConfiguration`):
361
+ * - string (glob path like `'./packages/*'`) → passed through unchanged.
362
+ * - object (inline config with `test: {...}`) → clone and prepend plugin.
363
+ * - function (sync or async) → wrap so its result is injected.
364
+ * - Promise (resolves to inline config) → chain `.then(injectPlugin)`.
365
+ *
366
+ * String/glob entries cannot be cloned, so they carry no injected plugin. This
367
+ * only weakens the COVERAGE guard, and only narrowly: coverage is global, and
368
+ * the migration rewrites every nested config file to vite-plus
369
+ * `defineConfig`/`defineProject` (which re-inject the guard), so a migrated
370
+ * workspace still fires it from its resolved projects. The residual gap is a
371
+ * hand-authored workspace whose string globs resolve to raw `vitest/config`
372
+ * sub-configs or bare directory projects — there a provider/runner skew falls
373
+ * back to Vitest's own (softer) warning instead of the guard's hard error.
374
+ */
375
+ function injectPluginIntoProject(project) {
376
+ if (typeof project === "string") return project;
377
+ if (typeof project === "function") {
378
+ const wrapped = (env) => {
379
+ const result = project(env);
380
+ if (result instanceof Promise) return result.then(injectPluginIntoInlineConfig);
381
+ return injectPluginIntoInlineConfig(result);
382
+ };
383
+ return wrapped;
384
+ }
385
+ if (project instanceof Promise) return project.then(injectPluginIntoInlineConfig);
386
+ if (typeof project === "object" && project !== null) return injectPluginIntoInlineConfig(project);
387
+ return project;
388
+ }
389
+ function injectPlugin(config) {
390
+ const injected = injectPluginIntoInlineConfig(config);
391
+ const projects = injected.test?.projects;
392
+ if (!projects || projects.length === 0) return injected;
393
+ return {
394
+ ...injected,
395
+ test: {
396
+ ...injected.test,
397
+ projects: projects.map(injectPluginIntoProject)
398
+ }
399
+ };
400
+ }
401
+ function injectPluginIntoConfig(config) {
402
+ if (typeof config === "function") return (env) => {
403
+ const result = config(env);
404
+ if (result instanceof Promise) return result.then(injectPlugin);
405
+ return injectPlugin(result);
406
+ };
407
+ if (config instanceof Promise) return config.then(injectPlugin);
408
+ return injectPlugin(config);
409
+ }
410
+ function defineConfig$1(config) {
411
+ return defineConfig(injectPluginIntoConfig(config));
412
+ }
413
+ /**
414
+ * Inject the vite-plus plugins into a `defineProject` export. A project config
415
+ * (`UserWorkspaceConfig`) cannot itself nest `test.projects`, so this only
416
+ * touches the top-level `plugins` array (no project recursion like
417
+ * [[injectPluginIntoConfig]] does).
418
+ */
419
+ function injectPluginIntoProjectExport(config) {
420
+ if (typeof config === "function") return ((env) => {
421
+ const result = config(env);
422
+ return result instanceof Promise ? result.then(injectPluginIntoInlineConfig) : injectPluginIntoInlineConfig(result);
423
+ });
424
+ if (config instanceof Promise) return config.then(injectPluginIntoInlineConfig);
425
+ return injectPluginIntoInlineConfig(config);
426
+ }
427
+ function defineProject$1(config) {
428
+ return defineProject(injectPluginIntoProjectExport(config));
429
+ }
430
+ const VITE_COMMANDS = new Set([
431
+ "dev",
432
+ "build",
433
+ "test",
434
+ "preview"
435
+ ]);
436
+ function lazyPlugins(cb) {
437
+ const cmd = process.env.VP_COMMAND;
438
+ if (!cmd || VITE_COMMANDS.has(cmd)) {
439
+ const result = cb();
440
+ if (result instanceof Promise) return [result];
441
+ return result;
442
+ }
443
+ }
444
+ //#endregion
445
+ export { defineConfig$1 as a, lazyPlugins as c, computeAutoInlineList as i, resolveCoverageProviderToCheck as l, assertCoverageProviderVersionMatch as n, defineProject$1 as o, checkCoverageProviderVersion as r, isVitestFamilySpecifier as s, AUTO_INLINE_DEPS as t };
@@ -1,5 +1,12 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_define_config = require("./define-config-BR1Y88zz.cjs");
2
+ const require_define_config = require("./define-config-BGSjF6Xp.cjs");
3
3
  require_define_config.init_define_config();
4
+ exports.AUTO_INLINE_DEPS = require_define_config.AUTO_INLINE_DEPS;
5
+ exports.assertCoverageProviderVersionMatch = require_define_config.assertCoverageProviderVersionMatch;
6
+ exports.checkCoverageProviderVersion = require_define_config.checkCoverageProviderVersion;
7
+ exports.computeAutoInlineList = require_define_config.computeAutoInlineList;
4
8
  exports.defineConfig = require_define_config.defineConfig;
9
+ exports.defineProject = require_define_config.defineProject;
10
+ exports.isVitestFamilySpecifier = require_define_config.isVitestFamilySpecifier;
5
11
  exports.lazyPlugins = require_define_config.lazyPlugins;
12
+ exports.resolveCoverageProviderToCheck = require_define_config.resolveCoverageProviderToCheck;
@@ -1,2 +1,2 @@
1
- import { n as lazyPlugins, t as defineConfig } from "./define-config-COdn-tsn.js";
2
- export { defineConfig, lazyPlugins };
1
+ import { a as defineConfig, c as lazyPlugins, i as computeAutoInlineList, l as resolveCoverageProviderToCheck, n as assertCoverageProviderVersionMatch, o as defineProject, r as checkCoverageProviderVersion, s as isVitestFamilySpecifier, t as AUTO_INLINE_DEPS } from "./define-config-2tfJoXr1.js";
2
+ export { AUTO_INLINE_DEPS, assertCoverageProviderVersionMatch, checkCoverageProviderVersion, computeAutoInlineList, defineConfig, defineProject, isVitestFamilySpecifier, lazyPlugins, resolveCoverageProviderToCheck };
@@ -1,2 +1,2 @@
1
- import { n as lazyPlugins, t as defineConfig } from "./define-config-BRC7qPNE.js";
2
- export { defineConfig, lazyPlugins };
1
+ import { a as defineConfig, c as lazyPlugins, i as computeAutoInlineList, l as resolveCoverageProviderToCheck, n as assertCoverageProviderVersionMatch, o as defineProject, r as checkCoverageProviderVersion, s as isVitestFamilySpecifier, t as AUTO_INLINE_DEPS } from "./define-config-DJUehepE.js";
2
+ export { AUTO_INLINE_DEPS, assertCoverageProviderVersionMatch, checkCoverageProviderVersion, computeAutoInlineList, defineConfig, defineProject, isVitestFamilySpecifier, lazyPlugins, resolveCoverageProviderToCheck };
@@ -0,0 +1,3 @@
1
+ import { t as require_dist } from "./dist-Oxo16Y0q.js";
2
+ export default require_dist();
3
+ export {};
@@ -1,4 +1,4 @@
1
- import { n as __require, t as __commonJSMin } from "./chunk-DnnnRqeS.js";
1
+ import { n as __require, t as __commonJSMin } from "./rolldown-runtime-DnnnRqeS.js";
2
2
  //#region ../../node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/dist/nodes/identity.js
3
3
  var require_identity = /* @__PURE__ */ __commonJSMin(((exports) => {
4
4
  const ALIAS = Symbol.for("yaml.alias");
@@ -3391,7 +3391,7 @@ var require_resolve_block_map = /* @__PURE__ */ __commonJSMin(((exports) => {
3391
3391
  var utilMapIncludes = require_util_map_includes();
3392
3392
  const startColMsg = "All mapping items must start at the same column";
3393
3393
  function resolveBlockMap({ composeNode, composeEmptyNode }, ctx, bm, onError, tag) {
3394
- const map = new (tag?.nodeClass ?? YAMLMap.YAMLMap)(ctx.schema);
3394
+ const map = new ((tag?.nodeClass) ?? YAMLMap.YAMLMap)(ctx.schema);
3395
3395
  if (ctx.atRoot) ctx.atRoot = false;
3396
3396
  let offset = bm.offset;
3397
3397
  let commentEnd = null;
@@ -3471,7 +3471,7 @@ var require_resolve_block_seq = /* @__PURE__ */ __commonJSMin(((exports) => {
3471
3471
  var resolveProps = require_resolve_props();
3472
3472
  var utilFlowIndentCheck = require_util_flow_indent_check();
3473
3473
  function resolveBlockSeq({ composeNode, composeEmptyNode }, ctx, bs, onError, tag) {
3474
- const seq = new (tag?.nodeClass ?? YAMLSeq.YAMLSeq)(ctx.schema);
3474
+ const seq = new ((tag?.nodeClass) ?? YAMLSeq.YAMLSeq)(ctx.schema);
3475
3475
  if (ctx.atRoot) ctx.atRoot = false;
3476
3476
  if (ctx.atKey) ctx.atKey = false;
3477
3477
  let offset = bs.offset;
@@ -3560,7 +3560,7 @@ var require_resolve_flow_collection = /* @__PURE__ */ __commonJSMin(((exports) =
3560
3560
  function resolveFlowCollection({ composeNode, composeEmptyNode }, ctx, fc, onError, tag) {
3561
3561
  const isMap = fc.start.source === "{";
3562
3562
  const fcName = isMap ? "flow map" : "flow sequence";
3563
- const coll = new (tag?.nodeClass ?? (isMap ? YAMLMap.YAMLMap : YAMLSeq.YAMLSeq))(ctx.schema);
3563
+ const coll = new ((tag?.nodeClass) ?? (isMap ? YAMLMap.YAMLMap : YAMLSeq.YAMLSeq))(ctx.schema);
3564
3564
  coll.flow = true;
3565
3565
  const atRoot = ctx.atRoot;
3566
3566
  if (atRoot) ctx.atRoot = false;
package/dist/index.cjs CHANGED
@@ -1,11 +1,16 @@
1
- const require_define_config = require("./define-config-BR1Y88zz.cjs");
1
+ const require_define_config = require("./define-config-BGSjF6Xp.cjs");
2
2
  //#region src/index.cts
3
3
  const vite = require("@voidzero-dev/vite-plus-core");
4
- const vitest = require("@voidzero-dev/vite-plus-test/config");
5
- const { defineConfig, lazyPlugins } = (require_define_config.init_define_config(), require_define_config.__toCommonJS(require_define_config.define_config_exports));
4
+ const { configDefaults, coverageConfigDefaults, defaultBrowserPort, defaultExclude, defaultInclude } = require("vitest/config");
5
+ const { defineConfig, defineProject, lazyPlugins } = (require_define_config.init_define_config(), require_define_config.__toCommonJS(require_define_config.define_config_exports));
6
6
  module.exports = {
7
7
  ...vite,
8
- ...vitest,
8
+ configDefaults,
9
+ coverageConfigDefaults,
10
+ defaultBrowserPort,
11
+ defaultExclude,
12
+ defaultInclude,
13
+ defineProject,
9
14
  defineConfig,
10
15
  lazyPlugins
11
16
  };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as lazyPlugins, t as defineConfig } from "./define-config-COdn-tsn.js";
2
- export * from "@voidzero-dev/vite-plus-test/config";
1
+ import { a as defineConfig, c as lazyPlugins, o as defineProject } from "./define-config-2tfJoXr1.js";
2
+ import { TestProjectConfiguration, TestProjectInlineConfiguration, TestTagDefinition, TestUserConfig, UserProjectConfigExport, UserProjectConfigFn, UserWorkspaceConfig, ViteUserConfig, ViteUserConfigExport, ViteUserConfigFn, ViteUserConfigFnObject, ViteUserConfigFnPromise, WatcherTriggerPattern, configDefaults, coverageConfigDefaults, defaultBrowserPort, defaultExclude, defaultInclude } from "vitest/config";
3
3
  export * from "@voidzero-dev/vite-plus-core";
4
- export { defineConfig, lazyPlugins };
4
+ export { type TestProjectConfiguration, type TestProjectInlineConfiguration, type TestTagDefinition, type TestUserConfig, type UserProjectConfigExport, type UserProjectConfigFn, type UserWorkspaceConfig, type ViteUserConfig, type ViteUserConfigExport, type ViteUserConfigFn, type ViteUserConfigFnObject, type ViteUserConfigFnPromise, type WatcherTriggerPattern, configDefaults, coverageConfigDefaults, defaultBrowserPort, defaultExclude, defaultInclude, defineConfig, defineProject, lazyPlugins };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as lazyPlugins, t as defineConfig } from "./define-config-BRC7qPNE.js";
2
- export * from "@voidzero-dev/vite-plus-test/config";
1
+ import { a as defineConfig, c as lazyPlugins, o as defineProject } from "./define-config-DJUehepE.js";
2
+ import { configDefaults, coverageConfigDefaults, defaultBrowserPort, defaultExclude, defaultInclude } from "vitest/config";
3
3
  export * from "@voidzero-dev/vite-plus-core";
4
- export { defineConfig, lazyPlugins };
4
+ export { configDefaults, coverageConfigDefaults, defaultBrowserPort, defaultExclude, defaultInclude, defineConfig, defineProject, lazyPlugins };