vitest 0.25.2 → 0.25.4
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.md +47 -2
- package/dist/browser.d.ts +3 -3
- package/dist/browser.js +10 -9
- package/dist/{chunk-api-setup.c5a9009c.js → chunk-api-setup.1c8923c4.js} +4 -2
- package/dist/{chunk-integrations-globals.06c8d418.js → chunk-integrations-globals.789c69e2.js} +7 -7
- package/dist/{chunk-runtime-chain.a0b441dc.js → chunk-runtime-chain.315721df.js} +25 -9
- package/dist/{chunk-runtime-error.6287172c.js → chunk-runtime-error.95c286d7.js} +2 -2
- package/dist/{chunk-runtime-mocker.a5151f99.js → chunk-runtime-mocker.cdc0ec57.js} +35 -19
- package/dist/{chunk-runtime-rpc.1e7530d3.js → chunk-runtime-rpc.b368762d.js} +2 -2
- package/dist/chunk-runtime-setup.80b27439.js +659 -0
- package/dist/{chunk-runtime-test-state.3cbc4575.js → chunk-runtime-test-state.7c288e2d.js} +78 -39
- package/dist/{chunk-typecheck-constants.4891f22f.js → chunk-typecheck-constants.ed987901.js} +12 -2
- package/dist/{chunk-utils-source-map.c6dfbbc1.js → chunk-utils-source-map.29ff1088.js} +3 -1
- package/dist/{chunk-utils-timers.06f993db.js → chunk-utils-timers.b81cda77.js} +2 -0
- package/dist/{chunk-vite-node-externalize.72a4d20b.js → chunk-vite-node-externalize.ddcbafa3.js} +59 -29
- package/dist/{chunk-vite-node-client.85cc7113.js → chunk-vite-node-source-map.61c5ea66.js} +37 -11
- package/dist/{chunk-vite-node-utils.8f0b4a12.js → chunk-vite-node-utils.abe05c5c.js} +105 -120
- package/dist/cli.js +14 -10
- package/dist/config.cjs +2 -1
- package/dist/config.d.ts +2 -1
- package/dist/config.js +2 -1
- package/dist/entry.js +9 -8
- package/dist/environments.d.ts +1 -1
- package/dist/{index-2f5b6168.d.ts → index-81973d31.d.ts} +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +7 -7
- package/dist/loader.js +2 -2
- package/dist/node.d.ts +5 -4
- package/dist/node.js +9 -8
- package/dist/suite.js +6 -6
- package/dist/{types-f302dae9.d.ts → types-1cf24598.d.ts} +71 -24
- package/dist/{chunk-runtime-setup.419ccdd8.js → vendor-source-map-support.1ce17397.js} +1 -657
- package/dist/worker.js +9 -7
- package/package.json +6 -6
|
@@ -8,55 +8,39 @@ import assert from 'assert';
|
|
|
8
8
|
import { format, inspect } from 'util';
|
|
9
9
|
|
|
10
10
|
const TRAILING_SLASH_RE = /\/$|\/\?/;
|
|
11
|
-
function hasTrailingSlash(input = "",
|
|
12
|
-
if (!
|
|
11
|
+
function hasTrailingSlash(input = "", queryParameters = false) {
|
|
12
|
+
if (!queryParameters) {
|
|
13
13
|
return input.endsWith("/");
|
|
14
14
|
}
|
|
15
15
|
return TRAILING_SLASH_RE.test(input);
|
|
16
16
|
}
|
|
17
|
-
function withTrailingSlash(input = "",
|
|
18
|
-
if (!
|
|
17
|
+
function withTrailingSlash(input = "", queryParameters = false) {
|
|
18
|
+
if (!queryParameters) {
|
|
19
19
|
return input.endsWith("/") ? input : input + "/";
|
|
20
20
|
}
|
|
21
21
|
if (hasTrailingSlash(input, true)) {
|
|
22
22
|
return input || "/";
|
|
23
23
|
}
|
|
24
24
|
const [s0, ...s] = input.split("?");
|
|
25
|
-
return s0 + "/" + (s.length ? `?${s.join("?")}` : "");
|
|
25
|
+
return s0 + "/" + (s.length > 0 ? `?${s.join("?")}` : "");
|
|
26
26
|
}
|
|
27
27
|
function hasLeadingSlash(input = "") {
|
|
28
28
|
return input.startsWith("/");
|
|
29
29
|
}
|
|
30
30
|
function withoutLeadingSlash(input = "") {
|
|
31
|
-
return (hasLeadingSlash(input) ? input.
|
|
31
|
+
return (hasLeadingSlash(input) ? input.slice(1) : input) || "/";
|
|
32
32
|
}
|
|
33
33
|
function isNonEmptyURL(url) {
|
|
34
34
|
return url && url !== "/";
|
|
35
35
|
}
|
|
36
36
|
function joinURL(base, ...input) {
|
|
37
37
|
let url = base || "";
|
|
38
|
-
for (const
|
|
39
|
-
url = url ? withTrailingSlash(url) + withoutLeadingSlash(
|
|
38
|
+
for (const index of input.filter((url2) => isNonEmptyURL(url2))) {
|
|
39
|
+
url = url ? withTrailingSlash(url) + withoutLeadingSlash(index) : index;
|
|
40
40
|
}
|
|
41
41
|
return url;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
function normalizeWindowsPath$1(input = "") {
|
|
45
|
-
if (!input || !input.includes("\\")) {
|
|
46
|
-
return input;
|
|
47
|
-
}
|
|
48
|
-
return input.replace(/\\/g, "/");
|
|
49
|
-
}
|
|
50
|
-
const _IS_ABSOLUTE_RE$1 = /^[\\/](?![\\/])|^[\\/]{2}(?!\.)|^[a-zA-Z]:[\\/]/;
|
|
51
|
-
const isAbsolute$1 = function(p) {
|
|
52
|
-
return _IS_ABSOLUTE_RE$1.test(p);
|
|
53
|
-
};
|
|
54
|
-
const _EXTNAME_RE = /.(\.[^/.]+)$/;
|
|
55
|
-
const extname = function(p) {
|
|
56
|
-
const match = _EXTNAME_RE.exec(normalizeWindowsPath$1(p));
|
|
57
|
-
return match && match[1] || "";
|
|
58
|
-
};
|
|
59
|
-
|
|
60
44
|
function normalizeWindowsPath(input = "") {
|
|
61
45
|
if (!input || !input.includes("\\")) {
|
|
62
46
|
return input;
|
|
@@ -64,9 +48,9 @@ function normalizeWindowsPath(input = "") {
|
|
|
64
48
|
return input.replace(/\\/g, "/");
|
|
65
49
|
}
|
|
66
50
|
|
|
67
|
-
const _UNC_REGEX = /^[
|
|
68
|
-
const _IS_ABSOLUTE_RE = /^[
|
|
69
|
-
const _DRIVE_LETTER_RE = /^[
|
|
51
|
+
const _UNC_REGEX = /^[/\\]{2}/;
|
|
52
|
+
const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
53
|
+
const _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
|
|
70
54
|
const normalize = function(path) {
|
|
71
55
|
if (path.length === 0) {
|
|
72
56
|
return ".";
|
|
@@ -96,18 +80,17 @@ const normalize = function(path) {
|
|
|
96
80
|
}
|
|
97
81
|
return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
|
|
98
82
|
};
|
|
99
|
-
const join = function(...
|
|
100
|
-
if (
|
|
83
|
+
const join = function(...arguments_) {
|
|
84
|
+
if (arguments_.length === 0) {
|
|
101
85
|
return ".";
|
|
102
86
|
}
|
|
103
87
|
let joined;
|
|
104
|
-
for (
|
|
105
|
-
|
|
106
|
-
if (arg && arg.length > 0) {
|
|
88
|
+
for (const argument of arguments_) {
|
|
89
|
+
if (argument && argument.length > 0) {
|
|
107
90
|
if (joined === void 0) {
|
|
108
|
-
joined =
|
|
91
|
+
joined = argument;
|
|
109
92
|
} else {
|
|
110
|
-
joined += `/${
|
|
93
|
+
joined += `/${argument}`;
|
|
111
94
|
}
|
|
112
95
|
}
|
|
113
96
|
}
|
|
@@ -116,12 +99,12 @@ const join = function(...args) {
|
|
|
116
99
|
}
|
|
117
100
|
return normalize(joined.replace(/\/\/+/g, "/"));
|
|
118
101
|
};
|
|
119
|
-
const resolve = function(...
|
|
120
|
-
|
|
102
|
+
const resolve = function(...arguments_) {
|
|
103
|
+
arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
|
|
121
104
|
let resolvedPath = "";
|
|
122
105
|
let resolvedAbsolute = false;
|
|
123
|
-
for (let
|
|
124
|
-
const path =
|
|
106
|
+
for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
|
|
107
|
+
const path = index >= 0 ? arguments_[index] : process.cwd().replace(/\\/g, "/");
|
|
125
108
|
if (!path || path.length === 0) {
|
|
126
109
|
continue;
|
|
127
110
|
}
|
|
@@ -140,16 +123,16 @@ function normalizeString(path, allowAboveRoot) {
|
|
|
140
123
|
let lastSlash = -1;
|
|
141
124
|
let dots = 0;
|
|
142
125
|
let char = null;
|
|
143
|
-
for (let
|
|
144
|
-
if (
|
|
145
|
-
char = path[
|
|
126
|
+
for (let index = 0; index <= path.length; ++index) {
|
|
127
|
+
if (index < path.length) {
|
|
128
|
+
char = path[index];
|
|
146
129
|
} else if (char === "/") {
|
|
147
130
|
break;
|
|
148
131
|
} else {
|
|
149
132
|
char = "/";
|
|
150
133
|
}
|
|
151
134
|
if (char === "/") {
|
|
152
|
-
if (lastSlash ===
|
|
135
|
+
if (lastSlash === index - 1 || dots === 1) ; else if (dots === 2) {
|
|
153
136
|
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
154
137
|
if (res.length > 2) {
|
|
155
138
|
const lastSlashIndex = res.lastIndexOf("/");
|
|
@@ -160,13 +143,13 @@ function normalizeString(path, allowAboveRoot) {
|
|
|
160
143
|
res = res.slice(0, lastSlashIndex);
|
|
161
144
|
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
162
145
|
}
|
|
163
|
-
lastSlash =
|
|
146
|
+
lastSlash = index;
|
|
164
147
|
dots = 0;
|
|
165
148
|
continue;
|
|
166
|
-
} else if (res.length
|
|
149
|
+
} else if (res.length > 0) {
|
|
167
150
|
res = "";
|
|
168
151
|
lastSegmentLength = 0;
|
|
169
|
-
lastSlash =
|
|
152
|
+
lastSlash = index;
|
|
170
153
|
dots = 0;
|
|
171
154
|
continue;
|
|
172
155
|
}
|
|
@@ -177,13 +160,13 @@ function normalizeString(path, allowAboveRoot) {
|
|
|
177
160
|
}
|
|
178
161
|
} else {
|
|
179
162
|
if (res.length > 0) {
|
|
180
|
-
res += `/${path.slice(lastSlash + 1,
|
|
163
|
+
res += `/${path.slice(lastSlash + 1, index)}`;
|
|
181
164
|
} else {
|
|
182
|
-
res = path.slice(lastSlash + 1,
|
|
165
|
+
res = path.slice(lastSlash + 1, index);
|
|
183
166
|
}
|
|
184
|
-
lastSegmentLength =
|
|
167
|
+
lastSegmentLength = index - lastSlash - 1;
|
|
185
168
|
}
|
|
186
|
-
lastSlash =
|
|
169
|
+
lastSlash = index;
|
|
187
170
|
dots = 0;
|
|
188
171
|
} else if (char === "." && dots !== -1) {
|
|
189
172
|
++dots;
|
|
@@ -196,6 +179,11 @@ function normalizeString(path, allowAboveRoot) {
|
|
|
196
179
|
const isAbsolute = function(p) {
|
|
197
180
|
return _IS_ABSOLUTE_RE.test(p);
|
|
198
181
|
};
|
|
182
|
+
const _EXTNAME_RE = /.(\.[^./]+)$/;
|
|
183
|
+
const extname = function(p) {
|
|
184
|
+
const match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
|
|
185
|
+
return match && match[1] || "";
|
|
186
|
+
};
|
|
199
187
|
|
|
200
188
|
const defaultFindOptions = {
|
|
201
189
|
startingFrom: ".",
|
|
@@ -208,7 +196,6 @@ const defaultFindOptions = {
|
|
|
208
196
|
}
|
|
209
197
|
} catch {
|
|
210
198
|
}
|
|
211
|
-
return null;
|
|
212
199
|
}
|
|
213
200
|
};
|
|
214
201
|
async function findFile(filename, _options = {}) {
|
|
@@ -224,15 +211,15 @@ async function findFile(filename, _options = {}) {
|
|
|
224
211
|
root = 0;
|
|
225
212
|
}
|
|
226
213
|
if (!options.reverse) {
|
|
227
|
-
for (let
|
|
228
|
-
const filePath = join(...segments.slice(0,
|
|
214
|
+
for (let index = segments.length; index > root; index--) {
|
|
215
|
+
const filePath = join(...segments.slice(0, index), filename);
|
|
229
216
|
if (await options.test(filePath)) {
|
|
230
217
|
return filePath;
|
|
231
218
|
}
|
|
232
219
|
}
|
|
233
220
|
} else {
|
|
234
|
-
for (let
|
|
235
|
-
const filePath = join(...segments.slice(0,
|
|
221
|
+
for (let index = root + 1; index <= segments.length; index++) {
|
|
222
|
+
const filePath = join(...segments.slice(0, index), filename);
|
|
236
223
|
if (await options.test(filePath)) {
|
|
237
224
|
return filePath;
|
|
238
225
|
}
|
|
@@ -243,35 +230,43 @@ async function findFile(filename, _options = {}) {
|
|
|
243
230
|
function findNearestFile(filename, _options = {}) {
|
|
244
231
|
return findFile(filename, _options);
|
|
245
232
|
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
const
|
|
249
|
-
|
|
233
|
+
const FileCache = /* @__PURE__ */ new Map();
|
|
234
|
+
async function readPackageJSON(id, options = {}) {
|
|
235
|
+
const resolvedPath = await resolvePackageJSON(id, options);
|
|
236
|
+
const cache = options.cache && typeof options.cache !== "boolean" ? options.cache : FileCache;
|
|
237
|
+
if (options.cache && cache.has(resolvedPath)) {
|
|
238
|
+
return cache.get(resolvedPath);
|
|
239
|
+
}
|
|
240
|
+
const blob = await promises.readFile(resolvedPath, "utf8");
|
|
241
|
+
const parsed = JSON.parse(blob);
|
|
242
|
+
cache.set(resolvedPath, parsed);
|
|
243
|
+
return parsed;
|
|
250
244
|
}
|
|
251
|
-
async function resolvePackageJSON(id = process.cwd(),
|
|
252
|
-
const resolvedPath = isAbsolute(id) ? id : await resolvePath(id,
|
|
253
|
-
return findNearestFile("package.json", { startingFrom: resolvedPath, ...
|
|
245
|
+
async function resolvePackageJSON(id = process.cwd(), options = {}) {
|
|
246
|
+
const resolvedPath = isAbsolute(id) ? id : await resolvePath(id, options);
|
|
247
|
+
return findNearestFile("package.json", { startingFrom: resolvedPath, ...options });
|
|
254
248
|
}
|
|
255
249
|
|
|
256
250
|
const BUILTIN_MODULES = new Set(builtinModules);
|
|
257
|
-
function normalizeSlash(
|
|
258
|
-
return
|
|
251
|
+
function normalizeSlash(string_) {
|
|
252
|
+
return string_.replace(/\\/g, "/");
|
|
259
253
|
}
|
|
260
|
-
function pcall(
|
|
254
|
+
function pcall(function_, ...arguments_) {
|
|
261
255
|
try {
|
|
262
|
-
return Promise.resolve(
|
|
263
|
-
} catch (
|
|
264
|
-
return perr(
|
|
256
|
+
return Promise.resolve(function_(...arguments_)).catch((error) => perr(error));
|
|
257
|
+
} catch (error) {
|
|
258
|
+
return perr(error);
|
|
265
259
|
}
|
|
266
260
|
}
|
|
267
|
-
function perr(
|
|
268
|
-
const
|
|
269
|
-
|
|
270
|
-
Error.captureStackTrace(
|
|
271
|
-
return Promise.reject(
|
|
261
|
+
function perr(_error) {
|
|
262
|
+
const error = new Error(_error);
|
|
263
|
+
error.code = _error.code;
|
|
264
|
+
Error.captureStackTrace(error, pcall);
|
|
265
|
+
return Promise.reject(error);
|
|
272
266
|
}
|
|
273
267
|
|
|
274
268
|
const reader = { read };
|
|
269
|
+
const packageJsonReader = reader;
|
|
275
270
|
function read(jsonPath) {
|
|
276
271
|
return find(path.dirname(jsonPath));
|
|
277
272
|
}
|
|
@@ -591,7 +586,7 @@ function getPackageConfig(path2, specifier, base) {
|
|
|
591
586
|
if (existing !== void 0) {
|
|
592
587
|
return existing;
|
|
593
588
|
}
|
|
594
|
-
const source =
|
|
589
|
+
const source = packageJsonReader.read(path2).string;
|
|
595
590
|
if (source === void 0) {
|
|
596
591
|
const packageConfig2 = {
|
|
597
592
|
pjsonPath: path2,
|
|
@@ -1212,7 +1207,7 @@ function isNodeBuiltin(id = "") {
|
|
|
1212
1207
|
const ProtocolRegex = /^(?<proto>.{2,}?):.+$/;
|
|
1213
1208
|
function getProtocol(id) {
|
|
1214
1209
|
const proto = id.match(ProtocolRegex);
|
|
1215
|
-
return proto ? proto.groups.proto :
|
|
1210
|
+
return proto ? proto.groups.proto : void 0;
|
|
1216
1211
|
}
|
|
1217
1212
|
|
|
1218
1213
|
const DEFAULT_CONDITIONS_SET = /* @__PURE__ */ new Set(["node", "import"]);
|
|
@@ -1222,35 +1217,36 @@ const NOT_FOUND_ERRORS = /* @__PURE__ */ new Set(["ERR_MODULE_NOT_FOUND", "ERR_U
|
|
|
1222
1217
|
function _tryModuleResolve(id, url, conditions) {
|
|
1223
1218
|
try {
|
|
1224
1219
|
return moduleResolve(id, url, conditions);
|
|
1225
|
-
} catch (
|
|
1226
|
-
if (!NOT_FOUND_ERRORS.has(
|
|
1227
|
-
throw
|
|
1220
|
+
} catch (error) {
|
|
1221
|
+
if (!NOT_FOUND_ERRORS.has(error.code)) {
|
|
1222
|
+
throw error;
|
|
1228
1223
|
}
|
|
1229
|
-
return null;
|
|
1230
1224
|
}
|
|
1231
1225
|
}
|
|
1232
|
-
function _resolve(id,
|
|
1226
|
+
function _resolve(id, options = {}) {
|
|
1233
1227
|
if (/(node|data|http|https):/.test(id)) {
|
|
1234
1228
|
return id;
|
|
1235
1229
|
}
|
|
1236
1230
|
if (BUILTIN_MODULES.has(id)) {
|
|
1237
1231
|
return "node:" + id;
|
|
1238
1232
|
}
|
|
1239
|
-
if (isAbsolute
|
|
1233
|
+
if (isAbsolute(id) && existsSync(id)) {
|
|
1240
1234
|
const realPath2 = realpathSync(fileURLToPath(id));
|
|
1241
1235
|
return pathToFileURL(realPath2).toString();
|
|
1242
1236
|
}
|
|
1243
|
-
const conditionsSet =
|
|
1244
|
-
const _urls = (Array.isArray(
|
|
1245
|
-
if (
|
|
1237
|
+
const conditionsSet = options.conditions ? new Set(options.conditions) : DEFAULT_CONDITIONS_SET;
|
|
1238
|
+
const _urls = (Array.isArray(options.url) ? options.url : [options.url]).filter(Boolean).map((u) => new URL(normalizeid(u.toString())));
|
|
1239
|
+
if (_urls.length === 0) {
|
|
1246
1240
|
_urls.push(DEFAULT_URL);
|
|
1247
1241
|
}
|
|
1248
1242
|
const urls = [..._urls];
|
|
1249
1243
|
for (const url of _urls) {
|
|
1250
1244
|
if (url.protocol === "file:") {
|
|
1251
|
-
urls.push(
|
|
1252
|
-
|
|
1253
|
-
|
|
1245
|
+
urls.push(
|
|
1246
|
+
new URL("./", url),
|
|
1247
|
+
new URL(joinURL(url.pathname, "_index.js"), url),
|
|
1248
|
+
new URL("node_modules", url)
|
|
1249
|
+
);
|
|
1254
1250
|
}
|
|
1255
1251
|
}
|
|
1256
1252
|
let resolved;
|
|
@@ -1260,8 +1256,8 @@ function _resolve(id, opts = {}) {
|
|
|
1260
1256
|
break;
|
|
1261
1257
|
}
|
|
1262
1258
|
for (const prefix of ["", "/index"]) {
|
|
1263
|
-
for (const
|
|
1264
|
-
resolved = _tryModuleResolve(id + prefix +
|
|
1259
|
+
for (const extension of options.extensions || DEFAULT_EXTENSIONS) {
|
|
1260
|
+
resolved = _tryModuleResolve(id + prefix + extension, url, conditionsSet);
|
|
1265
1261
|
if (resolved) {
|
|
1266
1262
|
break;
|
|
1267
1263
|
}
|
|
@@ -1272,24 +1268,24 @@ function _resolve(id, opts = {}) {
|
|
|
1272
1268
|
}
|
|
1273
1269
|
}
|
|
1274
1270
|
if (!resolved) {
|
|
1275
|
-
const
|
|
1276
|
-
|
|
1277
|
-
throw
|
|
1271
|
+
const error = new Error(`Cannot find module ${id} imported from ${urls.join(", ")}`);
|
|
1272
|
+
error.code = "ERR_MODULE_NOT_FOUND";
|
|
1273
|
+
throw error;
|
|
1278
1274
|
}
|
|
1279
1275
|
const realPath = realpathSync(fileURLToPath(resolved));
|
|
1280
1276
|
return pathToFileURL(realPath).toString();
|
|
1281
1277
|
}
|
|
1282
|
-
function resolveSync(id,
|
|
1283
|
-
return _resolve(id,
|
|
1278
|
+
function resolveSync(id, options) {
|
|
1279
|
+
return _resolve(id, options);
|
|
1284
1280
|
}
|
|
1285
|
-
function resolvePathSync(id,
|
|
1286
|
-
return fileURLToPath(resolveSync(id,
|
|
1281
|
+
function resolvePathSync(id, options) {
|
|
1282
|
+
return fileURLToPath(resolveSync(id, options));
|
|
1287
1283
|
}
|
|
1288
|
-
function resolvePath(id,
|
|
1289
|
-
return pcall(resolvePathSync, id,
|
|
1284
|
+
function resolvePath(id, options) {
|
|
1285
|
+
return pcall(resolvePathSync, id, options);
|
|
1290
1286
|
}
|
|
1291
1287
|
|
|
1292
|
-
const ESM_RE = /([\s;]|^)(import[\w
|
|
1288
|
+
const ESM_RE = /([\s;]|^)(import[\s\w*,{}]*from|import\s*["'*{]|export\b\s*(?:[*{]|default|class|type|function|const|var|let|async function)|import\.meta\b)/m;
|
|
1293
1289
|
const BUILTIN_EXTENSIONS = /* @__PURE__ */ new Set([".mjs", ".cjs", ".node", ".wasm"]);
|
|
1294
1290
|
function hasESMSyntax(code) {
|
|
1295
1291
|
return ESM_RE.test(code);
|
|
@@ -1301,19 +1297,19 @@ function hasCJSSyntax(code) {
|
|
|
1301
1297
|
const validNodeImportDefaults = {
|
|
1302
1298
|
allowedProtocols: ["node", "file", "data"]
|
|
1303
1299
|
};
|
|
1304
|
-
async function isValidNodeImport(id,
|
|
1300
|
+
async function isValidNodeImport(id, _options = {}) {
|
|
1305
1301
|
if (isNodeBuiltin(id)) {
|
|
1306
1302
|
return true;
|
|
1307
1303
|
}
|
|
1308
|
-
const
|
|
1304
|
+
const options = { ...validNodeImportDefaults, ..._options };
|
|
1309
1305
|
const proto = getProtocol(id);
|
|
1310
|
-
if (proto && !
|
|
1306
|
+
if (proto && !options.allowedProtocols.includes(proto)) {
|
|
1311
1307
|
return false;
|
|
1312
1308
|
}
|
|
1313
1309
|
if (proto === "data") {
|
|
1314
1310
|
return true;
|
|
1315
1311
|
}
|
|
1316
|
-
const resolvedPath = await resolvePath(id,
|
|
1312
|
+
const resolvedPath = await resolvePath(id, options);
|
|
1317
1313
|
const extension = extname(resolvedPath);
|
|
1318
1314
|
if (BUILTIN_EXTENSIONS.has(extension)) {
|
|
1319
1315
|
return true;
|
|
@@ -1321,14 +1317,16 @@ async function isValidNodeImport(id, _opts = {}) {
|
|
|
1321
1317
|
if (extension !== ".js") {
|
|
1322
1318
|
return false;
|
|
1323
1319
|
}
|
|
1324
|
-
const
|
|
1325
|
-
|
|
1320
|
+
const package_ = await readPackageJSON(resolvedPath).catch(() => {
|
|
1321
|
+
});
|
|
1322
|
+
if (package_?.type === "module") {
|
|
1326
1323
|
return true;
|
|
1327
1324
|
}
|
|
1328
|
-
if (
|
|
1325
|
+
if (/\.(\w+-)?esm?(-\w+)?\.js$|\/(esm?)\//.test(resolvedPath)) {
|
|
1329
1326
|
return false;
|
|
1330
1327
|
}
|
|
1331
|
-
const code =
|
|
1328
|
+
const code = options.code || await promises.readFile(resolvedPath, "utf8").catch(() => {
|
|
1329
|
+
}) || "";
|
|
1332
1330
|
return hasCJSSyntax(code) || !hasESMSyntax(code);
|
|
1333
1331
|
}
|
|
1334
1332
|
|
|
@@ -1376,19 +1374,6 @@ function toFilePath(id, root) {
|
|
|
1376
1374
|
absolute = absolute.slice(1);
|
|
1377
1375
|
return isWindows && absolute.startsWith("/") ? slash(fileURLToPath$1(pathToFileURL(absolute.slice(1)).href)) : absolute;
|
|
1378
1376
|
}
|
|
1379
|
-
let SOURCEMAPPING_URL = "sourceMa";
|
|
1380
|
-
SOURCEMAPPING_URL += "ppingURL";
|
|
1381
|
-
async function withInlineSourcemap(result) {
|
|
1382
|
-
const { code, map } = result;
|
|
1383
|
-
if (code.includes(`${SOURCEMAPPING_URL}=`))
|
|
1384
|
-
return result;
|
|
1385
|
-
if (map)
|
|
1386
|
-
result.code = `${code}
|
|
1387
|
-
|
|
1388
|
-
//# ${SOURCEMAPPING_URL}=data:application/json;charset=utf-8;base64,${Buffer.from(JSON.stringify(map), "utf-8").toString("base64")}
|
|
1389
|
-
`;
|
|
1390
|
-
return result;
|
|
1391
|
-
}
|
|
1392
1377
|
function toArray(array) {
|
|
1393
1378
|
if (array === null || array === void 0)
|
|
1394
1379
|
array = [];
|
|
@@ -1397,4 +1382,4 @@ function toArray(array) {
|
|
|
1397
1382
|
return [array];
|
|
1398
1383
|
}
|
|
1399
1384
|
|
|
1400
|
-
export { isValidNodeImport as a, toFilePath as b, isPrimitive as c, normalizeModuleId as d, hasCJSSyntax as h, isNodeBuiltin as i, mergeSlashes as m, normalizeRequestId as n, pathFromRoot as p, slash as s, toArray as t
|
|
1385
|
+
export { isValidNodeImport as a, toFilePath as b, isPrimitive as c, normalizeModuleId as d, hasCJSSyntax as h, isNodeBuiltin as i, mergeSlashes as m, normalizeRequestId as n, pathFromRoot as p, slash as s, toArray as t };
|
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { p as picocolors, n as normalize } from './chunk-utils-env.03f840f2.js';
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
|
-
import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.
|
|
3
|
+
import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.ddcbafa3.js';
|
|
4
4
|
import 'tty';
|
|
5
5
|
import 'url';
|
|
6
6
|
import 'path';
|
|
@@ -8,7 +8,7 @@ import './chunk-integrations-coverage.befed097.js';
|
|
|
8
8
|
import 'local-pkg';
|
|
9
9
|
import './chunk-env-node.67948209.js';
|
|
10
10
|
import 'console';
|
|
11
|
-
import './chunk-typecheck-constants.
|
|
11
|
+
import './chunk-typecheck-constants.ed987901.js';
|
|
12
12
|
import 'vite';
|
|
13
13
|
import 'process';
|
|
14
14
|
import 'fs';
|
|
@@ -16,25 +16,26 @@ import 'os';
|
|
|
16
16
|
import 'util';
|
|
17
17
|
import 'stream';
|
|
18
18
|
import './vendor-_commonjsHelpers.addc3445.js';
|
|
19
|
-
import './chunk-vite-node-
|
|
19
|
+
import './chunk-vite-node-source-map.61c5ea66.js';
|
|
20
20
|
import 'module';
|
|
21
21
|
import 'vm';
|
|
22
|
-
import './chunk-vite-node-utils.
|
|
22
|
+
import './chunk-vite-node-utils.abe05c5c.js';
|
|
23
23
|
import 'acorn';
|
|
24
24
|
import 'assert';
|
|
25
25
|
import 'debug';
|
|
26
|
+
import './vendor-source-map-support.1ce17397.js';
|
|
27
|
+
import 'source-map';
|
|
26
28
|
import 'perf_hooks';
|
|
27
29
|
import 'fs/promises';
|
|
28
30
|
import './vendor-index.737c3cff.js';
|
|
29
31
|
import 'buffer';
|
|
30
32
|
import 'child_process';
|
|
31
33
|
import './vendor-index.e1d4cf84.js';
|
|
32
|
-
import 'source-map';
|
|
33
34
|
import 'acorn-walk';
|
|
34
35
|
import 'worker_threads';
|
|
35
36
|
import 'tinypool';
|
|
36
|
-
import './chunk-utils-timers.
|
|
37
|
-
import './chunk-utils-source-map.
|
|
37
|
+
import './chunk-utils-timers.b81cda77.js';
|
|
38
|
+
import './chunk-utils-source-map.29ff1088.js';
|
|
38
39
|
import 'crypto';
|
|
39
40
|
import './vendor-index.9c919048.js';
|
|
40
41
|
import './chunk-magic-string.ffe2b171.js';
|
|
@@ -687,9 +688,12 @@ async function typecheck(cliFilters = [], options = {}) {
|
|
|
687
688
|
await start("typecheck", cliFilters, options);
|
|
688
689
|
}
|
|
689
690
|
function normalizeOptions(argv) {
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
691
|
+
if (argv.root)
|
|
692
|
+
argv.root = normalize(argv.root);
|
|
693
|
+
if (argv.config)
|
|
694
|
+
argv.config = normalize(argv.config);
|
|
695
|
+
if (argv.dir)
|
|
696
|
+
argv.dir = normalize(argv.dir);
|
|
693
697
|
return argv;
|
|
694
698
|
}
|
|
695
699
|
async function start(mode, cliFilters, options) {
|
package/dist/config.cjs
CHANGED
package/dist/config.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UserConfig as UserConfig$2, ConfigEnv } from 'vite';
|
|
2
2
|
export { ConfigEnv } from 'vite';
|
|
3
|
-
import { U as UserConfig$1, ao as ResolvedCoverageOptions, F as FakeTimerInstallOpts } from './types-
|
|
3
|
+
import { U as UserConfig$1, ao as ResolvedCoverageOptions, F as FakeTimerInstallOpts } from './types-1cf24598.js';
|
|
4
4
|
import 'tinybench';
|
|
5
5
|
import 'fs';
|
|
6
6
|
import 'worker_threads';
|
|
@@ -43,6 +43,7 @@ declare const config: {
|
|
|
43
43
|
include: string[];
|
|
44
44
|
exclude: string[];
|
|
45
45
|
};
|
|
46
|
+
slowTestThreshold: number;
|
|
46
47
|
};
|
|
47
48
|
declare const configDefaults: Required<Pick<UserConfig$1, keyof typeof config>>;
|
|
48
49
|
|
package/dist/config.js
CHANGED
package/dist/entry.js
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
import { promises } from 'fs';
|
|
2
|
-
import { g as getWorkerState, a as resetModules } from './chunk-typecheck-constants.
|
|
3
|
-
import { v as vi } from './chunk-runtime-test-state.
|
|
2
|
+
import { g as getWorkerState, a as resetModules } from './chunk-typecheck-constants.ed987901.js';
|
|
3
|
+
import { v as vi } from './chunk-runtime-test-state.7c288e2d.js';
|
|
4
4
|
import { a as envs } from './chunk-env-node.67948209.js';
|
|
5
|
-
import { a as setupGlobalEnv, s as startTests, w as withEnv } from './chunk-runtime-setup.
|
|
5
|
+
import { a as setupGlobalEnv, s as startTests, w as withEnv } from './chunk-runtime-setup.80b27439.js';
|
|
6
6
|
import 'path';
|
|
7
7
|
import './chunk-utils-env.03f840f2.js';
|
|
8
8
|
import 'tty';
|
|
9
9
|
import 'url';
|
|
10
10
|
import 'local-pkg';
|
|
11
|
-
import './chunk-runtime-chain.
|
|
11
|
+
import './chunk-runtime-chain.315721df.js';
|
|
12
12
|
import 'util';
|
|
13
13
|
import 'chai';
|
|
14
14
|
import './vendor-_commonjsHelpers.addc3445.js';
|
|
15
|
-
import './chunk-runtime-rpc.
|
|
16
|
-
import './chunk-utils-timers.
|
|
17
|
-
import './chunk-utils-source-map.
|
|
15
|
+
import './chunk-runtime-rpc.b368762d.js';
|
|
16
|
+
import './chunk-utils-timers.b81cda77.js';
|
|
17
|
+
import './chunk-utils-source-map.29ff1088.js';
|
|
18
18
|
import './spy.js';
|
|
19
19
|
import 'tinyspy';
|
|
20
20
|
import 'console';
|
|
21
21
|
import 'perf_hooks';
|
|
22
22
|
import './chunk-integrations-coverage.befed097.js';
|
|
23
|
-
import './chunk-runtime-error.
|
|
23
|
+
import './chunk-runtime-error.95c286d7.js';
|
|
24
|
+
import './vendor-source-map-support.1ce17397.js';
|
|
24
25
|
import 'source-map';
|
|
25
26
|
|
|
26
27
|
function groupBy(collection, iteratee) {
|
package/dist/environments.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SpyImpl } from 'tinyspy';
|
|
2
|
-
import { w as SuiteAPI, v as TestAPI, aw as BenchmarkAPI, y as SuiteHooks, H as HookListener, L as TestContext, p as Suite, x as HookCleanupCallback, O as OnTestFailedHandler, q as Test } from './types-
|
|
2
|
+
import { w as SuiteAPI, v as TestAPI, aw as BenchmarkAPI, y as SuiteHooks, H as HookListener, L as TestContext, p as Suite, x as HookCleanupCallback, O as OnTestFailedHandler, q as Test } from './types-1cf24598.js';
|
|
3
3
|
|
|
4
4
|
declare type Not<T extends boolean> = T extends true ? false : true;
|
|
5
5
|
declare type And<Types extends boolean[]> = Types[number] extends true ? true : false;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { s as spyOn, f as fn, M as MaybeMockedDeep, a as MaybeMocked, b as MaybePartiallyMocked, c as MaybePartiallyMockedDeep, E as EnhancedSpy } from './index-
|
|
2
|
-
export { A as AssertType, E as EnhancedSpy, q as ExpectTypeOf, x as Mock, y as MockContext, w as MockInstance, z as Mocked, B as MockedClass, u as MockedFunction, v as MockedObject, S as SpyInstance, j as afterAll, l as afterEach, r as assertType, h as beforeAll, k as beforeEach, g as bench, n as createExpect, e as describe, m as expect, p as expectTypeOf, i as it, o as onTestFailed, d as suite, t as test } from './index-
|
|
3
|
-
import { D as DoneCallback, F as FakeTimerInstallOpts, R as RuntimeConfig, a as File, T as TaskResultPack, b as ResolvedConfig, M as ModuleGraphData, c as Reporter } from './types-
|
|
4
|
-
export { a1 as AfterSuiteRunMeta, A as ApiConfig, a7 as ArgumentsType, a6 as Arrayable, a4 as Awaitable, ap as BaseCoverageOptions, av as BenchFunction, at as Benchmark, aw as BenchmarkAPI, au as BenchmarkResult, as as BenchmarkUserOptions, B as BuiltinEnvironment, i as CSSModuleScopeStrategy, C as CollectLineNumbers, f as CollectLines, ab as Constructable, h as Context, ar as CoverageC8Options, aq as CoverageIstanbulOptions, an as CoverageOptions, ak as CoverageProvider, al as CoverageProviderModule, am as CoverageReporter, a9 as DeepMerge, D as DoneCallback, ae as Environment, E as EnvironmentOptions, ad as EnvironmentReturn, ai as ErrorWithDiff, a as File, x as HookCleanupCallback, H as HookListener, I as InlineConfig, J as JSDOMOptions, a8 as MergeInsertions, ac as ModuleCache, M as ModuleGraphData, aa as MutableArray, a5 as Nullable, aj as OnServerRestartHandler, O as OnTestFailedHandler, ah as ParsedStack, ag as Position, d as RawErrsMap, c as Reporter, a0 as ResolveIdFunction, b as ResolvedConfig, ao as ResolvedCoverageOptions, g as RootAndTarget, l as RunMode, R as RuntimeConfig, K as RuntimeContext, S as SequenceHooks, P as SnapshotData, X as SnapshotMatchOptions, Y as SnapshotResult, W as SnapshotStateOptions, _ as SnapshotSummary, Q as SnapshotUpdateState, p as Suite, w as SuiteAPI, z as SuiteCollector, G as SuiteFactory, y as SuiteHooks, s as Task, n as TaskBase, o as TaskResult, T as TaskResultPack, m as TaskState, q as Test, v as TestAPI, L as TestContext, t as TestFunction, u as TestOptions, e as TscErrorInfo, r as TypeCheck, k as TypecheckConfig, Z as UncheckedSnapshot, U as UserConfig, af as UserConsoleLog, N as Vitest, V as VitestEnvironment, j as VitestRunMode, $ as WorkerContext, a3 as WorkerGlobalState, a2 as WorkerRPC } from './types-
|
|
1
|
+
import { s as spyOn, f as fn, M as MaybeMockedDeep, a as MaybeMocked, b as MaybePartiallyMocked, c as MaybePartiallyMockedDeep, E as EnhancedSpy } from './index-81973d31.js';
|
|
2
|
+
export { A as AssertType, E as EnhancedSpy, q as ExpectTypeOf, x as Mock, y as MockContext, w as MockInstance, z as Mocked, B as MockedClass, u as MockedFunction, v as MockedObject, S as SpyInstance, j as afterAll, l as afterEach, r as assertType, h as beforeAll, k as beforeEach, g as bench, n as createExpect, e as describe, m as expect, p as expectTypeOf, i as it, o as onTestFailed, d as suite, t as test } from './index-81973d31.js';
|
|
3
|
+
import { D as DoneCallback, F as FakeTimerInstallOpts, R as RuntimeConfig, a as File, T as TaskResultPack, b as ResolvedConfig, M as ModuleGraphData, c as Reporter } from './types-1cf24598.js';
|
|
4
|
+
export { a1 as AfterSuiteRunMeta, A as ApiConfig, a7 as ArgumentsType, a6 as Arrayable, a4 as Awaitable, ap as BaseCoverageOptions, av as BenchFunction, at as Benchmark, aw as BenchmarkAPI, au as BenchmarkResult, as as BenchmarkUserOptions, B as BuiltinEnvironment, i as CSSModuleScopeStrategy, C as CollectLineNumbers, f as CollectLines, ab as Constructable, h as Context, ar as CoverageC8Options, aq as CoverageIstanbulOptions, an as CoverageOptions, ak as CoverageProvider, al as CoverageProviderModule, am as CoverageReporter, a9 as DeepMerge, D as DoneCallback, ae as Environment, E as EnvironmentOptions, ad as EnvironmentReturn, ai as ErrorWithDiff, a as File, x as HookCleanupCallback, H as HookListener, I as InlineConfig, J as JSDOMOptions, a8 as MergeInsertions, ac as ModuleCache, M as ModuleGraphData, aa as MutableArray, a5 as Nullable, aj as OnServerRestartHandler, O as OnTestFailedHandler, ah as ParsedStack, ag as Position, d as RawErrsMap, c as Reporter, a0 as ResolveIdFunction, b as ResolvedConfig, ao as ResolvedCoverageOptions, g as RootAndTarget, l as RunMode, R as RuntimeConfig, K as RuntimeContext, S as SequenceHooks, P as SnapshotData, X as SnapshotMatchOptions, Y as SnapshotResult, W as SnapshotStateOptions, _ as SnapshotSummary, Q as SnapshotUpdateState, p as Suite, w as SuiteAPI, z as SuiteCollector, G as SuiteFactory, y as SuiteHooks, s as Task, n as TaskBase, o as TaskResult, T as TaskResultPack, m as TaskState, q as Test, v as TestAPI, L as TestContext, t as TestFunction, u as TestOptions, e as TscErrorInfo, r as TypeCheck, k as TypecheckConfig, Z as UncheckedSnapshot, U as UserConfig, af as UserConsoleLog, N as Vitest, V as VitestEnvironment, j as VitestRunMode, $ as WorkerContext, a3 as WorkerGlobalState, a2 as WorkerRPC } from './types-1cf24598.js';
|
|
5
5
|
import { TransformResult } from 'vite';
|
|
6
6
|
import * as chai from 'chai';
|
|
7
7
|
export { chai };
|
|
@@ -146,7 +146,7 @@ declare class VitestUtils {
|
|
|
146
146
|
/**
|
|
147
147
|
* Wait for all imports to load.
|
|
148
148
|
* Useful, if you have a synchronous call that starts
|
|
149
|
-
* importing a module
|
|
149
|
+
* importing a module that you cannot wait otherwise.
|
|
150
150
|
*/
|
|
151
151
|
dynamicImportSettled(): Promise<void>;
|
|
152
152
|
private _config;
|