vitest 0.25.4 → 0.25.6

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.js CHANGED
@@ -1,7 +1,7 @@
1
- export { c as createExpect, d as describe, e as expect, i as it, s as suite, t as test } from './chunk-runtime-chain.315721df.js';
2
- import { e as dist } from './chunk-runtime-test-state.7c288e2d.js';
3
- export { a as afterAll, d as afterEach, f as assertType, b as beforeAll, c as beforeEach, o as onTestFailed } from './chunk-runtime-test-state.7c288e2d.js';
4
- export { a as setupGlobalEnv, s as startTests } from './chunk-runtime-setup.80b27439.js';
1
+ export { c as createExpect, d as describe, e as expect, i as it, s as suite, t as test } from './chunk-runtime-chain.dd978482.js';
2
+ import { e as dist } from './chunk-runtime-test-state.0037e2e0.js';
3
+ export { a as afterAll, d as afterEach, f as assertType, b as beforeAll, c as beforeEach, o as onTestFailed } from './chunk-runtime-test-state.0037e2e0.js';
4
+ export { a as setupGlobalEnv, s as startTests } from './chunk-runtime-setup.bd2deed4.js';
5
5
  import * as chai from 'chai';
6
6
  export { chai };
7
7
  export { assert, should } from 'chai';
@@ -13,15 +13,15 @@ import 'tty';
13
13
  import 'url';
14
14
  import 'local-pkg';
15
15
  import './vendor-_commonjsHelpers.addc3445.js';
16
- import './chunk-runtime-rpc.b368762d.js';
17
- import './chunk-utils-timers.b81cda77.js';
16
+ import './chunk-runtime-rpc.42aebbb9.js';
17
+ import './chunk-utils-timers.793fd179.js';
18
18
  import 'fs';
19
19
  import './chunk-utils-source-map.29ff1088.js';
20
20
  import './spy.js';
21
21
  import 'tinyspy';
22
22
  import 'perf_hooks';
23
23
  import './chunk-integrations-coverage.befed097.js';
24
- import './chunk-runtime-error.95c286d7.js';
24
+ import './chunk-runtime-error.616e92ca.js';
25
25
  import './vendor-source-map-support.1ce17397.js';
26
26
  import 'source-map';
27
27
  import './chunk-env-node.67948209.js';
@@ -1,5 +1,5 @@
1
1
  import { promises } from 'fs';
2
- import { c as createBirpc } from './chunk-vite-node-source-map.61c5ea66.js';
2
+ import { c as createBirpc } from './chunk-vite-node-source-map.2b1f492a.js';
3
3
  import require$$0$1 from 'stream';
4
4
  import require$$0 from 'zlib';
5
5
  import require$$3 from 'net';
@@ -12,7 +12,7 @@ import url from 'url';
12
12
  import { A as API_PATH } from './chunk-utils-env.03f840f2.js';
13
13
  import 'module';
14
14
  import 'vm';
15
- import './chunk-vite-node-utils.abe05c5c.js';
15
+ import './chunk-vite-node-utils.0e4a6a88.js';
16
16
  import 'acorn';
17
17
  import 'path';
18
18
  import 'assert';
@@ -1,16 +1,16 @@
1
1
  import { m as globalApis } from './chunk-utils-env.03f840f2.js';
2
- import { i as index } from './chunk-runtime-test-state.7c288e2d.js';
2
+ import { i as index } from './chunk-runtime-test-state.0037e2e0.js';
3
3
  import 'tty';
4
4
  import 'url';
5
5
  import 'path';
6
- import './chunk-runtime-chain.315721df.js';
6
+ import './chunk-runtime-chain.dd978482.js';
7
7
  import 'util';
8
8
  import 'chai';
9
9
  import './chunk-typecheck-constants.ed987901.js';
10
10
  import 'local-pkg';
11
11
  import './vendor-_commonjsHelpers.addc3445.js';
12
- import './chunk-runtime-rpc.b368762d.js';
13
- import './chunk-utils-timers.b81cda77.js';
12
+ import './chunk-runtime-rpc.42aebbb9.js';
13
+ import './chunk-utils-timers.793fd179.js';
14
14
  import 'fs';
15
15
  import './chunk-utils-source-map.29ff1088.js';
16
16
  import './spy.js';
@@ -3,10 +3,10 @@ import * as chai$2 from 'chai';
3
3
  import { expect, AssertionError, util } from 'chai';
4
4
  import { i as isObject, b as getCallLastIndex, s as slash, g as getWorkerState, c as getNames, d as assertTypes, e as getFullName, o as objectAttr, n as noop, f as isRunningInTest, h as isRunningInBenchmark } from './chunk-typecheck-constants.ed987901.js';
5
5
  import { c as commonjsGlobal } from './vendor-_commonjsHelpers.addc3445.js';
6
- import { r as rpc } from './chunk-runtime-rpc.b368762d.js';
6
+ import { r as rpc } from './chunk-runtime-rpc.42aebbb9.js';
7
7
  import fs, { promises } from 'fs';
8
8
  import { j as join, d as dirname, p as picocolors } from './chunk-utils-env.03f840f2.js';
9
- import { p as plugins_1, f as format_1, u as unifiedDiff, a as stringify, m as matcherUtils, s as safeSetTimeout, b as safeClearTimeout } from './chunk-utils-timers.b81cda77.js';
9
+ import { p as plugins_1, f as format_1, u as unifiedDiff, a as stringify, m as matcherUtils, s as safeSetTimeout, b as safeClearTimeout } from './chunk-utils-timers.793fd179.js';
10
10
  import { a as posToNumber, n as numberToPos, l as lineSplitRE, p as parseStacktrace } from './chunk-utils-source-map.29ff1088.js';
11
11
  import { isMockFunction } from './spy.js';
12
12
 
@@ -1,6 +1,6 @@
1
1
  import util$1 from 'util';
2
2
  import { util } from 'chai';
3
- import { a as stringify } from './chunk-utils-timers.b81cda77.js';
3
+ import { a as stringify } from './chunk-utils-timers.793fd179.js';
4
4
  import { w as deepClone, x as getType } from './chunk-typecheck-constants.ed987901.js';
5
5
 
6
6
  const IS_RECORD_SYMBOL = "@@__IMMUTABLE_RECORD__@@";
@@ -1,8 +1,8 @@
1
- import { V as ViteNodeRunner } from './chunk-vite-node-source-map.61c5ea66.js';
1
+ import { V as ViteNodeRunner } from './chunk-vite-node-source-map.2b1f492a.js';
2
2
  import { normalizePath } from 'vite';
3
3
  import { g as getWorkerState, J as mergeSlashes, s as slash, x as getType, K as getAllMockableProperties } from './chunk-typecheck-constants.ed987901.js';
4
4
  import { existsSync, readdirSync } from 'fs';
5
- import { n as normalizeRequestId, p as pathFromRoot, i as isNodeBuiltin } from './chunk-vite-node-utils.abe05c5c.js';
5
+ import { c as normalizeRequestId, p as pathFromRoot, i as isNodeBuiltin } from './chunk-vite-node-utils.0e4a6a88.js';
6
6
  import { p as picocolors, d as dirname, j as join, c as basename, l as extname, b as resolve, e as distDir } from './chunk-utils-env.03f840f2.js';
7
7
 
8
8
  class RefTracker {
@@ -318,14 +318,18 @@ class VitestRunner extends ViteNodeRunner {
318
318
  prepareContext(context) {
319
319
  const request = context.__vite_ssr_import__;
320
320
  const resolveId = context.__vitest_resolve_id__;
321
+ const resolveUrl = async (dep) => {
322
+ const [id, resolvedId] = await resolveId(dep);
323
+ return resolvedId || id;
324
+ };
321
325
  const mocker = new VitestMocker(this.options, this.moduleCache, request);
322
326
  const workerState = getWorkerState();
323
327
  if (workerState.filepath && normalizePath(workerState.filepath) === normalizePath(context.__filename)) {
324
328
  Object.defineProperty(context.__vite_ssr_import_meta__, "vitest", { get: () => globalThis.__vitest_index__ });
325
329
  }
326
330
  return Object.assign(context, {
327
- __vite_ssr_import__: async (dep) => mocker.requestWithMock(await resolveId(dep)),
328
- __vite_ssr_dynamic_import__: async (dep) => mocker.requestWithMock(await resolveId(dep)),
331
+ __vite_ssr_import__: async (dep) => mocker.requestWithMock(await resolveUrl(dep)),
332
+ __vite_ssr_dynamic_import__: async (dep) => mocker.requestWithMock(await resolveUrl(dep)),
329
333
  __vitest_mocker__: mocker
330
334
  });
331
335
  }
@@ -1,5 +1,5 @@
1
1
  import { g as getWorkerState } from './chunk-typecheck-constants.ed987901.js';
2
- import { s as safeSetTimeout } from './chunk-utils-timers.b81cda77.js';
2
+ import { s as safeSetTimeout } from './chunk-utils-timers.793fd179.js';
3
3
 
4
4
  const safeRandom = Math.random;
5
5
  function withSafeTimers(fn) {
@@ -1,14 +1,14 @@
1
1
  import { performance } from 'perf_hooks';
2
2
  import { s as someTasksAreOnly, i as interpretTaskModes, t as takeCoverageInsideWorker, p as pLimit } from './chunk-integrations-coverage.befed097.js';
3
- import { r as resetRunOnceCounter, i as index, v as vi, s as setCurrentTest } from './chunk-runtime-test-state.7c288e2d.js';
3
+ import { r as resetRunOnceCounter, i as index, v as vi, s as setCurrentTest } from './chunk-runtime-test-state.0037e2e0.js';
4
4
  import { g as getWorkerState, R as RealDate, t as toArray, k as relativePath, h as isRunningInBenchmark, p as partitionSuiteChildren, l as shuffle, q as hasTests, u as hasFailed, v as createDefer, e as getFullName } from './chunk-typecheck-constants.ed987901.js';
5
- import { f as clearCollectorContext, h as defaultSuite, j as setHooks, k as getHooks, l as collectorContext, m as getBenchOptions, n as getFn, o as setState, G as GLOBAL_EXPECT, p as getState } from './chunk-runtime-chain.315721df.js';
6
- import { r as rpc } from './chunk-runtime-rpc.b368762d.js';
7
- import { p as processError } from './chunk-runtime-error.95c286d7.js';
5
+ import { f as clearCollectorContext, h as defaultSuite, j as setHooks, k as getHooks, l as collectorContext, m as getBenchOptions, n as getFn, o as setState, G as GLOBAL_EXPECT, p as getState } from './chunk-runtime-chain.dd978482.js';
6
+ import { r as rpc } from './chunk-runtime-rpc.42aebbb9.js';
7
+ import { p as processError } from './chunk-runtime-error.616e92ca.js';
8
8
  import { s as sourceMapSupport } from './vendor-source-map-support.1ce17397.js';
9
9
  import { e as environments } from './chunk-env-node.67948209.js';
10
10
  import { i as isNode, a as isBrowser } from './chunk-utils-env.03f840f2.js';
11
- import { b as safeClearTimeout, s as safeSetTimeout } from './chunk-utils-timers.b81cda77.js';
11
+ import { b as safeClearTimeout, s as safeSetTimeout } from './chunk-utils-timers.793fd179.js';
12
12
 
13
13
  function installSourcemapsSupport(options) {
14
14
  sourceMapSupport.exports.install({
@@ -46,7 +46,7 @@ async function setupGlobalEnv(config) {
46
46
  await setupConsoleLogSpy();
47
47
  }
48
48
  if (config.globals)
49
- (await import('./chunk-integrations-globals.789c69e2.js')).registerApiGlobally();
49
+ (await import('./chunk-integrations-globals.57158eb5.js')).registerApiGlobally();
50
50
  }
51
51
  function setupDefines(defines) {
52
52
  for (const key in defines)
@@ -346,7 +346,7 @@ const callCleanupHooks = async (cleanups) => {
346
346
  async function runTest(test) {
347
347
  var _a, _b, _c;
348
348
  if (test.mode !== "run") {
349
- const { getSnapshotClient } = await import('./chunk-runtime-chain.315721df.js').then(function (n) { return n.r; });
349
+ const { getSnapshotClient } = await import('./chunk-runtime-chain.dd978482.js').then(function (n) { return n.r; });
350
350
  getSnapshotClient().skipTestSnapshots(test);
351
351
  return;
352
352
  }
@@ -363,7 +363,7 @@ async function runTest(test) {
363
363
  clearModuleMocks();
364
364
  setCurrentTest(test);
365
365
  if (isNode) {
366
- const { getSnapshotClient } = await import('./chunk-runtime-chain.315721df.js').then(function (n) { return n.r; });
366
+ const { getSnapshotClient } = await import('./chunk-runtime-chain.dd978482.js').then(function (n) { return n.r; });
367
367
  await getSnapshotClient().setTest(test);
368
368
  }
369
369
  const workerState = getWorkerState();
@@ -426,7 +426,7 @@ async function runTest(test) {
426
426
  console.error(test.result.error.message, test.result.error.stackStr);
427
427
  setCurrentTest(void 0);
428
428
  if (isNode) {
429
- const { getSnapshotClient } = await import('./chunk-runtime-chain.315721df.js').then(function (n) { return n.r; });
429
+ const { getSnapshotClient } = await import('./chunk-runtime-chain.dd978482.js').then(function (n) { return n.r; });
430
430
  getSnapshotClient().clearTest();
431
431
  }
432
432
  test.result.duration = now() - start;
@@ -632,7 +632,7 @@ async function startTestsBrowser(paths, config) {
632
632
  async function startTestsNode(paths, config) {
633
633
  const files = await collectTests(paths, config);
634
634
  rpc().onCollected(files);
635
- const { getSnapshotClient } = await import('./chunk-runtime-chain.315721df.js').then(function (n) { return n.r; });
635
+ const { getSnapshotClient } = await import('./chunk-runtime-chain.dd978482.js').then(function (n) { return n.r; });
636
636
  getSnapshotClient().clear();
637
637
  await runFiles(files, config);
638
638
  const coverage = await takeCoverageInsideWorker(config.coverage);
@@ -1,10 +1,10 @@
1
- import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, s as suite, t as test, d as describe, i as it, b as bench, c as createExpect, e as globalExpect } from './chunk-runtime-chain.315721df.js';
1
+ import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, s as suite, t as test, d as describe, i as it, b as bench, c as createExpect, e as globalExpect } from './chunk-runtime-chain.dd978482.js';
2
2
  import { g as getWorkerState, R as RealDate, r as resetDate, m as mockDate, a as resetModules } from './chunk-typecheck-constants.ed987901.js';
3
3
  import { p as parseStacktrace } from './chunk-utils-source-map.29ff1088.js';
4
4
  import { c as commonjsGlobal } from './vendor-_commonjsHelpers.addc3445.js';
5
5
  import util from 'util';
6
6
  import { spyOn, fn, isMockFunction, spies } from './spy.js';
7
- import { s as safeSetTimeout } from './chunk-utils-timers.b81cda77.js';
7
+ import { s as safeSetTimeout } from './chunk-utils-timers.793fd179.js';
8
8
  import * as chai from 'chai';
9
9
  import { assert, should } from 'chai';
10
10
 
@@ -12,10 +12,10 @@ import util$2 from 'util';
12
12
  import require$$0$1 from 'stream';
13
13
  import require$$2 from 'events';
14
14
  import { c as commonjsGlobal } from './vendor-_commonjsHelpers.addc3445.js';
15
- import { w as withInlineSourcemap, c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-source-map.61c5ea66.js';
15
+ import { w as withInlineSourcemap, c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-source-map.2b1f492a.js';
16
16
  import { performance } from 'perf_hooks';
17
17
  import createDebug from 'debug';
18
- import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toArray, b as toFilePath } from './chunk-vite-node-utils.abe05c5c.js';
18
+ import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toArray, n as normalizeModuleId, b as toFilePath } from './chunk-vite-node-utils.0e4a6a88.js';
19
19
  import { writeFile, rm } from 'fs/promises';
20
20
  import { e as execa } from './vendor-index.737c3cff.js';
21
21
  import { SourceMapConsumer } from 'source-map';
@@ -24,7 +24,7 @@ import { parse as parse$4 } from 'acorn';
24
24
  import { ancestor } from 'acorn-walk';
25
25
  import { MessageChannel } from 'worker_threads';
26
26
  import { Tinypool } from 'tinypool';
27
- import { c as stripAnsi, d as safeSetInterval, e as safeClearInterval, g as cliTruncate, s as safeSetTimeout, h as stringWidth, i as ansiStyles, j as sliceAnsi, a as stringify$5, u as unifiedDiff, b as safeClearTimeout } from './chunk-utils-timers.b81cda77.js';
27
+ import { c as stripAnsi, d as safeSetInterval, e as safeClearInterval, g as cliTruncate, s as safeSetTimeout, h as stringWidth, i as ansiStyles, j as sliceAnsi, a as stringify$5, u as unifiedDiff, b as safeClearTimeout } from './chunk-utils-timers.793fd179.js';
28
28
  import { p as parseStacktrace, a as posToNumber, l as lineSplitRE } from './chunk-utils-source-map.29ff1088.js';
29
29
  import { resolveModule } from 'local-pkg';
30
30
  import { createHash } from 'crypto';
@@ -35,7 +35,7 @@ import { stripLiteral } from 'strip-literal';
35
35
  import require$$0$2 from 'readline';
36
36
  import { p as prompts } from './vendor-index.9f20a9be.js';
37
37
 
38
- var version$1 = "0.25.4";
38
+ var version$1 = "0.25.6";
39
39
 
40
40
  class EndError extends Error {
41
41
  constructor(value) {
@@ -6937,7 +6937,6 @@ ${result.code}`, "utf-8");
6937
6937
  }
6938
6938
 
6939
6939
  const debugRequest = createDebug("vite-node:server:request");
6940
- const RealDate = Date;
6941
6940
  class ViteNodeServer {
6942
6941
  constructor(server, options = {}) {
6943
6942
  this.server = server;
@@ -6984,6 +6983,7 @@ class ViteNodeServer {
6984
6983
  return (ssrTransformResult == null ? void 0 : ssrTransformResult.map) || null;
6985
6984
  }
6986
6985
  async fetchModule(id) {
6986
+ id = normalizeModuleId(id);
6987
6987
  if (!this.fetchPromiseMap.has(id)) {
6988
6988
  this.fetchPromiseMap.set(
6989
6989
  id,
@@ -7023,10 +7023,11 @@ class ViteNodeServer {
7023
7023
  let result;
7024
7024
  const filePath = toFilePath(id, this.server.config.root);
7025
7025
  const module = this.server.moduleGraph.getModuleById(id);
7026
- const timestamp = (module == null ? void 0 : module.lastHMRTimestamp) || RealDate.now();
7026
+ const timestamp = module ? module.lastHMRTimestamp : null;
7027
7027
  const cache = this.fetchCache.get(filePath);
7028
- if (timestamp && cache && cache.timestamp >= timestamp)
7028
+ if (timestamp !== null && cache && cache.timestamp >= timestamp)
7029
7029
  return cache.result;
7030
+ const time = Date.now();
7030
7031
  const externalize = await this.shouldExternalize(filePath);
7031
7032
  let duration;
7032
7033
  if (externalize) {
@@ -7040,7 +7041,7 @@ class ViteNodeServer {
7040
7041
  }
7041
7042
  this.fetchCache.set(filePath, {
7042
7043
  duration,
7043
- timestamp,
7044
+ timestamp: time,
7044
7045
  result
7045
7046
  });
7046
7047
  return result;
@@ -10206,7 +10207,7 @@ createLogUpdate(process$1.stdout);
10206
10207
 
10207
10208
  createLogUpdate(process$1.stderr);
10208
10209
 
10209
- var version = "0.25.4";
10210
+ var version = "0.25.6";
10210
10211
 
10211
10212
  function fileFromParsedStack(stack) {
10212
10213
  var _a, _b;
@@ -10568,8 +10569,7 @@ class Vitest {
10568
10569
  this.cache.results.setConfig(resolved.root, resolved.cache);
10569
10570
  try {
10570
10571
  await this.cache.results.readFromCache();
10571
- } catch (err) {
10572
- this.logger.error(`[vitest] Error, while trying to parse cache in ${this.cache.results.getCachePath()}:`, err);
10572
+ } catch {
10573
10573
  }
10574
10574
  }
10575
10575
  async initCoverageProvider() {
@@ -10732,6 +10732,7 @@ class Vitest {
10732
10732
  return runningTests;
10733
10733
  }
10734
10734
  async runFiles(paths) {
10735
+ paths = Array.from(new Set(paths));
10735
10736
  await this.runningPromise;
10736
10737
  this.state.startCollectingPaths();
10737
10738
  this.runningPromise = (async () => {
@@ -10796,6 +10797,9 @@ class Vitest {
10796
10797
  }
10797
10798
  }
10798
10799
  async scheduleRerun(triggerId) {
10800
+ const mod = this.server.moduleGraph.getModuleById(triggerId);
10801
+ if (mod)
10802
+ mod.lastHMRTimestamp = Date.now();
10799
10803
  const currentCount = this.restartsCount;
10800
10804
  safeClearTimeout(this._rerunTimer);
10801
10805
  await this.runningPromise;
@@ -11382,7 +11386,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
11382
11386
  try {
11383
11387
  await ctx.setServer(options, server);
11384
11388
  if (options.api && options.watch)
11385
- (await import('./chunk-api-setup.1c8923c4.js')).setup(ctx);
11389
+ (await import('./chunk-api-setup.5669c9a4.js')).setup(ctx);
11386
11390
  } catch (err) {
11387
11391
  ctx.logger.printError(err, true);
11388
11392
  process.exit(1);
@@ -2,24 +2,28 @@ import { createRequire } from 'module';
2
2
  import { pathToFileURL, fileURLToPath } from 'url';
3
3
  import vm from 'vm';
4
4
  import { b as resolve, d as dirname, g as isAbsolute, l as extname } from './chunk-utils-env.03f840f2.js';
5
- import { s as slash, n as normalizeRequestId, b as toFilePath, c as isPrimitive, i as isNodeBuiltin, d as normalizeModuleId, m as mergeSlashes } from './chunk-vite-node-utils.abe05c5c.js';
5
+ import { s as slash, c as normalizeRequestId, b as toFilePath, d as cleanUrl, e as isPrimitive, i as isNodeBuiltin, n as normalizeModuleId } from './chunk-vite-node-utils.0e4a6a88.js';
6
6
  import createDebug from 'debug';
7
7
  import './vendor-source-map-support.1ce17397.js';
8
8
 
9
9
  let SOURCEMAPPING_URL = "sourceMa";
10
10
  SOURCEMAPPING_URL += "ppingURL";
11
- const VITE_NODE_SOURCEMAPPING_URL = `${SOURCEMAPPING_URL}=data:application/json;charset=utf-8;source=vite-node`;
11
+ const VITE_NODE_SOURCEMAPPING_SOURCE = "//# sourceMappingSource=vite-node";
12
+ const VITE_NODE_SOURCEMAPPING_URL = `${SOURCEMAPPING_URL}=data:application/json;charset=utf-8`;
12
13
  const VITE_NODE_SOURCEMAPPING_REGEXP = new RegExp(`//# ${VITE_NODE_SOURCEMAPPING_URL};base64,(.+)`);
13
- const OTHER_SOURCE_MAP_REGEXP = new RegExp(`//# ${SOURCEMAPPING_URL}=data:application/json[^,]+base64,(.+)`);
14
14
  async function withInlineSourcemap(result) {
15
- const { code, map } = result;
16
- if (!map || code.includes(VITE_NODE_SOURCEMAPPING_URL))
15
+ const map = result.map;
16
+ let code = result.code;
17
+ if (!map || code.includes(VITE_NODE_SOURCEMAPPING_SOURCE))
17
18
  return result;
18
- if (OTHER_SOURCE_MAP_REGEXP.test(code))
19
- result.code = code.replace(OTHER_SOURCE_MAP_REGEXP, "");
20
- result.code = `${code}
19
+ const OTHER_SOURCE_MAP_REGEXP = new RegExp(`//# ${SOURCEMAPPING_URL}=data:application/json[^,]+base64,(.+)`, "g");
20
+ while (OTHER_SOURCE_MAP_REGEXP.test(code))
21
+ code = code.replace(OTHER_SOURCE_MAP_REGEXP, "");
22
+ const sourceMap = Buffer.from(JSON.stringify(map), "utf-8").toString("base64");
23
+ result.code = `${code.trimEnd()}
21
24
 
22
- //# ${VITE_NODE_SOURCEMAPPING_URL};base64,${Buffer.from(JSON.stringify(map), "utf-8").toString("base64")}
25
+ ${VITE_NODE_SOURCEMAPPING_SOURCE}
26
+ //# ${VITE_NODE_SOURCEMAPPING_URL};base64,${sourceMap}
23
27
  `;
24
28
  return result;
25
29
  }
@@ -171,10 +175,10 @@ class ViteNodeRunner {
171
175
  }
172
176
  async directRequest(id, fsPath, _callstack) {
173
177
  const callstack = [..._callstack, fsPath];
174
- const mod = this.moduleCache.get(fsPath);
175
- const request = async (dep) => {
178
+ let mod = this.moduleCache.get(fsPath);
179
+ const request = async (dep2) => {
176
180
  var _a;
177
- const depFsPath = toFilePath(normalizeRequestId(dep, this.options.base), this.root);
181
+ const depFsPath = toFilePath(normalizeRequestId(dep2, this.options.base), this.root);
178
182
  const getStack = () => {
179
183
  return `stack:
180
184
  ${[...callstack, depFsPath].reverse().map((p) => `- ${p}`).join("\n")}`;
@@ -190,28 +194,42 @@ ${getStack()}`), 2e3);
190
194
  return depExports;
191
195
  throw new Error(`[vite-node] Failed to resolve circular dependency, ${getStack()}`);
192
196
  }
193
- return await this.cachedRequest(dep, callstack);
197
+ return await this.cachedRequest(dep2, callstack);
194
198
  } finally {
195
199
  if (debugTimer)
196
200
  clearTimeout(debugTimer);
197
201
  }
198
202
  };
199
203
  Object.defineProperty(request, "callstack", { get: () => callstack });
200
- const resolveId = async (dep, callstackPosition = 1) => {
201
- if (this.options.resolveId && this.shouldResolveId(dep)) {
204
+ const resolveId = async (dep2, callstackPosition = 1) => {
205
+ if (this.options.resolveId && this.shouldResolveId(dep2)) {
202
206
  let importer = callstack[callstack.length - callstackPosition];
207
+ if (importer && !dep2.startsWith("."))
208
+ importer = void 0;
203
209
  if (importer && importer.startsWith("mock:"))
204
210
  importer = importer.slice(5);
205
- const { id: id2 } = await this.options.resolveId(dep, importer) || {};
206
- dep = id2 && isAbsolute(id2) ? mergeSlashes(`/@fs/${id2}`) : id2 || dep;
211
+ const resolved = await this.options.resolveId(normalizeRequestId(dep2), importer);
212
+ return [dep2, resolved == null ? void 0 : resolved.id];
207
213
  }
208
- return dep;
214
+ return [dep2, void 0];
209
215
  };
210
- id = await resolveId(id, 2);
216
+ const [dep, resolvedId] = await resolveId(id, 2);
211
217
  const requestStubs = this.options.requestStubs || DEFAULT_REQUEST_STUBS;
212
218
  if (id in requestStubs)
213
219
  return requestStubs[id];
214
- let { code: transformed, externalize } = await this.options.fetchModule(id);
220
+ let { code: transformed, externalize } = await this.options.fetchModule(resolvedId || dep);
221
+ if (resolvedId && !fsPath.includes("?") && fsPath !== resolvedId) {
222
+ if (this.moduleCache.has(resolvedId)) {
223
+ mod = this.moduleCache.get(resolvedId);
224
+ this.moduleCache.set(fsPath, mod);
225
+ if (mod.promise)
226
+ return mod.promise;
227
+ if (mod.exports)
228
+ return mod.exports;
229
+ } else {
230
+ this.moduleCache.set(resolvedId, mod);
231
+ }
232
+ }
215
233
  if (externalize) {
216
234
  debugNative(externalize);
217
235
  const exports2 = await this.interopedImport(externalize);
@@ -220,7 +238,8 @@ ${getStack()}`), 2e3);
220
238
  }
221
239
  if (transformed == null)
222
240
  throw new Error(`[vite-node] Failed to load ${id}`);
223
- const url = pathToFileURL(fsPath).href;
241
+ const file = cleanUrl(resolvedId || fsPath);
242
+ const url = pathToFileURL(file).href;
224
243
  const meta = { url };
225
244
  const exports = /* @__PURE__ */ Object.create(null);
226
245
  Object.defineProperty(exports, Symbol.toStringTag, {
@@ -229,9 +248,6 @@ ${getStack()}`), 2e3);
229
248
  configurable: false
230
249
  });
231
250
  const cjsExports = new Proxy(exports, {
232
- get(_, p, receiver) {
233
- return Reflect.get(exports, p, receiver);
234
- },
235
251
  set(_, p, value) {
236
252
  if (!Reflect.has(exports, "default"))
237
253
  exports.default = {};
@@ -245,7 +261,7 @@ ${getStack()}`), 2e3);
245
261
  return true;
246
262
  }
247
263
  });
248
- Object.assign(mod, { code: transformed, exports, evaluated: false });
264
+ Object.assign(mod, { code: transformed, exports });
249
265
  const __filename = fileURLToPath(url);
250
266
  const moduleProxy = {
251
267
  set exports(value) {
@@ -287,7 +303,7 @@ ${getStack()}`), 2e3);
287
303
  const code = `${codeDefinition}${transformed}
288
304
  }}`;
289
305
  const fn = vm.runInThisContext(code, {
290
- filename: fsPath,
306
+ filename: __filename,
291
307
  lineOffset: 0,
292
308
  columnOffset: -codeDefinition.length
293
309
  });
@@ -1334,14 +1334,14 @@ const isWindows = process.platform === "win32";
1334
1334
  function slash(str) {
1335
1335
  return str.replace(/\\/g, "/");
1336
1336
  }
1337
- function mergeSlashes(str) {
1338
- return str.replace(/\/\//g, "/");
1339
- }
1340
1337
  function normalizeRequestId(id, base) {
1341
1338
  if (base && id.startsWith(base))
1342
1339
  id = `/${id.slice(base.length)}`;
1343
1340
  return id.replace(/^\/@id\/__x00__/, "\0").replace(/^\/@id\//, "").replace(/^__vite-browser-external:/, "").replace(/^(node|file):/, "").replace(/^\/+/, "/").replace(/\?v=\w+/, "?").replace(/&v=\w+/, "").replace(/\?t=\w+/, "?").replace(/&t=\w+/, "").replace(/\?import/, "?").replace(/&import/, "").replace(/\?&/, "?").replace(/\?+$/, "");
1344
1341
  }
1342
+ const queryRE = /\?.*$/s;
1343
+ const hashRE = /#.*$/s;
1344
+ const cleanUrl = (url) => url.replace(hashRE, "").replace(queryRE, "");
1345
1345
  function normalizeModuleId(id) {
1346
1346
  return id.replace(/\\/g, "/").replace(/^\/@fs\//, "/").replace(/^file:\//, "/").replace(/^\/+/, "/");
1347
1347
  }
@@ -1382,4 +1382,4 @@ function toArray(array) {
1382
1382
  return [array];
1383
1383
  }
1384
1384
 
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 };
1385
+ export { isValidNodeImport as a, toFilePath as b, normalizeRequestId as c, cleanUrl as d, isPrimitive as e, hasCJSSyntax as h, isNodeBuiltin as i, normalizeModuleId 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.ddcbafa3.js';
3
+ import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.328ed604.js';
4
4
  import 'tty';
5
5
  import 'url';
6
6
  import 'path';
@@ -16,10 +16,10 @@ import 'os';
16
16
  import 'util';
17
17
  import 'stream';
18
18
  import './vendor-_commonjsHelpers.addc3445.js';
19
- import './chunk-vite-node-source-map.61c5ea66.js';
19
+ import './chunk-vite-node-source-map.2b1f492a.js';
20
20
  import 'module';
21
21
  import 'vm';
22
- import './chunk-vite-node-utils.abe05c5c.js';
22
+ import './chunk-vite-node-utils.0e4a6a88.js';
23
23
  import 'acorn';
24
24
  import 'assert';
25
25
  import 'debug';
@@ -34,7 +34,7 @@ import './vendor-index.e1d4cf84.js';
34
34
  import 'acorn-walk';
35
35
  import 'worker_threads';
36
36
  import 'tinypool';
37
- import './chunk-utils-timers.b81cda77.js';
37
+ import './chunk-utils-timers.793fd179.js';
38
38
  import './chunk-utils-source-map.29ff1088.js';
39
39
  import 'crypto';
40
40
  import './vendor-index.9c919048.js';
package/dist/entry.js CHANGED
@@ -1,26 +1,26 @@
1
1
  import { promises } from 'fs';
2
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';
3
+ import { v as vi } from './chunk-runtime-test-state.0037e2e0.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.80b27439.js';
5
+ import { a as setupGlobalEnv, s as startTests, w as withEnv } from './chunk-runtime-setup.bd2deed4.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.315721df.js';
11
+ import './chunk-runtime-chain.dd978482.js';
12
12
  import 'util';
13
13
  import 'chai';
14
14
  import './vendor-_commonjsHelpers.addc3445.js';
15
- import './chunk-runtime-rpc.b368762d.js';
16
- import './chunk-utils-timers.b81cda77.js';
15
+ import './chunk-runtime-rpc.42aebbb9.js';
16
+ import './chunk-utils-timers.793fd179.js';
17
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.95c286d7.js';
23
+ import './chunk-runtime-error.616e92ca.js';
24
24
  import './vendor-source-map-support.1ce17397.js';
25
25
  import 'source-map';
26
26
 
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- export { b as bench, c as createExpect, d as describe, e as expect, i as it, s as suite, t as test } from './chunk-runtime-chain.315721df.js';
2
- import { e as dist } from './chunk-runtime-test-state.7c288e2d.js';
3
- export { a as afterAll, d as afterEach, f as assertType, b as beforeAll, c as beforeEach, k as getRunningMode, h as isFirstRun, l as isWatchMode, o as onTestFailed, g as runOnce, v as vi, j as vitest, w as withCallback } from './chunk-runtime-test-state.7c288e2d.js';
1
+ export { b as bench, c as createExpect, d as describe, e as expect, i as it, s as suite, t as test } from './chunk-runtime-chain.dd978482.js';
2
+ import { e as dist } from './chunk-runtime-test-state.0037e2e0.js';
3
+ export { a as afterAll, d as afterEach, f as assertType, b as beforeAll, c as beforeEach, k as getRunningMode, h as isFirstRun, l as isWatchMode, o as onTestFailed, g as runOnce, v as vi, j as vitest, w as withCallback } from './chunk-runtime-test-state.0037e2e0.js';
4
4
  import * as chai from 'chai';
5
5
  export { chai };
6
6
  export { assert, should } from 'chai';
@@ -12,8 +12,8 @@ import 'tty';
12
12
  import 'url';
13
13
  import 'local-pkg';
14
14
  import './vendor-_commonjsHelpers.addc3445.js';
15
- import './chunk-runtime-rpc.b368762d.js';
16
- import './chunk-utils-timers.b81cda77.js';
15
+ import './chunk-runtime-rpc.42aebbb9.js';
16
+ import './chunk-utils-timers.793fd179.js';
17
17
  import 'fs';
18
18
  import './chunk-utils-source-map.29ff1088.js';
19
19
  import './spy.js';
package/dist/loader.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { pathToFileURL } from 'url';
2
2
  import { readFile } from 'fs/promises';
3
- import { i as isNodeBuiltin, d as normalizeModuleId, h as hasCJSSyntax } from './chunk-vite-node-utils.abe05c5c.js';
3
+ import { i as isNodeBuiltin, n as normalizeModuleId, h as hasCJSSyntax } from './chunk-vite-node-utils.0e4a6a88.js';
4
4
  import { g as getWorkerState } from './chunk-typecheck-constants.ed987901.js';
5
5
  import 'fs';
6
6
  import './chunk-utils-env.03f840f2.js';
package/dist/node.js CHANGED
@@ -1,5 +1,5 @@
1
- export { B as BaseSequencer, V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.ddcbafa3.js';
2
- export { V as VitestRunner } from './chunk-runtime-mocker.cdc0ec57.js';
1
+ export { B as BaseSequencer, V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.328ed604.js';
2
+ export { V as VitestRunner } from './chunk-runtime-mocker.bf08ae09.js';
3
3
  import './chunk-utils-env.03f840f2.js';
4
4
  import 'tty';
5
5
  import 'url';
@@ -17,10 +17,10 @@ import 'util';
17
17
  import 'stream';
18
18
  import 'events';
19
19
  import './vendor-_commonjsHelpers.addc3445.js';
20
- import './chunk-vite-node-source-map.61c5ea66.js';
20
+ import './chunk-vite-node-source-map.2b1f492a.js';
21
21
  import 'module';
22
22
  import 'vm';
23
- import './chunk-vite-node-utils.abe05c5c.js';
23
+ import './chunk-vite-node-utils.0e4a6a88.js';
24
24
  import 'acorn';
25
25
  import 'assert';
26
26
  import 'debug';
@@ -35,7 +35,7 @@ import './vendor-index.e1d4cf84.js';
35
35
  import 'acorn-walk';
36
36
  import 'worker_threads';
37
37
  import 'tinypool';
38
- import './chunk-utils-timers.b81cda77.js';
38
+ import './chunk-utils-timers.793fd179.js';
39
39
  import './chunk-utils-source-map.29ff1088.js';
40
40
  import 'crypto';
41
41
  import './vendor-index.9c919048.js';
package/dist/suite.js CHANGED
@@ -1,15 +1,15 @@
1
1
  import 'util';
2
2
  import 'chai';
3
3
  import './chunk-typecheck-constants.ed987901.js';
4
- export { b as bench, f as clearCollectorContext, q as createSuiteHooks, h as defaultSuite, d as describe, g as getCurrentSuite, i as it, s as suite, t as test } from './chunk-runtime-chain.315721df.js';
4
+ export { b as bench, f as clearCollectorContext, q as createSuiteHooks, h as defaultSuite, d as describe, g as getCurrentSuite, i as it, s as suite, t as test } from './chunk-runtime-chain.dd978482.js';
5
5
  import 'path';
6
6
  import './chunk-utils-env.03f840f2.js';
7
7
  import 'tty';
8
8
  import 'url';
9
9
  import 'local-pkg';
10
10
  import './vendor-_commonjsHelpers.addc3445.js';
11
- import './chunk-runtime-rpc.b368762d.js';
12
- import './chunk-utils-timers.b81cda77.js';
11
+ import './chunk-runtime-rpc.42aebbb9.js';
12
+ import './chunk-utils-timers.793fd179.js';
13
13
  import 'fs';
14
14
  import './chunk-utils-source-map.29ff1088.js';
15
15
  import './spy.js';
package/dist/worker.js CHANGED
@@ -1,16 +1,16 @@
1
1
  import { b as resolve, e as distDir } from './chunk-utils-env.03f840f2.js';
2
- import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-source-map.61c5ea66.js';
2
+ import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-source-map.2b1f492a.js';
3
3
  import { workerId } from 'tinypool';
4
4
  import { g as getWorkerState } from './chunk-typecheck-constants.ed987901.js';
5
- import { e as executeInViteNode } from './chunk-runtime-mocker.cdc0ec57.js';
6
- import { r as rpc } from './chunk-runtime-rpc.b368762d.js';
7
- import { p as processError } from './chunk-runtime-error.95c286d7.js';
5
+ import { e as executeInViteNode } from './chunk-runtime-mocker.bf08ae09.js';
6
+ import { r as rpc } from './chunk-runtime-rpc.42aebbb9.js';
7
+ import { p as processError } from './chunk-runtime-error.616e92ca.js';
8
8
  import 'tty';
9
9
  import 'url';
10
10
  import 'path';
11
11
  import 'module';
12
12
  import 'vm';
13
- import './chunk-vite-node-utils.abe05c5c.js';
13
+ import './chunk-vite-node-utils.0e4a6a88.js';
14
14
  import 'fs';
15
15
  import 'acorn';
16
16
  import 'assert';
@@ -20,7 +20,7 @@ import './vendor-source-map-support.1ce17397.js';
20
20
  import 'source-map';
21
21
  import 'local-pkg';
22
22
  import 'vite';
23
- import './chunk-utils-timers.b81cda77.js';
23
+ import './chunk-utils-timers.793fd179.js';
24
24
  import 'chai';
25
25
 
26
26
  let _viteNode;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vitest",
3
3
  "type": "module",
4
- "version": "0.25.4",
4
+ "version": "0.25.6",
5
5
  "description": "A blazing fast unit test framework powered by Vite",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -125,7 +125,7 @@
125
125
  "@types/natural-compare": "^1.4.1",
126
126
  "@types/prompts": "^2.4.1",
127
127
  "@types/sinonjs__fake-timers": "^8.1.2",
128
- "@vitest/ui": "0.25.4",
128
+ "@vitest/ui": "0.25.6",
129
129
  "birpc": "^0.2.3",
130
130
  "cac": "^6.7.14",
131
131
  "chai-subset": "^1.6.0",
@@ -148,13 +148,13 @@
148
148
  "p-limit": "^4.0.0",
149
149
  "pathe": "^0.2.0",
150
150
  "picocolors": "^1.0.0",
151
- "pkg-types": "^0.3.6",
151
+ "pkg-types": "^1.0.1",
152
152
  "pretty-format": "^27.5.1",
153
153
  "prompts": "^2.4.2",
154
154
  "rollup": "^2.79.1",
155
155
  "strip-ansi": "^7.0.1",
156
156
  "typescript": "^4.8.4",
157
- "vite-node": "0.25.4",
157
+ "vite-node": "0.25.6",
158
158
  "ws": "^8.11.0"
159
159
  },
160
160
  "scripts": {