vitest 0.20.3 → 0.21.0
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/dist/browser.d.ts +9 -1902
- package/dist/browser.mjs +7 -7
- package/dist/{chunk-api-setup.9bff74bb.mjs → chunk-api-setup.89eb0e7a.mjs} +5 -5
- package/dist/{chunk-constants.16825f0c.mjs → chunk-constants.9da1ef26.mjs} +1 -1
- package/dist/{chunk-defaults.6698a2d3.mjs → chunk-defaults.8390340d.mjs} +1 -1
- package/dist/{chunk-integrations-globals.c5b78414.mjs → chunk-integrations-globals.a798d352.mjs} +6 -6
- package/dist/{chunk-mock-date.9160e13b.mjs → chunk-mock-date.ea3b3121.mjs} +10 -7
- package/dist/{chunk-node-git.43dbdd42.mjs → chunk-node-git.e0dc0a7e.mjs} +1 -1
- package/dist/{chunk-runtime-chain.b6c2cdbc.mjs → chunk-runtime-chain.44b4224d.mjs} +30 -21
- package/dist/{chunk-runtime-error.034e03ba.mjs → chunk-runtime-error.95e53764.mjs} +12 -11
- package/dist/{chunk-runtime-hooks.a8401528.mjs → chunk-runtime-hooks.291644ec.mjs} +3 -3
- package/dist/{chunk-runtime-mocker.653847b2.mjs → chunk-runtime-mocker.6190d6a3.mjs} +19 -11
- package/dist/{chunk-runtime-rpc.dbf0b31d.mjs → chunk-runtime-rpc.fc50dcc0.mjs} +1 -1
- package/dist/{chunk-utils-source-map.8198ebd9.mjs → chunk-utils-source-map.d307e4ea.mjs} +1 -1
- package/dist/{chunk-vite-node-client.115caed2.mjs → chunk-vite-node-client.b59ba135.mjs} +2 -2
- package/dist/{chunk-vite-node-debug.c5887932.mjs → chunk-vite-node-debug.dbce2e1f.mjs} +1 -1
- package/dist/{chunk-vite-node-externalize.91ae6e85.mjs → chunk-vite-node-externalize.80bed9b3.mjs} +23 -13
- package/dist/{chunk-vite-node-utils.7e46948f.mjs → chunk-vite-node-utils.96438e82.mjs} +2 -2
- package/dist/cli.mjs +7 -7
- package/dist/config.d.ts +2 -67
- package/dist/entry.mjs +7 -7
- package/dist/global-644546f7.d.ts +1777 -0
- package/dist/index-3f764034.d.ts +164 -0
- package/dist/index.d.ts +10 -1928
- package/dist/index.mjs +5 -5
- package/dist/loader.mjs +72 -16
- package/dist/mocker-5e2a8e41.d.ts +3 -0
- package/dist/node.d.ts +7 -1682
- package/dist/node.mjs +8 -8
- package/dist/suite.mjs +4 -4
- package/dist/worker.mjs +6 -6
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
export { c as createExpect, d as describe, b as expect, i as it, s as suite, t as test } from './chunk-runtime-chain.
|
|
2
|
-
export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, h as getRunningMode, f as isFirstRun, j as isWatchMode, e as runOnce, v as vi, g as vitest, w as withCallback } from './chunk-runtime-hooks.
|
|
1
|
+
export { c as createExpect, d as describe, b as expect, i as it, s as suite, t as test } from './chunk-runtime-chain.44b4224d.mjs';
|
|
2
|
+
export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, h as getRunningMode, f as isFirstRun, j as isWatchMode, e as runOnce, v as vi, g as vitest, w as withCallback } from './chunk-runtime-hooks.291644ec.mjs';
|
|
3
3
|
import * as chai from 'chai';
|
|
4
4
|
export { chai };
|
|
5
5
|
export { assert, should } from 'chai';
|
|
6
6
|
import 'util';
|
|
7
|
-
import './chunk-mock-date.
|
|
7
|
+
import './chunk-mock-date.ea3b3121.mjs';
|
|
8
8
|
import 'path';
|
|
9
9
|
import 'tty';
|
|
10
10
|
import 'local-pkg';
|
|
11
11
|
import './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
12
|
-
import './chunk-runtime-rpc.
|
|
12
|
+
import './chunk-runtime-rpc.fc50dcc0.mjs';
|
|
13
13
|
import './chunk-utils-global.fa20c2f6.mjs';
|
|
14
14
|
import './chunk-utils-timers.b48455ed.mjs';
|
|
15
15
|
import 'fs';
|
|
16
|
-
import './chunk-utils-source-map.
|
|
16
|
+
import './chunk-utils-source-map.d307e4ea.mjs';
|
|
17
17
|
import './spy.mjs';
|
|
18
18
|
import 'tinyspy';
|
package/dist/loader.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { pathToFileURL } from 'url';
|
|
2
|
-
import {
|
|
3
|
-
import './chunk-
|
|
2
|
+
import { readFile } from 'fs/promises';
|
|
3
|
+
import { i as isNodeBuiltin, d as normalizeModuleId, h as hasCJSSyntax } from './chunk-vite-node-utils.96438e82.mjs';
|
|
4
|
+
import './chunk-mock-date.ea3b3121.mjs';
|
|
4
5
|
import { g as getWorkerState } from './chunk-utils-global.fa20c2f6.mjs';
|
|
5
6
|
import 'module';
|
|
6
7
|
import 'path';
|
|
@@ -10,27 +11,82 @@ import 'util';
|
|
|
10
11
|
import 'tty';
|
|
11
12
|
import 'local-pkg';
|
|
12
13
|
|
|
14
|
+
var ModuleFormat = /* @__PURE__ */ ((ModuleFormat2) => {
|
|
15
|
+
ModuleFormat2["Builtin"] = "builtin";
|
|
16
|
+
ModuleFormat2["Commonjs"] = "commonjs";
|
|
17
|
+
ModuleFormat2["Json"] = "json";
|
|
18
|
+
ModuleFormat2["Module"] = "module";
|
|
19
|
+
ModuleFormat2["Wasm"] = "wasm";
|
|
20
|
+
return ModuleFormat2;
|
|
21
|
+
})(ModuleFormat || {});
|
|
22
|
+
|
|
23
|
+
const ESM_RE = /([\s;}]|^)(import[\w,{}\s*]*from|import\s*['"*{]|export\b\s*(?:[*{]|default|class|type|function|const|var|let|async function)|import\.meta\b)/m;
|
|
24
|
+
function hasESMSyntax(code) {
|
|
25
|
+
return ESM_RE.test(code);
|
|
26
|
+
}
|
|
27
|
+
const cache = /* @__PURE__ */ new Map();
|
|
28
|
+
const getPotentialSource = async (filepath, result) => {
|
|
29
|
+
var _a;
|
|
30
|
+
if (!result.url.startsWith("file://") || result.format === "module")
|
|
31
|
+
return null;
|
|
32
|
+
let source = (_a = cache.get(result.url)) == null ? void 0 : _a.source;
|
|
33
|
+
if (source == null)
|
|
34
|
+
source = await readFile(filepath, "utf8");
|
|
35
|
+
return source;
|
|
36
|
+
};
|
|
37
|
+
const detectESM = (url, source) => {
|
|
38
|
+
const cached = cache.get(url);
|
|
39
|
+
if (cached)
|
|
40
|
+
return cached.isPseudoESM;
|
|
41
|
+
if (!source)
|
|
42
|
+
return false;
|
|
43
|
+
return hasESMSyntax(source) && !hasCJSSyntax(source);
|
|
44
|
+
};
|
|
13
45
|
const resolve = async (url, context, next) => {
|
|
14
46
|
const { parentURL } = context;
|
|
15
|
-
|
|
47
|
+
const state = getWorkerState();
|
|
48
|
+
const resolver = state == null ? void 0 : state.rpc.resolveId;
|
|
49
|
+
if (!parentURL || isNodeBuiltin(url) || !resolver)
|
|
16
50
|
return next(url, context, next);
|
|
17
51
|
const id = normalizeModuleId(url);
|
|
18
52
|
const importer = normalizeModuleId(parentURL);
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
53
|
+
const resolved = await resolver(id, importer);
|
|
54
|
+
let result;
|
|
55
|
+
let filepath;
|
|
56
|
+
if (resolved) {
|
|
57
|
+
const resolvedUrl = pathToFileURL(resolved.id).toString();
|
|
58
|
+
filepath = resolved.id;
|
|
59
|
+
result = {
|
|
60
|
+
url: resolvedUrl,
|
|
61
|
+
shortCircuit: true
|
|
62
|
+
};
|
|
63
|
+
} else {
|
|
64
|
+
const { url: resolvedUrl, format } = await next(url, context, next);
|
|
65
|
+
filepath = new URL(resolvedUrl).pathname;
|
|
66
|
+
result = {
|
|
67
|
+
url: resolvedUrl,
|
|
68
|
+
format,
|
|
69
|
+
shortCircuit: true
|
|
70
|
+
};
|
|
29
71
|
}
|
|
30
|
-
|
|
72
|
+
const source = await getPotentialSource(filepath, result);
|
|
73
|
+
const isPseudoESM = detectESM(result.url, source);
|
|
74
|
+
if (typeof source === "string")
|
|
75
|
+
cache.set(result.url, { isPseudoESM, source });
|
|
76
|
+
if (isPseudoESM)
|
|
77
|
+
result.format = ModuleFormat.Module;
|
|
78
|
+
return result;
|
|
31
79
|
};
|
|
32
|
-
const load = (url, context, next) => {
|
|
33
|
-
|
|
80
|
+
const load = async (url, context, next) => {
|
|
81
|
+
const result = await next(url, context, next);
|
|
82
|
+
const cached = cache.get(url);
|
|
83
|
+
if ((cached == null ? void 0 : cached.isPseudoESM) && result.format !== "module") {
|
|
84
|
+
return {
|
|
85
|
+
source: cached.source,
|
|
86
|
+
format: ModuleFormat.Module
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
return result;
|
|
34
90
|
};
|
|
35
91
|
|
|
36
92
|
export { load, resolve };
|