vitest 0.22.0 → 0.23.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.md +29 -29
- package/dist/browser.d.ts +5 -4
- package/dist/browser.mjs +12 -9
- package/dist/{chunk-api-setup.ecd02c18.mjs → chunk-api-setup.9e83ca0a.mjs} +92 -90
- package/dist/chunk-constants.6196597b.mjs +284 -0
- package/dist/{chunk-integrations-coverage.d205bd87.mjs → chunk-env-node.ceb43f1c.mjs} +31 -179
- package/dist/{chunk-install-pkg.3aa3eae6.mjs → chunk-install-pkg.e081fc1b.mjs} +3 -3
- package/dist/chunk-integrations-coverage.99c020eb.mjs +166 -0
- package/dist/chunk-integrations-globals.b1aa52c3.mjs +25 -0
- package/dist/{chunk-magic-string.efe26975.mjs → chunk-magic-string.56b2b543.mjs} +30 -10
- package/dist/{chunk-mock-date.debe9954.mjs → chunk-mock-date.f63a5ff2.mjs} +31 -193
- package/dist/{chunk-node-git.71b74da4.mjs → chunk-node-git.6f289b0a.mjs} +20 -16
- package/dist/{chunk-runtime-chain.6e363ba2.mjs → chunk-runtime-chain.8bfc559b.mjs} +507 -173
- package/dist/{chunk-runtime-error.975bd80a.mjs → chunk-runtime-error.252dd130.mjs} +206 -75
- package/dist/{chunk-runtime-hooks.4789e99d.mjs → chunk-runtime-hooks.c6b06bd8.mjs} +18 -12
- package/dist/{chunk-runtime-mocker.c91d29ce.mjs → chunk-runtime-mocker.d9690273.mjs} +19 -12
- package/dist/{chunk-runtime-rpc.29488183.mjs → chunk-runtime-rpc.48bd94e3.mjs} +1 -2
- package/dist/{chunk-utils-source-map.2a082ffd.mjs → chunk-utils-source-map.a1647f5f.mjs} +11 -5
- package/dist/{chunk-vite-node-client.d1ead698.mjs → chunk-vite-node-client.998e04d0.mjs} +92 -31
- package/dist/{chunk-vite-node-debug.ff1d2a9f.mjs → chunk-vite-node-debug.2d8a1dc3.mjs} +3 -4
- package/dist/{chunk-vite-node-externalize.3a38c8af.mjs → chunk-vite-node-externalize.3035bd5b.mjs} +515 -211
- package/dist/{chunk-vite-node-utils.d8e5ff7b.mjs → chunk-vite-node-utils.8a9b3014.mjs} +39 -41
- package/dist/cli-wrapper.mjs +54 -33
- package/dist/cli.mjs +31 -20
- package/dist/config.cjs +2 -2
- package/dist/config.d.ts +4 -3
- package/dist/config.mjs +2 -2
- package/dist/entry.mjs +20 -14
- package/dist/environments.d.ts +23 -0
- package/dist/environments.mjs +3 -0
- package/dist/{global-74489cc9.d.ts → global-ea084c9f.d.ts} +154 -24
- package/dist/{index-9eded9ec.d.ts → index-5f09f4d0.d.ts} +3 -2
- package/dist/index.d.ts +6 -5
- package/dist/index.mjs +7 -7
- package/dist/loader.mjs +5 -6
- package/dist/node.d.ts +5 -4
- package/dist/node.mjs +17 -16
- package/dist/suite.mjs +6 -6
- package/dist/vendor-index.0557b03a.mjs +147 -0
- package/dist/{vendor-index.9d9196cc.mjs → vendor-index.13e3bda3.mjs} +0 -0
- package/dist/{vendor-index.fbec8a81.mjs → vendor-index.4aeeb598.mjs} +2 -2
- package/dist/{vendor-index.2ae8040a.mjs → vendor-index.62ce5c33.mjs} +0 -0
- package/dist/{vendor-index.29636037.mjs → vendor-index.731a22f2.mjs} +0 -0
- package/dist/worker.mjs +20 -19
- package/package.json +18 -11
- package/dist/chunk-constants.d3f8437b.mjs +0 -38
- package/dist/chunk-integrations-globals.e81d2091.mjs +0 -27
- package/dist/chunk-utils-global.fa20c2f6.mjs +0 -5
- package/dist/vendor-picocolors.807856aa.mjs +0 -64
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createRequire } from 'module';
|
|
2
2
|
import { pathToFileURL, fileURLToPath } from 'url';
|
|
3
3
|
import vm from 'vm';
|
|
4
|
-
import {
|
|
5
|
-
import { s as slash, n as normalizeRequestId, b as toFilePath, i as isNodeBuiltin, c as isPrimitive, d as normalizeModuleId, m as mergeSlashes } from './chunk-vite-node-utils.
|
|
4
|
+
import { a as resolve, d as dirname, i as isAbsolute, h as extname } from './chunk-constants.6196597b.mjs';
|
|
5
|
+
import { s as slash, n as normalizeRequestId, b as toFilePath, i as isNodeBuiltin, c as isPrimitive, d as normalizeModuleId, m as mergeSlashes } from './chunk-vite-node-utils.8a9b3014.mjs';
|
|
6
6
|
import createDebug from 'debug';
|
|
7
7
|
|
|
8
8
|
const debugExecute = createDebug("vite-node:client:execute");
|
|
@@ -45,7 +45,7 @@ class ModuleCacheMap extends Map {
|
|
|
45
45
|
normalizePath(fsPath) {
|
|
46
46
|
return normalizeModuleId(fsPath);
|
|
47
47
|
}
|
|
48
|
-
|
|
48
|
+
update(fsPath, mod) {
|
|
49
49
|
fsPath = this.normalizePath(fsPath);
|
|
50
50
|
if (!super.has(fsPath))
|
|
51
51
|
super.set(fsPath, mod);
|
|
@@ -53,14 +53,48 @@ class ModuleCacheMap extends Map {
|
|
|
53
53
|
Object.assign(super.get(fsPath), mod);
|
|
54
54
|
return this;
|
|
55
55
|
}
|
|
56
|
+
set(fsPath, mod) {
|
|
57
|
+
fsPath = this.normalizePath(fsPath);
|
|
58
|
+
return super.set(fsPath, mod);
|
|
59
|
+
}
|
|
56
60
|
get(fsPath) {
|
|
57
61
|
fsPath = this.normalizePath(fsPath);
|
|
62
|
+
if (!super.has(fsPath))
|
|
63
|
+
super.set(fsPath, {});
|
|
58
64
|
return super.get(fsPath);
|
|
59
65
|
}
|
|
60
66
|
delete(fsPath) {
|
|
61
67
|
fsPath = this.normalizePath(fsPath);
|
|
62
68
|
return super.delete(fsPath);
|
|
63
69
|
}
|
|
70
|
+
invalidateDepTree(ids, invalidated = /* @__PURE__ */ new Set()) {
|
|
71
|
+
for (const _id of ids) {
|
|
72
|
+
const id = this.normalizePath(_id);
|
|
73
|
+
if (invalidated.has(id))
|
|
74
|
+
continue;
|
|
75
|
+
invalidated.add(id);
|
|
76
|
+
const mod = super.get(id);
|
|
77
|
+
if (mod == null ? void 0 : mod.importers)
|
|
78
|
+
this.invalidateDepTree(mod.importers, invalidated);
|
|
79
|
+
super.delete(id);
|
|
80
|
+
}
|
|
81
|
+
return invalidated;
|
|
82
|
+
}
|
|
83
|
+
invalidateSubDepTree(ids, invalidated = /* @__PURE__ */ new Set()) {
|
|
84
|
+
for (const _id of ids) {
|
|
85
|
+
const id = this.normalizePath(_id);
|
|
86
|
+
if (invalidated.has(id))
|
|
87
|
+
continue;
|
|
88
|
+
invalidated.add(id);
|
|
89
|
+
const subIds = Array.from(super.entries()).filter(([, mod]) => {
|
|
90
|
+
var _a;
|
|
91
|
+
return (_a = mod.importers) == null ? void 0 : _a.has(id);
|
|
92
|
+
}).map(([key]) => key);
|
|
93
|
+
subIds.length && this.invalidateSubDepTree(subIds, invalidated);
|
|
94
|
+
super.delete(id);
|
|
95
|
+
}
|
|
96
|
+
return invalidated;
|
|
97
|
+
}
|
|
64
98
|
}
|
|
65
99
|
class ViteNodeRunner {
|
|
66
100
|
constructor(options) {
|
|
@@ -76,39 +110,44 @@ class ViteNodeRunner {
|
|
|
76
110
|
return await this.cachedRequest(id, []);
|
|
77
111
|
}
|
|
78
112
|
async cachedRequest(rawId, callstack) {
|
|
79
|
-
var _a, _b, _c, _d;
|
|
80
113
|
const id = normalizeRequestId(rawId, this.options.base);
|
|
81
114
|
const fsPath = toFilePath(id, this.root);
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (
|
|
85
|
-
|
|
115
|
+
const mod = this.moduleCache.get(fsPath);
|
|
116
|
+
const importee = callstack[callstack.length - 1];
|
|
117
|
+
if (!mod.importers)
|
|
118
|
+
mod.importers = /* @__PURE__ */ new Set();
|
|
119
|
+
if (importee)
|
|
120
|
+
mod.importers.add(importee);
|
|
121
|
+
if (callstack.includes(fsPath) && mod.exports)
|
|
122
|
+
return mod.exports;
|
|
123
|
+
if (mod.promise)
|
|
124
|
+
return mod.promise;
|
|
86
125
|
const promise = this.directRequest(id, fsPath, callstack);
|
|
87
|
-
|
|
126
|
+
Object.assign(mod, { promise });
|
|
88
127
|
return await promise;
|
|
89
128
|
}
|
|
90
129
|
async directRequest(id, fsPath, _callstack) {
|
|
91
130
|
const callstack = [..._callstack, fsPath];
|
|
131
|
+
const mod = this.moduleCache.get(fsPath);
|
|
92
132
|
const request = async (dep) => {
|
|
93
133
|
var _a;
|
|
94
|
-
const
|
|
134
|
+
const depFsPath = toFilePath(normalizeRequestId(dep, this.options.base), this.root);
|
|
95
135
|
const getStack = () => {
|
|
96
136
|
return `stack:
|
|
97
|
-
${[...callstack,
|
|
137
|
+
${[...callstack, depFsPath].reverse().map((p) => `- ${p}`).join("\n")}`;
|
|
98
138
|
};
|
|
99
139
|
let debugTimer;
|
|
100
140
|
if (this.debug)
|
|
101
|
-
debugTimer = setTimeout(() => console.warn(() => `module ${
|
|
141
|
+
debugTimer = setTimeout(() => console.warn(() => `module ${depFsPath} takes over 2s to load.
|
|
102
142
|
${getStack()}`), 2e3);
|
|
103
143
|
try {
|
|
104
|
-
if (callstack.includes(
|
|
105
|
-
const depExports = (_a = this.moduleCache.get(
|
|
144
|
+
if (callstack.includes(depFsPath)) {
|
|
145
|
+
const depExports = (_a = this.moduleCache.get(depFsPath)) == null ? void 0 : _a.exports;
|
|
106
146
|
if (depExports)
|
|
107
147
|
return depExports;
|
|
108
148
|
throw new Error(`[vite-node] Failed to resolve circular dependency, ${getStack()}`);
|
|
109
149
|
}
|
|
110
|
-
|
|
111
|
-
return mod;
|
|
150
|
+
return await this.cachedRequest(dep, callstack);
|
|
112
151
|
} finally {
|
|
113
152
|
if (debugTimer)
|
|
114
153
|
clearTimeout(debugTimer);
|
|
@@ -132,9 +171,9 @@ ${getStack()}`), 2e3);
|
|
|
132
171
|
let { code: transformed, externalize } = await this.options.fetchModule(id);
|
|
133
172
|
if (externalize) {
|
|
134
173
|
debugNative(externalize);
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
return
|
|
174
|
+
const exports2 = await this.interopedImport(externalize);
|
|
175
|
+
mod.exports = exports2;
|
|
176
|
+
return exports2;
|
|
138
177
|
}
|
|
139
178
|
if (transformed == null)
|
|
140
179
|
throw new Error(`[vite-node] Failed to load ${id}`);
|
|
@@ -146,15 +185,34 @@ ${getStack()}`), 2e3);
|
|
|
146
185
|
enumerable: false,
|
|
147
186
|
configurable: false
|
|
148
187
|
});
|
|
149
|
-
|
|
188
|
+
const cjsExports = new Proxy(exports, {
|
|
189
|
+
get(_, p, receiver) {
|
|
190
|
+
return Reflect.get(exports, p, receiver);
|
|
191
|
+
},
|
|
192
|
+
set(_, p, value) {
|
|
193
|
+
if (p !== "default") {
|
|
194
|
+
if (!Reflect.has(exports, "default"))
|
|
195
|
+
exports.default = {};
|
|
196
|
+
if (exports.default === null || typeof exports.default !== "object") {
|
|
197
|
+
defineExport(exports, p, () => void 0);
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
exports.default[p] = value;
|
|
201
|
+
defineExport(exports, p, () => value);
|
|
202
|
+
return true;
|
|
203
|
+
}
|
|
204
|
+
return Reflect.set(exports, p, value);
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
Object.assign(mod, { code: transformed, exports });
|
|
150
208
|
const __filename = fileURLToPath(url);
|
|
151
209
|
const moduleProxy = {
|
|
152
210
|
set exports(value) {
|
|
153
|
-
exportAll(
|
|
154
|
-
|
|
211
|
+
exportAll(cjsExports, value);
|
|
212
|
+
cjsExports.default = value;
|
|
155
213
|
},
|
|
156
214
|
get exports() {
|
|
157
|
-
return
|
|
215
|
+
return cjsExports;
|
|
158
216
|
}
|
|
159
217
|
};
|
|
160
218
|
let hotContext;
|
|
@@ -176,7 +234,7 @@ ${getStack()}`), 2e3);
|
|
|
176
234
|
__vite_ssr_import_meta__: meta,
|
|
177
235
|
__vitest_resolve_id__: resolveId,
|
|
178
236
|
require: createRequire(url),
|
|
179
|
-
exports,
|
|
237
|
+
exports: cjsExports,
|
|
180
238
|
module: moduleProxy,
|
|
181
239
|
__filename,
|
|
182
240
|
__dirname: dirname(__filename)
|
|
@@ -232,19 +290,22 @@ function proxyMethod(name, tryDefault) {
|
|
|
232
290
|
return result;
|
|
233
291
|
};
|
|
234
292
|
}
|
|
293
|
+
function defineExport(exports, key, value) {
|
|
294
|
+
Object.defineProperty(exports, key, {
|
|
295
|
+
enumerable: true,
|
|
296
|
+
configurable: true,
|
|
297
|
+
get: value
|
|
298
|
+
});
|
|
299
|
+
}
|
|
235
300
|
function exportAll(exports, sourceModule) {
|
|
236
301
|
if (exports === sourceModule)
|
|
237
302
|
return;
|
|
303
|
+
if (typeof sourceModule !== "object" || Array.isArray(sourceModule) || !sourceModule)
|
|
304
|
+
return;
|
|
238
305
|
for (const key in sourceModule) {
|
|
239
306
|
if (key !== "default") {
|
|
240
307
|
try {
|
|
241
|
-
|
|
242
|
-
enumerable: true,
|
|
243
|
-
configurable: true,
|
|
244
|
-
get() {
|
|
245
|
-
return sourceModule[key];
|
|
246
|
-
}
|
|
247
|
-
});
|
|
308
|
+
defineExport(exports, key, () => sourceModule[key]);
|
|
248
309
|
} catch (_err) {
|
|
249
310
|
}
|
|
250
311
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { existsSync, promises } from 'fs';
|
|
2
|
-
import {
|
|
3
|
-
import { p as picocolors } from './vendor-picocolors.807856aa.mjs';
|
|
4
|
-
import 'path';
|
|
5
|
-
import 'local-pkg';
|
|
2
|
+
import { a as resolve, p as picocolors, j as join } from './chunk-constants.6196597b.mjs';
|
|
6
3
|
import 'tty';
|
|
4
|
+
import 'url';
|
|
5
|
+
import 'path';
|
|
7
6
|
|
|
8
7
|
function hashCode(s) {
|
|
9
8
|
return s.split("").reduce((a, b) => {
|