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,488 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __esmMin = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
7
+ var __exportAll = (all, no_symbols) => {
8
+ let target = {};
9
+ for (var name in all) __defProp(target, name, {
10
+ get: all[name],
11
+ enumerable: true
12
+ });
13
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
14
+ return target;
15
+ };
16
+ var __copyProps = (to, from, except, desc) => {
17
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
18
+ key = keys[i];
19
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
20
+ get: ((k) => from[k]).bind(null, key),
21
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
22
+ });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ //#endregion
28
+ let node_fs = require("node:fs");
29
+ let node_module = require("node:module");
30
+ let node_url = require("node:url");
31
+ let vitest_config = require("vitest/config");
32
+ //#region src/utils/constants.ts
33
+ var VITEST_VERSION;
34
+ var init_constants = __esmMin((() => {
35
+ process.env.VP_VERSION;
36
+ VITEST_VERSION = "4.1.9";
37
+ process.env.VP_OVERRIDE_PACKAGES && JSON.parse(process.env.VP_OVERRIDE_PACKAGES);
38
+ (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
39
+ process.versions.node, process.release.name;
40
+ }));
41
+ //#endregion
42
+ //#region src/define-config.ts
43
+ var define_config_exports = /* @__PURE__ */ __exportAll({
44
+ AUTO_INLINE_DEPS: () => AUTO_INLINE_DEPS,
45
+ assertCoverageProviderVersionMatch: () => assertCoverageProviderVersionMatch,
46
+ checkCoverageProviderVersion: () => checkCoverageProviderVersion,
47
+ computeAutoInlineList: () => computeAutoInlineList,
48
+ defineConfig: () => defineConfig,
49
+ defineProject: () => defineProject,
50
+ isVitestFamilySpecifier: () => isVitestFamilySpecifier,
51
+ lazyPlugins: () => lazyPlugins,
52
+ resolveCoverageProviderToCheck: () => resolveCoverageProviderToCheck
53
+ });
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
+ * Compute the merged `test.server.deps.inline` list for a given project root,
150
+ * appending only those entries from [[AUTO_INLINE_DEPS]] that are actually
151
+ * installed in the project.
152
+ *
153
+ * Returns `null` when nothing needs to change (either `inline: true` or an
154
+ * empty result), so the caller can skip the mutation step.
155
+ *
156
+ * Exported for unit testing. The `_createRequire` parameter lets tests inject
157
+ * a controlled resolver without needing to spy on Node's ESM module namespace.
158
+ */
159
+ function computeAutoInlineList(existingInline, projectRoot, _createRequire = node_module.createRequire) {
160
+ if (existingInline === true) return null;
161
+ const projectRequire = _createRequire(`${projectRoot}/package.json`);
162
+ const merged = Array.isArray(existingInline) ? [...existingInline] : [];
163
+ for (const pkg of AUTO_INLINE_DEPS) {
164
+ if (merged.some((entry) => entry === pkg || entry instanceof RegExp && entry.test(pkg))) continue;
165
+ try {
166
+ projectRequire.resolve(pkg);
167
+ } catch {
168
+ continue;
169
+ }
170
+ merged.push(pkg);
171
+ }
172
+ const hadEntries = Array.isArray(existingInline) ? existingInline.length : 0;
173
+ if (merged.length === hadEntries) return null;
174
+ return merged;
175
+ }
176
+ function vitePlusAutoInlineMatcherPlugin() {
177
+ return {
178
+ name: "vite-plus:auto-inline-matcher-deps",
179
+ enforce: "pre",
180
+ configResolved(resolvedConfig) {
181
+ const testConfig = resolvedConfig.test;
182
+ const merged = computeAutoInlineList(testConfig?.server?.deps?.inline, resolvedConfig.root);
183
+ if (merged === null) return;
184
+ if (!testConfig) resolvedConfig.test = { server: { deps: { inline: merged } } };
185
+ else {
186
+ if (!testConfig.server) testConfig.server = {};
187
+ if (!testConfig.server.deps) testConfig.server.deps = {};
188
+ testConfig.server.deps.inline = merged;
189
+ }
190
+ }
191
+ };
192
+ }
193
+ /**
194
+ * Resolve the coverage provider package name that should be version-checked, or
195
+ * `null` when no check applies (coverage off, or a `custom`/unknown provider
196
+ * vite-plus does not bundle a runner for).
197
+ *
198
+ * Takes Vitest's OWN resolved coverage options (`enabled`/`provider`), which the
199
+ * `configureVitest` hook exposes AFTER Vitest's CLI parser has run — so the
200
+ * `--coverage` family of flags is already folded into `enabled`/`provider` and
201
+ * we never re-parse `process.argv` ourselves. Unset `provider` defaults to `v8`
202
+ * (Vitest's default).
203
+ *
204
+ * Exported for unit testing.
205
+ */
206
+ function resolveCoverageProviderToCheck(coverage) {
207
+ if (!coverage?.enabled) return null;
208
+ const name = coverage.provider ?? "v8";
209
+ return KNOWN_COVERAGE_PROVIDERS.has(name) ? `@vitest/coverage-${name}` : null;
210
+ }
211
+ /**
212
+ * vite-plus bundles `vitest@VITEST_VERSION` as the test runner, but coverage
213
+ * providers (`@vitest/coverage-v8` / `-istanbul`) are project-installed peer
214
+ * deps it does not ship. Vitest only PRINTS A WARNING on a provider/runner
215
+ * version skew and then runs mixed versions (verified in 4.1.9: the provider's
216
+ * `_initialize` calls `logger.warn`, it never throws), silently producing
217
+ * unreliable coverage. Fail fast instead.
218
+ *
219
+ * Exported for unit testing.
220
+ */
221
+ function assertCoverageProviderVersionMatch(providerPackageName, installedVersion, expectedVersion = VITEST_VERSION) {
222
+ 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.`);
223
+ }
224
+ function bundledVitestAnchor() {
225
+ if (bundledVitestAnchorCache === void 0) try {
226
+ bundledVitestAnchorCache = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href).resolve("vitest/package.json");
227
+ } catch {
228
+ bundledVitestAnchorCache = null;
229
+ }
230
+ return bundledVitestAnchorCache;
231
+ }
232
+ /**
233
+ * Read a project-installed coverage provider's version, mirroring how Vitest
234
+ * itself resolves the provider. Vitest install-checks it from BOTH the runner
235
+ * root AND its own bundled dir (`isPackageExists(dep, {paths:[root, vitestDir]})`)
236
+ * and then loads it via a bare `import('@vitest/coverage-*')` anchored at that
237
+ * bundled dir. So the guard tries the project root FIRST — the supported layout
238
+ * where a directly-declared provider is symlinked at the root, the same copy the
239
+ * bundled vitest walks up to — then falls back to the bundled-vitest anchor,
240
+ * which catches hoisted / pnpm peer-set layouts where the provider lives next to
241
+ * vitest but is not resolvable from the project root (a silent skip otherwise).
242
+ * `@vitest/coverage-*`'s exports map has a `"./*": "./*"` catch-all, so
243
+ * `./package.json` is resolvable. Returns `null` when no anchor can resolve it —
244
+ * Vitest then emits its own (already clear) missing-provider error.
245
+ *
246
+ * The `_createRequire` / `_readFile` parameters let tests inject controlled
247
+ * resolvers without spying on Node's module/fs namespaces.
248
+ */
249
+ function readInstalledCoverageProviderVersion(providerPackageName, projectRoot, _createRequire = node_module.createRequire, _readFile = (path) => (0, node_fs.readFileSync)(path, "utf8")) {
250
+ const anchors = [`${projectRoot}/package.json`, bundledVitestAnchor()];
251
+ for (const anchor of anchors) {
252
+ if (!anchor) continue;
253
+ try {
254
+ const pkgJsonPath = _createRequire(anchor).resolve(`${providerPackageName}/package.json`);
255
+ const parsed = JSON.parse(_readFile(pkgJsonPath));
256
+ if (parsed.version) return parsed.version;
257
+ } catch {}
258
+ }
259
+ return null;
260
+ }
261
+ /**
262
+ * Orchestrates the coverage version guard: detect the active provider from
263
+ * Vitest's resolved coverage options, read its installed version from the
264
+ * project root, and throw on a mismatch. A no-op when coverage is off or the
265
+ * provider is not installed.
266
+ *
267
+ * Exported (with injectable `deps`) for unit testing.
268
+ */
269
+ function checkCoverageProviderVersion(coverage, projectRoot, deps = {}) {
270
+ const providerPackageName = resolveCoverageProviderToCheck(coverage);
271
+ if (!providerPackageName) return;
272
+ assertCoverageProviderVersionMatch(providerPackageName, readInstalledCoverageProviderVersion(providerPackageName, projectRoot, deps.createRequire, deps.readFile));
273
+ }
274
+ function vitePlusCoverageVersionGuardPlugin() {
275
+ return {
276
+ name: "vite-plus:coverage-version-guard",
277
+ configureVitest(context) {
278
+ const { vitest } = context;
279
+ if (coverageGuardedVitestInstances.has(vitest)) return;
280
+ coverageGuardedVitestInstances.add(vitest);
281
+ checkCoverageProviderVersion(vitest.config.coverage, vitest.config.root);
282
+ const enableCoverage = vitest.enableCoverage.bind(vitest);
283
+ vitest.enableCoverage = async () => {
284
+ checkCoverageProviderVersion({
285
+ enabled: true,
286
+ provider: vitest.config.coverage?.provider
287
+ }, vitest.config.root);
288
+ return enableCoverage();
289
+ };
290
+ }
291
+ };
292
+ }
293
+ /**
294
+ * Inject the vitest resolver plugin, the auto-inline matcher plugin, and the
295
+ * coverage version guard into a single inline project config. Used both for
296
+ * root configs and for object-shaped entries inside `test.projects`.
297
+ *
298
+ * The shapes overlap (both have an optional top-level `plugins` array and
299
+ * an optional `test.server.deps.inline`), so a shared helper keeps the
300
+ * wiring consistent.
301
+ */
302
+ function injectPluginIntoInlineConfig(config) {
303
+ return {
304
+ ...config,
305
+ plugins: [
306
+ vitePlusVitestResolverPlugin(),
307
+ vitePlusAutoInlineMatcherPlugin(),
308
+ vitePlusCoverageVersionGuardPlugin(),
309
+ ...config.plugins ?? []
310
+ ]
311
+ };
312
+ }
313
+ /**
314
+ * Walk `config.test?.projects` and inject the vite-plus plugins into each
315
+ * project entry. Vitest spins up an independent Vite pipeline per project, so
316
+ * root-level plugins do NOT propagate — without this, files matched by a
317
+ * project's `include` glob never get the vitest resolver / auto-inline plugins.
318
+ *
319
+ * Entry shapes (from `TestProjectConfiguration`):
320
+ * - string (glob path like `'./packages/*'`) → passed through unchanged.
321
+ * - object (inline config with `test: {...}`) → clone and prepend plugin.
322
+ * - function (sync or async) → wrap so its result is injected.
323
+ * - Promise (resolves to inline config) → chain `.then(injectPlugin)`.
324
+ *
325
+ * String/glob entries cannot be cloned, so they carry no injected plugin. This
326
+ * only weakens the COVERAGE guard, and only narrowly: coverage is global, and
327
+ * the migration rewrites every nested config file to vite-plus
328
+ * `defineConfig`/`defineProject` (which re-inject the guard), so a migrated
329
+ * workspace still fires it from its resolved projects. The residual gap is a
330
+ * hand-authored workspace whose string globs resolve to raw `vitest/config`
331
+ * sub-configs or bare directory projects — there a provider/runner skew falls
332
+ * back to Vitest's own (softer) warning instead of the guard's hard error.
333
+ */
334
+ function injectPluginIntoProject(project) {
335
+ if (typeof project === "string") return project;
336
+ if (typeof project === "function") {
337
+ const wrapped = (env) => {
338
+ const result = project(env);
339
+ if (result instanceof Promise) return result.then(injectPluginIntoInlineConfig);
340
+ return injectPluginIntoInlineConfig(result);
341
+ };
342
+ return wrapped;
343
+ }
344
+ if (project instanceof Promise) return project.then(injectPluginIntoInlineConfig);
345
+ if (typeof project === "object" && project !== null) return injectPluginIntoInlineConfig(project);
346
+ return project;
347
+ }
348
+ function injectPlugin(config) {
349
+ const injected = injectPluginIntoInlineConfig(config);
350
+ const projects = injected.test?.projects;
351
+ if (!projects || projects.length === 0) return injected;
352
+ return {
353
+ ...injected,
354
+ test: {
355
+ ...injected.test,
356
+ projects: projects.map(injectPluginIntoProject)
357
+ }
358
+ };
359
+ }
360
+ function injectPluginIntoConfig(config) {
361
+ if (typeof config === "function") return (env) => {
362
+ const result = config(env);
363
+ if (result instanceof Promise) return result.then(injectPlugin);
364
+ return injectPlugin(result);
365
+ };
366
+ if (config instanceof Promise) return config.then(injectPlugin);
367
+ return injectPlugin(config);
368
+ }
369
+ function defineConfig(config) {
370
+ return (0, vitest_config.defineConfig)(injectPluginIntoConfig(config));
371
+ }
372
+ /**
373
+ * Inject the vite-plus plugins into a `defineProject` export. A project config
374
+ * (`UserWorkspaceConfig`) cannot itself nest `test.projects`, so this only
375
+ * touches the top-level `plugins` array (no project recursion like
376
+ * [[injectPluginIntoConfig]] does).
377
+ */
378
+ function injectPluginIntoProjectExport(config) {
379
+ if (typeof config === "function") return ((env) => {
380
+ const result = config(env);
381
+ return result instanceof Promise ? result.then(injectPluginIntoInlineConfig) : injectPluginIntoInlineConfig(result);
382
+ });
383
+ if (config instanceof Promise) return config.then(injectPluginIntoInlineConfig);
384
+ return injectPluginIntoInlineConfig(config);
385
+ }
386
+ function defineProject(config) {
387
+ return (0, vitest_config.defineProject)(injectPluginIntoProjectExport(config));
388
+ }
389
+ function lazyPlugins(cb) {
390
+ const cmd = process.env.VP_COMMAND;
391
+ if (!cmd || VITE_COMMANDS.has(cmd)) {
392
+ const result = cb();
393
+ if (result instanceof Promise) return [result];
394
+ return result;
395
+ }
396
+ }
397
+ var vitePlusRequire, vitePlusModuleFile, vitestAnchor, AUTO_INLINE_DEPS, KNOWN_COVERAGE_PROVIDERS, bundledVitestAnchorCache, coverageGuardedVitestInstances, VITE_COMMANDS;
398
+ var init_define_config = __esmMin((() => {
399
+ init_constants();
400
+ vitePlusRequire = (0, node_module.createRequire)(typeof __dirname !== "undefined" ? __dirname : require("url").pathToFileURL(__filename).href);
401
+ vitePlusModuleFile = (0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href);
402
+ AUTO_INLINE_DEPS = [
403
+ "@testing-library/jest-dom",
404
+ "@storybook/test",
405
+ "jest-extended"
406
+ ];
407
+ KNOWN_COVERAGE_PROVIDERS = new Set(["v8", "istanbul"]);
408
+ coverageGuardedVitestInstances = /* @__PURE__ */ new WeakSet();
409
+ VITE_COMMANDS = new Set([
410
+ "dev",
411
+ "build",
412
+ "test",
413
+ "preview"
414
+ ]);
415
+ }));
416
+ //#endregion
417
+ Object.defineProperty(exports, "AUTO_INLINE_DEPS", {
418
+ enumerable: true,
419
+ get: function() {
420
+ return AUTO_INLINE_DEPS;
421
+ }
422
+ });
423
+ Object.defineProperty(exports, "__toCommonJS", {
424
+ enumerable: true,
425
+ get: function() {
426
+ return __toCommonJS;
427
+ }
428
+ });
429
+ Object.defineProperty(exports, "assertCoverageProviderVersionMatch", {
430
+ enumerable: true,
431
+ get: function() {
432
+ return assertCoverageProviderVersionMatch;
433
+ }
434
+ });
435
+ Object.defineProperty(exports, "checkCoverageProviderVersion", {
436
+ enumerable: true,
437
+ get: function() {
438
+ return checkCoverageProviderVersion;
439
+ }
440
+ });
441
+ Object.defineProperty(exports, "computeAutoInlineList", {
442
+ enumerable: true,
443
+ get: function() {
444
+ return computeAutoInlineList;
445
+ }
446
+ });
447
+ Object.defineProperty(exports, "defineConfig", {
448
+ enumerable: true,
449
+ get: function() {
450
+ return defineConfig;
451
+ }
452
+ });
453
+ Object.defineProperty(exports, "defineProject", {
454
+ enumerable: true,
455
+ get: function() {
456
+ return defineProject;
457
+ }
458
+ });
459
+ Object.defineProperty(exports, "define_config_exports", {
460
+ enumerable: true,
461
+ get: function() {
462
+ return define_config_exports;
463
+ }
464
+ });
465
+ Object.defineProperty(exports, "init_define_config", {
466
+ enumerable: true,
467
+ get: function() {
468
+ return init_define_config;
469
+ }
470
+ });
471
+ Object.defineProperty(exports, "isVitestFamilySpecifier", {
472
+ enumerable: true,
473
+ get: function() {
474
+ return isVitestFamilySpecifier;
475
+ }
476
+ });
477
+ Object.defineProperty(exports, "lazyPlugins", {
478
+ enumerable: true,
479
+ get: function() {
480
+ return lazyPlugins;
481
+ }
482
+ });
483
+ Object.defineProperty(exports, "resolveCoverageProviderToCheck", {
484
+ enumerable: true,
485
+ get: function() {
486
+ return resolveCoverageProviderToCheck;
487
+ }
488
+ });