vite-plus 0.3.3 → 1.0.0-rc.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.
- package/LICENSE +35 -146
- package/README.md +6 -4
- package/binding/index.cjs +58 -54
- package/binding/index.d.cts +36 -4
- package/dist/{agent-Cu6-tXIP.js → agent-DIwEez_1.js} +6 -5
- package/dist/bin.js +75 -35
- package/dist/config/bin.js +3 -3
- package/dist/constants-BAsBfS1J.js +356 -0
- package/dist/create/bin.js +19 -13
- package/dist/{define-config-IgzmnvvV.js → define-config-Bz6dc3fm.js} +165 -43
- package/dist/{define-config-D0mevyb3.cjs → define-config-CAeeMTvb.cjs} +179 -44
- package/dist/{define-config-DPNEJxPz.d.ts → define-config-Cf_5GHmY.d.ts} +71 -25
- package/dist/define-config.cjs +1 -1
- package/dist/define-config.d.ts +1 -1
- package/dist/define-config.js +1 -1
- package/dist/dist-BWiANxFS.js +8052 -0
- package/dist/{dist-BDYZP12R.js → dist-BsAzy8OW.js} +109 -105
- package/dist/documentation-DqcZSthV.js +11 -0
- package/dist/{editor-4sjlHmUh.js → editor-DWgrWTbN.js} +246 -159
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{json-cULBl7Pi.js → json-JP24qHUF.js} +14 -6
- package/dist/lint-plugins.cjs +1 -1
- package/dist/migration/bin.js +3127 -18
- package/dist/migration/compat/worker.js +1 -1
- package/dist/{oxlint-plugin-config-BVqEe9KY.js → oxlint-plugin-config-B-P1a_0g.js} +1 -1
- package/dist/oxlint-plugin.js +9 -7
- package/dist/pack-bin.js +1 -1
- package/dist/{package-CHH8jWan.js → package-BrupPpWA.js} +6 -2
- package/dist/{vitest-ecosystem-BiRqcaRI.js → package-overrides-Dpn4scvN.js} +1 -7
- package/dist/{prompts-k14KgthC.js → prompts-BW7_fDGJ.js} +3 -4
- package/dist/{report-CK5TnTsr.js → report-NhQk8VHb.js} +1 -0
- package/dist/{resolve-vite-config-CTOTuqTi.js → resolve-vite-config-D3XIVT6s.js} +1 -1
- package/dist/{resolve-vite-config-BqvS2P98.js → resolve-vite-config-DcsMQaYy.js} +2 -2
- package/dist/staged/bin.js +1206 -3318
- package/dist/sync-versions/bin.js +4 -4
- package/dist/sync-versions/bin.mjs +17 -2
- package/dist/test/browser/context.js +1 -1
- package/dist/test/browser/providers/playwright/context.js +1 -1
- package/dist/test/browser/providers/preview/context.js +1 -1
- package/dist/test/browser-playwright/context.js +1 -1
- package/dist/test/browser-preview/context.js +1 -1
- package/dist/test/context.d.ts +2 -942
- package/dist/test/context.js +1 -1
- package/dist/test/internal/traces.js +1 -0
- package/dist/test/locators.d.ts +2 -294
- package/dist/test/matchers.d.ts +2 -29
- package/dist/test/mocker.d.ts +2 -0
- package/dist/test/mocker.js +1 -0
- package/dist/test/{browser-webdriverio/context.js → plugins/browser-context.d.ts} +1 -0
- package/dist/test/plugins/browser-context.js +1 -1
- package/dist/test/plugins/browser-locators.d.ts +2 -0
- package/dist/test/plugins/browser-playwright.d.ts +2 -0
- package/dist/test/plugins/browser-preview.d.ts +2 -0
- package/dist/test/plugins/browser.d.ts +2 -0
- package/dist/test/plugins/mocker-automock.d.ts +2 -0
- package/dist/test/plugins/mocker-browser.d.ts +2 -0
- package/dist/test/plugins/mocker-node.d.ts +2 -0
- package/dist/test/plugins/mocker-redirect.d.ts +2 -0
- package/dist/test/plugins/mocker-register.d.ts +2 -0
- package/dist/test/plugins/mocker-transforms.d.ts +2 -0
- package/dist/test/plugins/mocker.d.ts +2 -0
- package/dist/test/plugins/pretty-format.d.ts +2 -0
- package/dist/test/plugins/snapshot-environment.d.ts +2 -0
- package/dist/test/plugins/snapshot-manager.d.ts +2 -0
- package/dist/test/plugins/snapshot.d.ts +2 -0
- package/dist/test/plugins/spy.d.ts +2 -0
- package/dist/test/plugins/utils-constants.d.ts +2 -0
- package/dist/test/plugins/utils-diff.d.ts +2 -0
- package/dist/test/plugins/utils-display.d.ts +2 -0
- package/dist/test/plugins/utils-error.d.ts +2 -0
- package/dist/test/plugins/utils-helpers.d.ts +2 -0
- package/dist/test/plugins/utils-offset.d.ts +2 -0
- package/dist/test/plugins/utils-resolver.d.ts +2 -0
- package/dist/test/plugins/utils-serialize.d.ts +2 -0
- package/dist/test/plugins/utils-source-map-node.d.ts +2 -0
- package/dist/test/plugins/utils-source-map.d.ts +2 -0
- package/dist/test/plugins/utils-timers.d.ts +2 -0
- package/dist/test/plugins/utils.d.ts +2 -0
- package/dist/toolchain.js +11 -11
- package/dist/toolchain.json +11 -11
- package/dist/{tsconfig-euB-GmIE.js → tsconfig-DESFDzWP.js} +1 -1
- package/dist/{tsconfig-C3h9CVTA.js → tsconfig-piorpNV7.js} +8 -4
- package/dist/version.js +5 -3
- package/dist/versions.js +6 -6
- package/dist/vitest-ecosystem-BU0AqZq-.js +23 -0
- package/dist/vitest-v5-entry-points-DthU1e_O.js +25 -0
- package/docs/config/fmt.md +4 -2
- package/docs/config/lint.md +4 -2
- package/docs/config/run.md +62 -26
- package/docs/guide/automatic-data-tracking.md +20 -15
- package/docs/guide/cache.md +12 -8
- package/docs/guide/check.md +2 -0
- package/docs/guide/commit-hooks.md +8 -1
- package/docs/guide/env.md +18 -13
- package/docs/guide/fmt.md +6 -2
- package/docs/guide/index.md +1 -1
- package/docs/guide/install.md +1 -1
- package/docs/guide/lint.md +5 -1
- package/docs/guide/local-cli.md +3 -3
- package/docs/guide/migrate-rules.md +58 -12
- package/docs/guide/migrate.md +86 -20
- package/docs/guide/monorepo.md +7 -1
- package/docs/guide/run.md +3 -1
- package/docs/guide/test.md +2 -0
- package/docs/guide/troubleshooting.md +3 -3
- package/docs/guide/vitest-v5.md +221 -0
- package/package.json +64 -87
- package/bin/oxfmt +0 -33
- package/bin/oxlint +0 -38
- package/dist/cli-truncate-Bg3RDXpi.js +0 -865
- package/dist/constants-C2dTOTe-.js +0 -80
- package/dist/dist-Dqv1-Clg.js +0 -3
- package/dist/is-fullwidth-code-point-BUNlIICg.js +0 -8
- package/dist/log-update-CoW8Z4Dl.js +0 -491
- package/dist/semver-CaDAb8vV.js +0 -1400
- package/dist/strip-ansi-C3wrWz9t.js +0 -853
- package/dist/test/browser/providers/webdriverio/context.d.ts +0 -1
- package/dist/test/browser/providers/webdriverio/context.js +0 -1
- package/dist/test/browser/providers/webdriverio.d.ts +0 -77
- package/dist/test/browser/providers/webdriverio.js +0 -1
- package/dist/test/browser-webdriverio/context.d.ts +0 -1
- package/dist/test/browser-webdriverio.d.ts +0 -77
- package/dist/test/browser-webdriverio.js +0 -1
- package/dist/test/coverage.d.ts +0 -2
- package/dist/test/coverage.js +0 -1
- package/dist/test/environments.d.ts +0 -2
- package/dist/test/environments.js +0 -1
- package/dist/test/plugins/browser-webdriverio.js +0 -1
- package/dist/test/plugins/expect.js +0 -1
- package/dist/test/plugins/runner-types.js +0 -1
- package/dist/test/plugins/runner-utils.js +0 -1
- package/dist/test/plugins/runner.js +0 -1
- package/dist/test/reporters.d.ts +0 -2
- package/dist/test/reporters.js +0 -1
- package/dist/test/runners.d.ts +0 -2
- package/dist/test/runners.js +0 -1
- package/dist/test/snapshot.d.ts +0 -2
- package/dist/test/snapshot.js +0 -1
- package/dist/test/suite.d.ts +0 -2
- package/dist/test/suite.js +0 -1
- package/dist/tsgolint-path-CbDReEOx.js +0 -34
- package/dist/tsgolint-path.d.ts +0 -7
- package/dist/tsgolint-path.js +0 -2
- package/dist/wrap-ansi-DNjkuBEp.js +0 -157
- package/dist/wrap-ansi-DUi52C6W.js +0 -2
|
@@ -34,19 +34,40 @@ var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["modu
|
|
|
34
34
|
//#endregion
|
|
35
35
|
let node_fs = require("node:fs");
|
|
36
36
|
let node_module = require("node:module");
|
|
37
|
+
let node_path = require("node:path");
|
|
37
38
|
let node_url = require("node:url");
|
|
38
39
|
let vitest_config = require("vitest/config");
|
|
39
40
|
//#region package.json
|
|
40
|
-
var version = "0.
|
|
41
|
+
var version = "1.0.0-rc.1", VITE_PLUS_VERSION, VITEST_VERSION, CONFIG_METADATA_ENV;
|
|
41
42
|
var init_constants = __esmMin((() => {
|
|
42
43
|
VITE_PLUS_VERSION = process.env.VP_VERSION || version;
|
|
43
|
-
VITEST_VERSION = "
|
|
44
|
+
VITEST_VERSION = "5.0.1";
|
|
44
45
|
process.env.VP_OVERRIDE_PACKAGES ? JSON.parse(process.env.VP_OVERRIDE_PACKAGES) : `${VITE_PLUS_VERSION}`;
|
|
45
46
|
(0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
|
|
46
47
|
process.versions.node, process.release.name;
|
|
47
48
|
CONFIG_METADATA_ENV = "VP_RESOLVING_CONFIG_METADATA";
|
|
48
49
|
}));
|
|
49
50
|
//#endregion
|
|
51
|
+
//#region src/utils/vitest-ecosystem.ts
|
|
52
|
+
var VITEST_EXACT_VERSION_PACKAGES, VITEST_RESOLVER_PACKAGES;
|
|
53
|
+
var init_vitest_ecosystem = __esmMin((() => {
|
|
54
|
+
VITEST_EXACT_VERSION_PACKAGES = /* @__PURE__ */ new Set([
|
|
55
|
+
"@vitest/browser",
|
|
56
|
+
"@vitest/browser-playwright",
|
|
57
|
+
"@vitest/browser-preview",
|
|
58
|
+
"@vitest/coverage-v8",
|
|
59
|
+
"@vitest/coverage-istanbul",
|
|
60
|
+
"@vitest/mocker",
|
|
61
|
+
"@vitest/pretty-format",
|
|
62
|
+
"@vitest/snapshot",
|
|
63
|
+
"@vitest/spy",
|
|
64
|
+
"@vitest/ui",
|
|
65
|
+
"@vitest/utils",
|
|
66
|
+
"@vitest/web-worker"
|
|
67
|
+
]);
|
|
68
|
+
VITEST_RESOLVER_PACKAGES = /* @__PURE__ */ new Set(["vitest", ...VITEST_EXACT_VERSION_PACKAGES]);
|
|
69
|
+
}));
|
|
70
|
+
//#endregion
|
|
50
71
|
//#region src/define-config.ts
|
|
51
72
|
var define_config_exports = /* @__PURE__ */ __exportAll({
|
|
52
73
|
AUTO_INLINE_DEPS: () => AUTO_INLINE_DEPS,
|
|
@@ -69,6 +90,18 @@ function getVitestAnchor() {
|
|
|
69
90
|
}
|
|
70
91
|
return vitestAnchor;
|
|
71
92
|
}
|
|
93
|
+
function getVitestImportTarget(id) {
|
|
94
|
+
const anchor = getVitestAnchor();
|
|
95
|
+
if (!anchor) throw new Error("Cannot resolve the bundled Vitest package. Reinstall vite-plus.");
|
|
96
|
+
vitestExports ??= JSON.parse((0, node_fs.readFileSync)(anchor, "utf8")).exports;
|
|
97
|
+
let target = vitestExports[id === "vitest" ? "." : `.${id.slice(6)}`];
|
|
98
|
+
while (target && typeof target === "object") {
|
|
99
|
+
const conditions = target;
|
|
100
|
+
target = conditions.import ?? conditions.default;
|
|
101
|
+
}
|
|
102
|
+
if (typeof target !== "string" || !target.startsWith("./")) throw new Error(`The bundled Vitest has no ESM export for ${id}.`);
|
|
103
|
+
return (0, node_path.resolve)(anchor, "..", target);
|
|
104
|
+
}
|
|
72
105
|
/**
|
|
73
106
|
* Match the `vitest` / `@vitest/*` family of bare specifiers — the imports a
|
|
74
107
|
* browser-mode Vite dev server must resolve. Any query string is stripped
|
|
@@ -79,7 +112,9 @@ function getVitestAnchor() {
|
|
|
79
112
|
function isVitestFamilySpecifier(id) {
|
|
80
113
|
const bare = id.split("?")[0];
|
|
81
114
|
if (bare.startsWith(".") || bare.startsWith("/") || bare.startsWith("\0")) return false;
|
|
82
|
-
|
|
115
|
+
const segments = bare.split("/");
|
|
116
|
+
const packageName = bare.startsWith("@") ? segments.slice(0, 2).join("/") : segments[0];
|
|
117
|
+
return VITEST_RESOLVER_PACKAGES.has(packageName);
|
|
83
118
|
}
|
|
84
119
|
/**
|
|
85
120
|
* Rescue `vitest` / `@vitest/*` resolution for browser-mode tests.
|
|
@@ -88,10 +123,10 @@ function isVitestFamilySpecifier(id) {
|
|
|
88
123
|
* and `@vitest/browser` are transitive deps. pnpm's isolated layout only
|
|
89
124
|
* exposes a package's *direct* deps, so the browser-mode Vite dev server
|
|
90
125
|
* (rooted at the consumer project) cannot resolve `vitest/internal/browser`,
|
|
91
|
-
* `@vitest/
|
|
126
|
+
* `@vitest/mocker`, etc. Non-browser tests are unaffected — vitest's own
|
|
92
127
|
* module runner handles resolution there.
|
|
93
128
|
*
|
|
94
|
-
* This plugin re-resolves the
|
|
129
|
+
* This plugin re-resolves the explicit Vitest runtime allowlist through Vite's OWN
|
|
95
130
|
* resolver, but ROOTED at `vite-plus`'s location ([[vitePlusModuleFile]]) and
|
|
96
131
|
* then the bundled `vitest`'s location ([[getVitestAnchor]]) BEFORE the
|
|
97
132
|
* project. So every such import binds to the same physical (pinned) Vitest that
|
|
@@ -132,10 +167,61 @@ function isVitestFamilySpecifier(id) {
|
|
|
132
167
|
* [[vitePlusCoverageVersionGuardPlugin]] fails fast on a mismatch instead.
|
|
133
168
|
*/
|
|
134
169
|
function vitePlusVitestResolverPlugin() {
|
|
170
|
+
let isVitestServer = false;
|
|
135
171
|
return {
|
|
136
172
|
name: "vite-plus:vitest-resolver",
|
|
137
173
|
enforce: "pre",
|
|
174
|
+
config: {
|
|
175
|
+
order: "post",
|
|
176
|
+
handler(config, { command }) {
|
|
177
|
+
isVitestServer = command === "serve" && !!config.environments?.["__vitest__"];
|
|
178
|
+
if (!isVitestServer || !config.test?.browser?.enabled) return;
|
|
179
|
+
const aliases = config.resolve?.alias;
|
|
180
|
+
const entries = Array.isArray(aliases) ? [...aliases] : Object.entries(aliases ?? {}).map(([find, replacement]) => ({
|
|
181
|
+
find,
|
|
182
|
+
replacement
|
|
183
|
+
}));
|
|
184
|
+
const runtimeRequire = (0, node_module.createRequire)(getVitestAnchor());
|
|
185
|
+
const targets = new Map([
|
|
186
|
+
"vitest",
|
|
187
|
+
"vitest/internal/browser",
|
|
188
|
+
"vitest/internal/traces",
|
|
189
|
+
"expect-type",
|
|
190
|
+
"magic-string",
|
|
191
|
+
"chai",
|
|
192
|
+
"vite/module-runner"
|
|
193
|
+
].map((id) => [id, id.startsWith("vitest") ? getVitestImportTarget(id) : runtimeRequire.resolve(id)]));
|
|
194
|
+
if (config.test.browser.provider?.name === "preview") {
|
|
195
|
+
const previewRequire = (0, node_module.createRequire)(vitePlusRequire.resolve("@vitest/browser-preview"));
|
|
196
|
+
for (const id of ["@testing-library/user-event", "@testing-library/dom"]) targets.set(id, previewRequire.resolve(id));
|
|
197
|
+
}
|
|
198
|
+
for (const [id, replacement] of targets) {
|
|
199
|
+
if (entries.some(({ find }) => typeof find === "string" ? id === find || id.startsWith(`${find}/`) : new RegExp(find).test(id))) continue;
|
|
200
|
+
entries.push({
|
|
201
|
+
find: new RegExp(`^${id}$`),
|
|
202
|
+
replacement
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
config.resolve ??= {};
|
|
206
|
+
config.resolve.alias = entries;
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
configResolved(config) {
|
|
210
|
+
const seen = /* @__PURE__ */ new Set();
|
|
211
|
+
const plugins = config.plugins;
|
|
212
|
+
const unique = plugins.filter((plugin) => {
|
|
213
|
+
if (!VITE_PLUS_TEST_PLUGIN_NAMES.has(plugin.name)) return true;
|
|
214
|
+
if (seen.has(plugin.name)) return false;
|
|
215
|
+
seen.add(plugin.name);
|
|
216
|
+
return true;
|
|
217
|
+
});
|
|
218
|
+
plugins.splice(0, plugins.length, ...unique);
|
|
219
|
+
},
|
|
138
220
|
async resolveId(id, importer, options) {
|
|
221
|
+
if (isVitestServer && id === "vite-plus/test") return this.resolve("vitest", importer, {
|
|
222
|
+
...options,
|
|
223
|
+
skipSelf: true
|
|
224
|
+
});
|
|
139
225
|
if (!isVitestFamilySpecifier(id)) return null;
|
|
140
226
|
if (id.includes("?")) return null;
|
|
141
227
|
const vitestAnchorPath = getVitestAnchor();
|
|
@@ -164,18 +250,26 @@ function vitePlusVitestResolverPlugin() {
|
|
|
164
250
|
*
|
|
165
251
|
* Exported for unit testing. The `_createRequire` parameter lets tests inject
|
|
166
252
|
* a controlled resolver without needing to spy on Node's ESM module namespace.
|
|
253
|
+
* Callers may share installation results for the same root within one config load.
|
|
167
254
|
*/
|
|
168
|
-
function computeAutoInlineList(existingInline, projectRoot, _createRequire = node_module.createRequire) {
|
|
255
|
+
function computeAutoInlineList(existingInline, projectRoot, _createRequire = node_module.createRequire, installedPackages = /* @__PURE__ */ new Map()) {
|
|
169
256
|
if (existingInline === true) return null;
|
|
170
|
-
|
|
257
|
+
let projectRequire;
|
|
171
258
|
const merged = Array.isArray(existingInline) ? [...existingInline] : [];
|
|
172
259
|
for (const pkg of AUTO_INLINE_DEPS) {
|
|
173
260
|
if (merged.some((entry) => entry === pkg || entry instanceof RegExp && entry.test(pkg))) continue;
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
261
|
+
let installed = installedPackages.get(pkg);
|
|
262
|
+
if (installed === void 0) {
|
|
263
|
+
projectRequire ??= _createRequire(`${projectRoot}/package.json`);
|
|
264
|
+
try {
|
|
265
|
+
projectRequire.resolve(pkg);
|
|
266
|
+
installed = true;
|
|
267
|
+
} catch {
|
|
268
|
+
installed = false;
|
|
269
|
+
}
|
|
270
|
+
installedPackages.set(pkg, installed);
|
|
178
271
|
}
|
|
272
|
+
if (!installed) continue;
|
|
179
273
|
merged.push(pkg);
|
|
180
274
|
}
|
|
181
275
|
const hadEntries = Array.isArray(existingInline) ? existingInline.length : 0;
|
|
@@ -183,18 +277,47 @@ function computeAutoInlineList(existingInline, projectRoot, _createRequire = nod
|
|
|
183
277
|
return merged;
|
|
184
278
|
}
|
|
185
279
|
function vitePlusAutoInlineMatcherPlugin() {
|
|
280
|
+
let projectRoot = "";
|
|
281
|
+
let isVitestServer = false;
|
|
282
|
+
const installedByRoot = /* @__PURE__ */ new Map();
|
|
283
|
+
function inlineList(existing, root) {
|
|
284
|
+
root = (0, node_path.resolve)(root);
|
|
285
|
+
let installed = installedByRoot.get(root);
|
|
286
|
+
if (!installed) {
|
|
287
|
+
installed = /* @__PURE__ */ new Map();
|
|
288
|
+
installedByRoot.set(root, installed);
|
|
289
|
+
}
|
|
290
|
+
return computeAutoInlineList(existing, root, node_module.createRequire, installed);
|
|
291
|
+
}
|
|
186
292
|
return {
|
|
187
293
|
name: "vite-plus:auto-inline-matcher-deps",
|
|
188
294
|
enforce: "pre",
|
|
295
|
+
config: {
|
|
296
|
+
order: "post",
|
|
297
|
+
handler(config, { command }) {
|
|
298
|
+
isVitestServer = command === "serve" && !!config.environments?.["__vitest__"];
|
|
299
|
+
projectRoot = (0, node_path.resolve)(config.root ?? ".");
|
|
300
|
+
installedByRoot.clear();
|
|
301
|
+
}
|
|
302
|
+
},
|
|
303
|
+
configEnvironment(_name, config) {
|
|
304
|
+
if (!isVitestServer) return;
|
|
305
|
+
const existing = config.resolve?.noExternal;
|
|
306
|
+
const merged = inlineList(typeof existing === "string" || existing instanceof RegExp ? [existing] : existing, projectRoot);
|
|
307
|
+
if (merged !== null) {
|
|
308
|
+
config.resolve ??= {};
|
|
309
|
+
config.resolve.noExternal = merged;
|
|
310
|
+
}
|
|
311
|
+
},
|
|
189
312
|
configResolved(resolvedConfig) {
|
|
190
|
-
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
if (
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
313
|
+
if (!isVitestServer) return;
|
|
314
|
+
const config = resolvedConfig;
|
|
315
|
+
const merged = inlineList(config.test?.server?.deps?.inline, config.root);
|
|
316
|
+
if (merged !== null) {
|
|
317
|
+
config.test ??= {};
|
|
318
|
+
config.test.server ??= {};
|
|
319
|
+
config.test.server.deps ??= {};
|
|
320
|
+
config.test.server.deps.inline = merged;
|
|
198
321
|
}
|
|
199
322
|
}
|
|
200
323
|
};
|
|
@@ -299,15 +422,14 @@ function vitePlusCoverageVersionGuardPlugin() {
|
|
|
299
422
|
}
|
|
300
423
|
};
|
|
301
424
|
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
*/
|
|
425
|
+
function withoutVitePlusTestPlugins(plugin) {
|
|
426
|
+
if (Array.isArray(plugin)) return plugin.filter(keepUserPlugin).map(withoutVitePlusTestPlugins);
|
|
427
|
+
if (plugin instanceof Promise) return plugin.then(withoutVitePlusTestPlugins);
|
|
428
|
+
return plugin && VITE_PLUS_TEST_PLUGIN_NAMES.has(plugin.name) ? false : plugin;
|
|
429
|
+
}
|
|
430
|
+
function keepUserPlugin(plugin) {
|
|
431
|
+
return !plugin || !("name" in plugin) || !VITE_PLUS_TEST_PLUGIN_NAMES.has(plugin.name);
|
|
432
|
+
}
|
|
311
433
|
function injectPluginIntoInlineConfig(config) {
|
|
312
434
|
return {
|
|
313
435
|
...config,
|
|
@@ -315,15 +437,13 @@ function injectPluginIntoInlineConfig(config) {
|
|
|
315
437
|
vitePlusVitestResolverPlugin(),
|
|
316
438
|
vitePlusAutoInlineMatcherPlugin(),
|
|
317
439
|
vitePlusCoverageVersionGuardPlugin(),
|
|
318
|
-
...config.plugins ?? []
|
|
440
|
+
...(config.plugins ?? []).filter(keepUserPlugin).map(withoutVitePlusTestPlugins)
|
|
319
441
|
]
|
|
320
442
|
};
|
|
321
443
|
}
|
|
322
444
|
/**
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
* root-level plugins do NOT propagate — without this, files matched by a
|
|
326
|
-
* project's `include` glob never get the vitest resolver / auto-inline plugins.
|
|
445
|
+
* Inline projects inherit root plugins by default in Vitest v5. Only projects
|
|
446
|
+
* with inheritance disabled or an external base need their own injection.
|
|
327
447
|
*
|
|
328
448
|
* Entry shapes (from `TestProjectConfiguration`):
|
|
329
449
|
* - string (glob path like `'./packages/*'`) → passed through unchanged.
|
|
@@ -345,15 +465,18 @@ function injectPluginIntoProject(project) {
|
|
|
345
465
|
if (typeof project === "function") {
|
|
346
466
|
const wrapped = (env) => {
|
|
347
467
|
const result = project(env);
|
|
348
|
-
if (result instanceof Promise) return result.then(
|
|
349
|
-
return
|
|
468
|
+
if (result instanceof Promise) return result.then(injectIndependentProject);
|
|
469
|
+
return injectIndependentProject(result);
|
|
350
470
|
};
|
|
351
471
|
return wrapped;
|
|
352
472
|
}
|
|
353
|
-
if (project instanceof Promise) return project.then(
|
|
354
|
-
if (typeof project === "object" && project !== null) return
|
|
473
|
+
if (project instanceof Promise) return project.then(injectIndependentProject);
|
|
474
|
+
if (typeof project === "object" && project !== null) return injectIndependentProject(project);
|
|
355
475
|
return project;
|
|
356
476
|
}
|
|
477
|
+
function injectIndependentProject(config) {
|
|
478
|
+
return config.extends === false || typeof config.extends === "string" ? injectPlugin(config) : config;
|
|
479
|
+
}
|
|
357
480
|
function injectPlugin(config) {
|
|
358
481
|
const injected = injectPluginIntoInlineConfig(config);
|
|
359
482
|
const projects = injected.test?.projects;
|
|
@@ -375,22 +498,28 @@ function injectPluginIntoConfig(config) {
|
|
|
375
498
|
if (config instanceof Promise) return config.then(injectPlugin);
|
|
376
499
|
return injectPlugin(config);
|
|
377
500
|
}
|
|
501
|
+
/**
|
|
502
|
+
* Keep a single generic signature so callback returns receive one contextual
|
|
503
|
+
* config type. Separate sync and async overloads make TypeScript widen nested
|
|
504
|
+
* literals in async callbacks before overload resolution (for example, an
|
|
505
|
+
* Oxlint rule severity of `'warn'` becomes `string`).
|
|
506
|
+
*/
|
|
378
507
|
function defineConfig(config) {
|
|
379
508
|
return (0, vitest_config.defineConfig)(injectPluginIntoConfig(config));
|
|
380
509
|
}
|
|
381
510
|
/**
|
|
382
511
|
* Inject the vite-plus plugins into a `defineProject` export. A project config
|
|
383
|
-
* (`UserWorkspaceConfig`)
|
|
384
|
-
*
|
|
385
|
-
*
|
|
512
|
+
* (`UserWorkspaceConfig`) can itself declare nested projects in v5. Referenced
|
|
513
|
+
* configs own a Vite server, so inject at their root and apply inheritance rules
|
|
514
|
+
* to their inline children.
|
|
386
515
|
*/
|
|
387
516
|
function injectPluginIntoProjectExport(config) {
|
|
388
517
|
if (typeof config === "function") return (env) => {
|
|
389
518
|
const result = config(env);
|
|
390
|
-
return result instanceof Promise ? result.then(
|
|
519
|
+
return result instanceof Promise ? result.then(injectPlugin) : injectPlugin(result);
|
|
391
520
|
};
|
|
392
|
-
if (config instanceof Promise) return config.then(
|
|
393
|
-
return
|
|
521
|
+
if (config instanceof Promise) return config.then(injectPlugin);
|
|
522
|
+
return injectPlugin(config);
|
|
394
523
|
}
|
|
395
524
|
function defineProject(config) {
|
|
396
525
|
return (0, vitest_config.defineProject)(injectPluginIntoProjectExport(config));
|
|
@@ -432,9 +561,10 @@ function lazyPlugins(cb) {
|
|
|
432
561
|
if (result instanceof Promise) return [result];
|
|
433
562
|
return result;
|
|
434
563
|
}
|
|
435
|
-
var vitePlusRequire, vitePlusModuleFile, vitestAnchor, AUTO_INLINE_DEPS, KNOWN_COVERAGE_PROVIDERS, bundledVitestAnchorCache, coverageGuardedVitestInstances, configMetadataDepth, configMetadataSavedValue;
|
|
564
|
+
var vitePlusRequire, vitePlusModuleFile, vitestAnchor, vitestExports, AUTO_INLINE_DEPS, KNOWN_COVERAGE_PROVIDERS, bundledVitestAnchorCache, coverageGuardedVitestInstances, VITE_PLUS_TEST_PLUGIN_NAMES, configMetadataDepth, configMetadataSavedValue;
|
|
436
565
|
var init_define_config = __esmMin((() => {
|
|
437
566
|
init_constants();
|
|
567
|
+
init_vitest_ecosystem();
|
|
438
568
|
vitePlusRequire = (0, node_module.createRequire)(typeof __dirname !== "undefined" ? __dirname : require("url").pathToFileURL(__filename).href);
|
|
439
569
|
vitePlusModuleFile = (0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href);
|
|
440
570
|
AUTO_INLINE_DEPS = [
|
|
@@ -444,6 +574,11 @@ var init_define_config = __esmMin((() => {
|
|
|
444
574
|
];
|
|
445
575
|
KNOWN_COVERAGE_PROVIDERS = /* @__PURE__ */ new Set(["v8", "istanbul"]);
|
|
446
576
|
coverageGuardedVitestInstances = /* @__PURE__ */ new WeakSet();
|
|
577
|
+
VITE_PLUS_TEST_PLUGIN_NAMES = /* @__PURE__ */ new Set([
|
|
578
|
+
"vite-plus:vitest-resolver",
|
|
579
|
+
"vite-plus:auto-inline-matcher-deps",
|
|
580
|
+
"vite-plus:coverage-version-guard"
|
|
581
|
+
]);
|
|
447
582
|
configMetadataDepth = 0;
|
|
448
583
|
}));
|
|
449
584
|
//#endregion
|
|
@@ -57,11 +57,17 @@ type Task = {
|
|
|
57
57
|
* direct workspace dependency that defines a `build` task.
|
|
58
58
|
*/
|
|
59
59
|
dependsOn?: Array<DependsOnEntry>;
|
|
60
|
-
} & ({
|
|
61
60
|
/**
|
|
62
|
-
* Whether to cache the task
|
|
61
|
+
* Whether and how to cache the task.
|
|
62
|
+
*
|
|
63
|
+
* - Omitted or `true`: caching enabled with default settings (same as `{}`)
|
|
64
|
+
* - `false`: caching disabled
|
|
65
|
+
* - Object: caching enabled with the given settings
|
|
63
66
|
*/
|
|
64
|
-
cache?:
|
|
67
|
+
cache?: TaskCache;
|
|
68
|
+
};
|
|
69
|
+
type TaskCache = boolean | TaskCacheConfig;
|
|
70
|
+
type TaskCacheConfig = {
|
|
65
71
|
/**
|
|
66
72
|
* Environment variable names to be fingerprinted and passed to the task.
|
|
67
73
|
*/
|
|
@@ -92,12 +98,7 @@ type Task = {
|
|
|
92
98
|
* - Negative patterns (e.g. `"!dist/cache/**"`) exclude matched files
|
|
93
99
|
*/
|
|
94
100
|
output?: Array<string | GlobWithBase | AutoTracking>;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Whether to cache the task
|
|
98
|
-
*/
|
|
99
|
-
cache: false;
|
|
100
|
-
});
|
|
101
|
+
};
|
|
101
102
|
type TaskDefinition = Task | Command;
|
|
102
103
|
type UserGlobalCacheConfig = boolean | {
|
|
103
104
|
/**
|
|
@@ -112,7 +113,8 @@ type UserGlobalCacheConfig = boolean | {
|
|
|
112
113
|
/**
|
|
113
114
|
* Global cache kill switch for task entries.
|
|
114
115
|
*
|
|
115
|
-
* When `false`, overrides all tasks to disable caching, even tasks with `cache: true
|
|
116
|
+
* When `false`, overrides all tasks to disable caching, even tasks with `cache: true`
|
|
117
|
+
* or a `cache` object.
|
|
116
118
|
* When `true`, respects each task's individual `cache` setting
|
|
117
119
|
* (each task's `cache` defaults to `true` if omitted).
|
|
118
120
|
*
|
|
@@ -155,15 +157,56 @@ type RunConfig = {
|
|
|
155
157
|
enablePrePostScripts?: boolean;
|
|
156
158
|
};
|
|
157
159
|
//#endregion
|
|
158
|
-
//#region ../../node_modules/.pnpm/lint-staged@
|
|
159
|
-
|
|
160
|
-
|
|
160
|
+
//#region ../../node_modules/.pnpm/lint-staged@17.5.1/node_modules/lint-staged/lib/config.d.ts
|
|
161
|
+
/**
|
|
162
|
+
* A single task that will be spawned
|
|
163
|
+
*
|
|
164
|
+
* @example "eslint --fix"
|
|
165
|
+
*/
|
|
166
|
+
type SpawnedTask = string;
|
|
167
|
+
type SyncGenerateTask = (files: readonly string[]) => string | string[];
|
|
168
|
+
type AsyncGenerateTask = (files: readonly string[]) => Promise<string | string[]>;
|
|
169
|
+
/**
|
|
170
|
+
* A function that returns one or more tasks that will be spawned and run sequentially, in order.
|
|
171
|
+
* The function receives list of the matched staged files as its argument. Can be sync or async.
|
|
172
|
+
*
|
|
173
|
+
* @example <caption>Return a command after manipulating list of staged files</caption>
|
|
174
|
+
* (files: string) => `eslint --fix ${files.map((f) => `'${f}'`).join(' ')}`
|
|
175
|
+
*
|
|
176
|
+
* @example <caption>Ignore staged files and run "tsc" and "vitest" without any arguments</caption>
|
|
177
|
+
* () => ['tsc', 'vitest']
|
|
178
|
+
*/
|
|
161
179
|
type GenerateTask = SyncGenerateTask | AsyncGenerateTask;
|
|
180
|
+
/**
|
|
181
|
+
* List of tasks that will be run in parallel
|
|
182
|
+
*
|
|
183
|
+
* @example ["prettier --write", "eslint --fix"]
|
|
184
|
+
*/
|
|
185
|
+
type ParallelTasks = (SpawnedTask | GenerateTask)[];
|
|
186
|
+
/**
|
|
187
|
+
* List of tasks that will be run sequentially, in order
|
|
188
|
+
*
|
|
189
|
+
* @example ["prettier --write", "eslint --fix"]
|
|
190
|
+
*/
|
|
191
|
+
type SequentialTasks = (SpawnedTask | GenerateTask | ParallelTasks)[];
|
|
192
|
+
/**
|
|
193
|
+
* A single Node.js/JavaScript task that defines its title and the function which will be
|
|
194
|
+
* run with the list of the matched staged files as its argument.
|
|
195
|
+
*
|
|
196
|
+
* @example
|
|
197
|
+
* {
|
|
198
|
+
* title: 'Log staged files',
|
|
199
|
+
* task: (files: readonly string[]) => {
|
|
200
|
+
* console.log('Staged files:', files)
|
|
201
|
+
* }
|
|
202
|
+
* }
|
|
203
|
+
*/
|
|
162
204
|
type TaskFunction = {
|
|
163
205
|
title: string;
|
|
164
|
-
task: (
|
|
206
|
+
task: (filepaths: readonly string[]) => void | Promise<void>;
|
|
165
207
|
};
|
|
166
|
-
|
|
208
|
+
/** An entire `lint-staged` configuration, or a function that returns one */
|
|
209
|
+
type Configuration = Record<string, SpawnedTask | TaskFunction | GenerateTask | SequentialTasks> | GenerateTask;
|
|
167
210
|
//#endregion
|
|
168
211
|
//#region src/staged-config.d.ts
|
|
169
212
|
type StagedConfig = Configuration;
|
|
@@ -246,6 +289,7 @@ type ViteUserConfigFnObject = (env: ConfigEnv) => UserConfig;
|
|
|
246
289
|
type ViteUserConfigFnPromise = (env: ConfigEnv) => Promise<UserConfig>;
|
|
247
290
|
type ViteUserConfigFn = (env: ConfigEnv) => UserConfig | Promise<UserConfig>;
|
|
248
291
|
type ViteUserConfigExport = UserConfig | Promise<UserConfig> | ViteUserConfigFnObject | ViteUserConfigFnPromise | ViteUserConfigFn;
|
|
292
|
+
type DefinedViteUserConfig<T extends ViteUserConfigExport> = T extends ViteUserConfigFnPromise ? ViteUserConfigFnPromise : T extends ViteUserConfigFnObject ? ViteUserConfigFnObject : T extends ViteUserConfigFn ? ViteUserConfigFn : T extends Promise<UserConfig> ? Promise<UserConfig> : UserConfig;
|
|
249
293
|
/**
|
|
250
294
|
* Match the `vitest` / `@vitest/*` family of bare specifiers — the imports a
|
|
251
295
|
* browser-mode Vite dev server must resolve. Any query string is stripped
|
|
@@ -266,10 +310,9 @@ declare function isVitestFamilySpecifier(id: string): boolean;
|
|
|
266
310
|
* Absent packages are silently skipped so the server-deps optimizer never
|
|
267
311
|
* tries to resolve a name that does not exist in the project's node_modules.
|
|
268
312
|
*
|
|
269
|
-
* The
|
|
270
|
-
*
|
|
271
|
-
*
|
|
272
|
-
* time (which can differ in workspace / monorepo setups).
|
|
313
|
+
* The environment hook adds installed packages to the module-runner options
|
|
314
|
+
* inherited by shared-server projects. The resolved-config hook also handles
|
|
315
|
+
* independent project servers, using each project's resolved root.
|
|
273
316
|
*
|
|
274
317
|
* Exported for unit testing.
|
|
275
318
|
*/
|
|
@@ -284,10 +327,11 @@ declare const AUTO_INLINE_DEPS: ReadonlyArray<string>;
|
|
|
284
327
|
*
|
|
285
328
|
* Exported for unit testing. The `_createRequire` parameter lets tests inject
|
|
286
329
|
* a controlled resolver without needing to spy on Node's ESM module namespace.
|
|
330
|
+
* Callers may share installation results for the same root within one config load.
|
|
287
331
|
*/
|
|
288
332
|
declare function computeAutoInlineList(existingInline: (string | RegExp)[] | true | undefined, projectRoot: string, _createRequire?: (from: string) => {
|
|
289
333
|
resolve: (id: string) => string;
|
|
290
|
-
}): (string | RegExp)[] | null;
|
|
334
|
+
}, installedPackages?: Map<string, boolean>): (string | RegExp)[] | null;
|
|
291
335
|
/**
|
|
292
336
|
* Resolve the coverage provider package name that should be version-checked, or
|
|
293
337
|
* `null` when no check applies (coverage off, or a `custom`/unknown provider
|
|
@@ -333,11 +377,13 @@ declare function checkCoverageProviderVersion(coverage: {
|
|
|
333
377
|
};
|
|
334
378
|
readFile?: (path: string) => string;
|
|
335
379
|
}): void;
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
380
|
+
/**
|
|
381
|
+
* Keep a single generic signature so callback returns receive one contextual
|
|
382
|
+
* config type. Separate sync and async overloads make TypeScript widen nested
|
|
383
|
+
* literals in async callbacks before overload resolution (for example, an
|
|
384
|
+
* Oxlint rule severity of `'warn'` becomes `string`).
|
|
385
|
+
*/
|
|
386
|
+
declare function defineConfig$1<T extends ViteUserConfigExport>(config: T): DefinedViteUserConfig<T>;
|
|
341
387
|
/**
|
|
342
388
|
* `defineProject` counterpart of [[defineConfig]]. A migrated project config
|
|
343
389
|
* that uses `defineProject({ test: { browser: ... } })` — e.g. a file named by
|
package/dist/define-config.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_define_config = require("./define-config-
|
|
2
|
+
const require_define_config = require("./define-config-CAeeMTvb.cjs");
|
|
3
3
|
require_define_config.init_define_config();
|
|
4
4
|
exports.AUTO_INLINE_DEPS = require_define_config.AUTO_INLINE_DEPS;
|
|
5
5
|
exports.assertCoverageProviderVersionMatch = require_define_config.assertCoverageProviderVersionMatch;
|
package/dist/define-config.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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, u as withConfigMetadataResolution } from "./define-config-
|
|
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, u as withConfigMetadataResolution } from "./define-config-Cf_5GHmY.js";
|
|
2
2
|
export { AUTO_INLINE_DEPS, assertCoverageProviderVersionMatch, checkCoverageProviderVersion, computeAutoInlineList, defineConfig, defineProject, isVitestFamilySpecifier, lazyPlugins, resolveCoverageProviderToCheck, withConfigMetadataResolution };
|
package/dist/define-config.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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, u as withConfigMetadataResolution } from "./define-config-
|
|
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, u as withConfigMetadataResolution } from "./define-config-Bz6dc3fm.js";
|
|
2
2
|
export { AUTO_INLINE_DEPS, assertCoverageProviderVersionMatch, checkCoverageProviderVersion, computeAutoInlineList, defineConfig, defineProject, isVitestFamilySpecifier, lazyPlugins, resolveCoverageProviderToCheck, withConfigMetadataResolution };
|