vitest 4.0.0-beta.4 → 4.0.0-beta.5

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.
Files changed (71) hide show
  1. package/dist/browser.d.ts +8 -9
  2. package/dist/browser.js +3 -2
  3. package/dist/chunks/base.DMfOuRWD.js +48 -0
  4. package/dist/chunks/{benchmark.CYdenmiT.js → benchmark.CtuRzf-i.js} +4 -1
  5. package/dist/chunks/{browser.d.BRP8scJf.d.ts → browser.d.Cawq_X_N.d.ts} +1 -1
  6. package/dist/chunks/{cac.CY0IAxC4.js → cac.CKnbxhn2.js} +8 -9
  7. package/dist/chunks/{cli-api.B8xRY9Zt.js → cli-api.COn58yrl.js} +540 -342
  8. package/dist/chunks/{config.d.DZo8c7fw.d.ts → config.d.CKNVOKm0.d.ts} +3 -8
  9. package/dist/chunks/{console.DoJHFxmj.js → console.Duv2dVIC.js} +1 -1
  10. package/dist/chunks/{constants.CXzqaLmq.js → constants.D_Q9UYh-.js} +1 -6
  11. package/dist/chunks/{coverage.C84l9G-M.js → coverage.B6cReEn1.js} +232 -133
  12. package/dist/chunks/{coverage.DVF1vEu8.js → coverage.D_JHT54q.js} +2 -2
  13. package/dist/chunks/{coverage.d.CNYjU4GF.d.ts → coverage.d.BZtK59WP.d.ts} +7 -5
  14. package/dist/chunks/{creator.yfA2ExGt.js → creator.DUVZ6rfm.js} +1 -1
  15. package/dist/chunks/{environment.d.Bhm9oc0v.d.ts → environment.d.2fYMoz3o.d.ts} +26 -4
  16. package/dist/chunks/{global.d.DAhT2emn.d.ts → global.d.K6uBQHzY.d.ts} +1 -1
  17. package/dist/chunks/{globals.Dgo-vS5G.js → globals.CJQ63oO0.js} +6 -5
  18. package/dist/chunks/{index.CmSc2RE5.js → index.BRtIe7r8.js} +4 -4
  19. package/dist/chunks/{index.Bz6b0Ib7.js → index.DQhAfQQU.js} +12 -4
  20. package/dist/chunks/{index.D3SKT3tv.js → index.DgN0Zk9a.js} +1 -1
  21. package/dist/chunks/{index.D1_MsKEt.js → index.QZr3S3vQ.js} +4 -2
  22. package/dist/chunks/{index.CtUvr1c8.js → index.oWRWx-nj.js} +18 -18
  23. package/dist/chunks/moduleRunner.d.mmOmOGrW.d.ts +202 -0
  24. package/dist/chunks/moduleTransport.I-bgQy0S.js +19 -0
  25. package/dist/chunks/{node.fjCdwEIl.js → node.4JV5OXkt.js} +1 -1
  26. package/dist/chunks/{plugin.d.CLhMcYdD.d.ts → plugin.d.CvOlgjxK.d.ts} +1 -1
  27. package/dist/chunks/{reporters.d.DWg40D2B.d.ts → reporters.d.CYE9sT5z.d.ts} +37 -69
  28. package/dist/chunks/resolver.D5bG4zy5.js +162 -0
  29. package/dist/chunks/{rpc.jnQO9F8a.js → rpc.DGoW_Vl-.js} +1 -1
  30. package/dist/chunks/{runBaseTests.DBVVLMSb.js → runBaseTests.B3KcKqlF.js} +22 -23
  31. package/dist/chunks/{setup-common.Ebx5x0eP.js → setup-common.lgPs-bYv.js} +11 -10
  32. package/dist/chunks/{execute.Dt-pCVcL.js → startModuleRunner.C8FtT_BY.js} +381 -312
  33. package/dist/chunks/{typechecker.CMNPqJOo.js → typechecker.BgoW4nTA.js} +1 -1
  34. package/dist/chunks/{utils.XdZDrNZV.js → utils.B9FY3b73.js} +7 -8
  35. package/dist/chunks/{vi.CA0EPI9Y.js → vi.DGAfBY4R.js} +12 -8
  36. package/dist/chunks/{vm.BUnLJt_P.js → vm.BKfKvaKl.js} +36 -56
  37. package/dist/chunks/{worker.d.zjyR34Pb.d.ts → worker.d.D9QWnzAe.d.ts} +16 -13
  38. package/dist/chunks/{worker.d.C-1AbnVe.d.ts → worker.d.Db-UVmXc.d.ts} +1 -1
  39. package/dist/cli.js +4 -4
  40. package/dist/config.cjs +3 -9
  41. package/dist/config.d.ts +10 -12
  42. package/dist/config.js +1 -1
  43. package/dist/coverage.d.ts +10 -11
  44. package/dist/coverage.js +5 -6
  45. package/dist/environments.d.ts +2 -2
  46. package/dist/environments.js +1 -1
  47. package/dist/index.d.ts +10 -9
  48. package/dist/index.js +5 -4
  49. package/dist/module-evaluator.d.ts +12 -0
  50. package/dist/module-evaluator.js +327 -0
  51. package/dist/module-runner.js +15 -0
  52. package/dist/node.d.ts +12 -13
  53. package/dist/node.js +15 -14
  54. package/dist/reporters.d.ts +7 -8
  55. package/dist/reporters.js +3 -3
  56. package/dist/runners.d.ts +3 -3
  57. package/dist/runners.js +16 -10
  58. package/dist/snapshot.js +2 -2
  59. package/dist/suite.js +2 -2
  60. package/dist/worker.js +84 -31
  61. package/dist/workers/forks.js +10 -9
  62. package/dist/workers/runVmTests.js +16 -17
  63. package/dist/workers/threads.js +10 -9
  64. package/dist/workers/vmForks.js +9 -8
  65. package/dist/workers/vmThreads.js +9 -8
  66. package/dist/workers.d.ts +5 -4
  67. package/dist/workers.js +14 -13
  68. package/package.json +21 -16
  69. package/dist/chunks/base.BaCDDRPG.js +0 -38
  70. package/dist/execute.d.ts +0 -148
  71. package/dist/execute.js +0 -13
@@ -374,7 +374,7 @@ base.MethodDefinition = base.PropertyDefinition = base.Property = function (node
374
374
  };
375
375
 
376
376
  async function collectTests(ctx, filepath) {
377
- const request = await ctx.vitenode.transformRequest(filepath, filepath);
377
+ const request = await ctx.vite.environments.ssr.transformRequest(filepath);
378
378
  if (!request) return null;
379
379
  const ast = await parseAstAsync(request.code);
380
380
  const testFilepath = relative(ctx.config.root, filepath);
@@ -34,14 +34,16 @@ function setProcessTitle(title) {
34
34
  function resetModules(modules, resetMocks = false) {
35
35
  const skipPaths = [
36
36
  /\/vitest\/dist\//,
37
- /\/vite-node\/dist\//,
38
37
  /vitest-virtual-\w+\/dist/,
39
38
  /@vitest\/dist/,
40
39
  ...!resetMocks ? [/^mock:/] : []
41
40
  ];
42
- modules.forEach((mod, path) => {
41
+ modules.idToModuleMap.forEach((node, path) => {
43
42
  if (skipPaths.some((re) => re.test(path))) return;
44
- modules.invalidateModule(mod);
43
+ node.promise = void 0;
44
+ node.exports = void 0;
45
+ node.evaluated = false;
46
+ node.importers.clear();
45
47
  });
46
48
  }
47
49
  function waitNextTick() {
@@ -52,11 +54,8 @@ async function waitForImportsToResolve() {
52
54
  await waitNextTick();
53
55
  const state = getWorkerState();
54
56
  const promises = [];
55
- let resolvingCount = 0;
56
- for (const mod of state.moduleCache.values()) {
57
- if (mod.promise && !mod.evaluated) promises.push(mod.promise);
58
- if (mod.resolving) resolvingCount++;
59
- }
57
+ const resolvingCount = state.resolvingModules.size;
58
+ for (const [_, mod] of state.evaluatedModules.idToModuleMap) if (mod.promise && !mod.evaluated) promises.push(mod.promise);
60
59
  if (!promises.length && !resolvingCount) return;
61
60
  await Promise.allSettled(promises);
62
61
  await waitForImportsToResolve();
@@ -2,7 +2,7 @@ import { equals, iterableEquality, subsetEquality, JestExtend, JestChaiExpect, J
2
2
  import { getCurrentTest } from '@vitest/runner';
3
3
  import { getNames, getTestName } from '@vitest/runner/utils';
4
4
  import * as chai$1 from 'chai';
5
- import { g as getWorkerState, a as getCurrentEnvironment, i as isChildProcess, w as waitForImportsToResolve, r as resetModules } from './utils.XdZDrNZV.js';
5
+ import { g as getWorkerState, a as getCurrentEnvironment, i as isChildProcess, w as waitForImportsToResolve, r as resetModules } from './utils.B9FY3b73.js';
6
6
  import { getSafeTimers, assertTypes, createSimpleStackTrace } from '@vitest/utils';
7
7
  import { g as getDefaultExportFromCjs, c as commonjsGlobal } from './_commonjsHelpers.BFTU3MAI.js';
8
8
  import { stripSnapshotIndentation, addSerializer, SnapshotClient } from '@vitest/snapshot';
@@ -3954,10 +3954,12 @@ function createVitest() {
3954
3954
  return utils;
3955
3955
  },
3956
3956
  stubEnv(name, value) {
3957
- if (!_stubsEnv.has(name)) _stubsEnv.set(name, process.env[name]);
3958
- if (_envBooleans.includes(name)) process.env[name] = value ? "1" : "";
3959
- else if (value === void 0) delete process.env[name];
3960
- else process.env[name] = String(value);
3957
+ const state = getWorkerState();
3958
+ const env = state.metaEnv;
3959
+ if (!_stubsEnv.has(name)) _stubsEnv.set(name, env[name]);
3960
+ if (_envBooleans.includes(name)) env[name] = value ? "1" : "";
3961
+ else if (value === void 0) delete env[name];
3962
+ else env[name] = String(value);
3961
3963
  return utils;
3962
3964
  },
3963
3965
  unstubAllGlobals() {
@@ -3969,15 +3971,17 @@ function createVitest() {
3969
3971
  return utils;
3970
3972
  },
3971
3973
  unstubAllEnvs() {
3974
+ const state = getWorkerState();
3975
+ const env = state.metaEnv;
3972
3976
  _stubsEnv.forEach((original, name) => {
3973
- if (original === void 0) delete process.env[name];
3974
- else process.env[name] = original;
3977
+ if (original === void 0) delete env[name];
3978
+ else env[name] = original;
3975
3979
  });
3976
3980
  _stubsEnv.clear();
3977
3981
  return utils;
3978
3982
  },
3979
3983
  resetModules() {
3980
- resetModules(workerState.moduleCache);
3984
+ resetModules(workerState.evaluatedModules);
3981
3985
  return utils;
3982
3986
  },
3983
3987
  async dynamicImportSettled() {
@@ -1,15 +1,16 @@
1
1
  import { fileURLToPath, pathToFileURL } from 'node:url';
2
2
  import vm, { isContext } from 'node:vm';
3
- import { dirname, basename, extname, normalize, join, resolve } from 'pathe';
3
+ import { dirname, basename, extname, normalize, resolve } from 'pathe';
4
4
  import { distDir } from '../path.js';
5
- import { createCustomConsole } from './console.DoJHFxmj.js';
6
- import { g as getDefaultRequestStubs, s as startVitestExecutor } from './execute.Dt-pCVcL.js';
5
+ import { createCustomConsole } from './console.Duv2dVIC.js';
7
6
  import fs from 'node:fs';
7
+ import { createRequire, Module, isBuiltin } from 'node:module';
8
+ import { CSS_LANGS_RE, KNOWN_ASSET_RE, toArray, isBareImport } from '@vitest/utils';
9
+ import { f as findNearestPackageData } from './resolver.D5bG4zy5.js';
8
10
  import { dirname as dirname$1 } from 'node:path';
9
- import { isPrimitive, isNodeBuiltin, toArray, getCachedData, setCacheData, isBareImport } from 'vite-node/utils';
10
- import { createRequire, Module } from 'node:module';
11
- import { CSS_LANGS_RE, KNOWN_ASSET_RE } from 'vite-node/constants';
12
- import { p as provideWorkerState } from './utils.XdZDrNZV.js';
11
+ import { getDefaultRequestStubs } from '../module-evaluator.js';
12
+ import { s as startVitestModuleRunner, a as VITEST_VM_CONTEXT_SYMBOL } from './startModuleRunner.C8FtT_BY.js';
13
+ import { p as provideWorkerState } from './utils.B9FY3b73.js';
13
14
 
14
15
  function interopCommonJsModule(interopDefault, mod) {
15
16
  if (isPrimitive(mod) || Array.isArray(mod) || mod instanceof Promise) return {
@@ -36,6 +37,10 @@ function interopCommonJsModule(interopDefault, mod) {
36
37
  defaultExport: mod
37
38
  };
38
39
  }
40
+ function isPrimitive(obj) {
41
+ const isObject = obj != null && (typeof obj === "object" || typeof obj === "function");
42
+ return !isObject;
43
+ }
39
44
  const SyntheticModule = vm.SyntheticModule;
40
45
  const SourceTextModule = vm.SourceTextModule;
41
46
 
@@ -174,7 +179,7 @@ class CommonjsExecutor {
174
179
  const require = (id) => {
175
180
  const resolved = _require.resolve(id);
176
181
  const ext = extname(resolved);
177
- if (ext === ".node" || isNodeBuiltin(resolved)) return this.requireCoreModule(resolved);
182
+ if (ext === ".node" || isBuiltin(resolved)) return this.requireCoreModule(resolved);
178
183
  const module = new this.Module(resolved);
179
184
  return this.loadCommonJSModule(module, resolved);
180
185
  };
@@ -294,7 +299,7 @@ class CommonjsExecutor {
294
299
  // }
295
300
  require(identifier) {
296
301
  const ext = extname(identifier);
297
- if (ext === ".node" || isNodeBuiltin(identifier)) return this.requireCoreModule(identifier);
302
+ if (ext === ".node" || isBuiltin(identifier)) return this.requireCoreModule(identifier);
298
303
  const module = new this.Module(identifier);
299
304
  return this.loadCommonJSModule(module, identifier);
300
305
  }
@@ -464,30 +469,19 @@ class ViteExecutor {
464
469
  this.options = options;
465
470
  this.esm = options.esmExecutor;
466
471
  }
467
- resolve = (identifier, parent) => {
468
- if (identifier === CLIENT_ID) {
469
- if (this.workerState.environment.transformMode === "web") return identifier;
470
- const packageName = this.getPackageName(parent);
471
- throw new Error(`[vitest] Vitest cannot handle ${CLIENT_ID} imported in ${parent} when running in SSR environment. Add "${packageName}" to "ssr.noExternal" if you are using Vite SSR, or to "server.deps.inline" if you are using Vite Node.`);
472
- }
472
+ resolve = (identifier) => {
473
+ if (identifier === CLIENT_ID) return identifier;
473
474
  };
474
475
  get workerState() {
475
476
  return this.options.context.__vitest_worker__;
476
477
  }
477
- getPackageName(modulePath) {
478
- const path = normalize(modulePath);
479
- let name = path.split("/node_modules/").pop() || "";
480
- if (name?.startsWith("@")) name = name.split("/").slice(0, 2).join("/");
481
- else name = name.split("/")[0];
482
- return name;
483
- }
484
478
  async createViteModule(fileUrl) {
485
- if (fileUrl === CLIENT_FILE) return this.createViteClientModule();
479
+ if (fileUrl === CLIENT_FILE || fileUrl === CLIENT_ID) return this.createViteClientModule();
486
480
  const cached = this.esm.resolveCachedModule(fileUrl);
487
481
  if (cached) return cached;
488
482
  return this.esm.createEsModule(fileUrl, async () => {
489
483
  try {
490
- const result = await this.options.transform(fileUrl, "web");
484
+ const result = await this.options.transform(fileUrl);
491
485
  if (result.code) return result.code;
492
486
  } catch (cause) {
493
487
  // rethrow vite error if it cannot load the module because it's not resolved
@@ -518,8 +512,6 @@ class ViteExecutor {
518
512
  return module;
519
513
  }
520
514
  canResolve = (fileUrl) => {
521
- const transformMode = this.workerState.environment.transformMode;
522
- if (transformMode !== "web") return false;
523
515
  if (fileUrl === CLIENT_FILE) return true;
524
516
  const config = this.workerState.config.deps?.web || {};
525
517
  const [modulePath] = fileUrl.split("?");
@@ -530,7 +522,7 @@ class ViteExecutor {
530
522
  };
531
523
  }
532
524
 
533
- const { existsSync, statSync } = fs;
525
+ const { existsSync } = fs;
534
526
  // always defined when we use vm pool
535
527
  const nativeResolve = import.meta.resolve;
536
528
  // TODO: improve Node.js strict mode support in #2854
@@ -590,26 +582,6 @@ class ExternalModulesExecutor {
590
582
  // import.meta.resolve can be asynchronous in older +18 Node versions
591
583
  return nativeResolve(specifier, parent);
592
584
  }
593
- findNearestPackageData(basedir) {
594
- const originalBasedir = basedir;
595
- const packageCache = this.options.packageCache;
596
- while (basedir) {
597
- const cached = getCachedData(packageCache, basedir, originalBasedir);
598
- if (cached) return cached;
599
- const pkgPath = join(basedir, "package.json");
600
- try {
601
- if (statSync(pkgPath, { throwIfNoEntry: false })?.isFile()) {
602
- const pkgData = JSON.parse(this.fs.readFile(pkgPath));
603
- if (packageCache) setCacheData(packageCache, pkgData, basedir, originalBasedir);
604
- return pkgData;
605
- }
606
- } catch {}
607
- const nextBasedir = dirname$1(basedir);
608
- if (nextBasedir === basedir) break;
609
- basedir = nextBasedir;
610
- }
611
- return {};
612
- }
613
585
  getModuleInformation(identifier) {
614
586
  if (identifier.startsWith("data:")) return {
615
587
  type: "data",
@@ -617,7 +589,7 @@ class ExternalModulesExecutor {
617
589
  path: identifier
618
590
  };
619
591
  const extension = extname(identifier);
620
- if (extension === ".node" || isNodeBuiltin(identifier)) return {
592
+ if (extension === ".node" || isBuiltin(identifier)) return {
621
593
  type: "builtin",
622
594
  url: identifier,
623
595
  path: identifier
@@ -639,7 +611,7 @@ class ExternalModulesExecutor {
639
611
  // cf. ESM_FILE_FORMAT(url) in https://nodejs.org/docs/latest-v20.x/api/esm.html#resolution-algorithm
640
612
  type = "wasm";
641
613
  else {
642
- const pkgData = this.findNearestPackageData(normalize(pathUrl));
614
+ const pkgData = findNearestPackageData(normalize(pathUrl));
643
615
  type = pkgData.type === "module" ? "module" : "commonjs";
644
616
  }
645
617
  return {
@@ -740,21 +712,29 @@ async function runVmTests(method, state) {
740
712
  transform: rpc.transform,
741
713
  viteClientModule: stubs["/@vite/client"]
742
714
  });
743
- const executor = await startVitestExecutor({
715
+ const moduleRunner = await startVitestModuleRunner({
744
716
  context,
745
- moduleCache: state.moduleCache,
717
+ evaluatedModules: state.evaluatedModules,
746
718
  state,
747
- externalModulesExecutor,
748
- requestStubs: stubs
719
+ externalModulesExecutor
720
+ });
721
+ Object.defineProperty(context, VITEST_VM_CONTEXT_SYMBOL, {
722
+ value: {
723
+ context,
724
+ externalModulesExecutor
725
+ },
726
+ configurable: true,
727
+ enumerable: false,
728
+ writable: false
749
729
  });
750
- context.__vitest_mocker__ = executor.mocker;
751
- const { run } = await executor.importExternalModule(entryFile);
730
+ context.__vitest_mocker__ = moduleRunner.mocker;
731
+ const { run } = await moduleRunner.import(entryFile);
752
732
  const fileSpecs = ctx.files.map((f) => typeof f === "string" ? {
753
733
  filepath: f,
754
734
  testLocations: void 0
755
735
  } : f);
756
736
  try {
757
- await run(method, fileSpecs, ctx.config, executor);
737
+ await run(method, fileSpecs, ctx.config, moduleRunner);
758
738
  } finally {
759
739
  await vm.teardown?.();
760
740
  state.environmentTeardownRun = true;
@@ -1,6 +1,7 @@
1
1
  import { CancelReason, File, TestAnnotation, TaskResultPack, TaskEventPack, FileSpecification, Task } from '@vitest/runner';
2
- import { a as SerializedConfig } from './config.d.DZo8c7fw.js';
3
- import { T as TransformMode, U as UserConsoleLog, A as AfterSuiteRunMeta, E as Environment } from './environment.d.Bhm9oc0v.js';
2
+ import { FetchFunctionOptions, FetchResult, EvaluatedModules } from 'vite/module-runner';
3
+ import { a as SerializedConfig } from './config.d.CKNVOKm0.js';
4
+ import { F as FetchCachedFileSystemResult, R as ResolveFunctionResult, U as UserConsoleLog, A as AfterSuiteRunMeta, E as Environment } from './environment.d.2fYMoz3o.js';
4
5
  import { SnapshotResult } from '@vitest/snapshot';
5
6
 
6
7
  type ArgumentsType<T> = T extends (...args: infer A) => any ? A : never;
@@ -104,17 +105,11 @@ interface PromiseEntry {
104
105
  declare const setTimeout: typeof globalThis.setTimeout;
105
106
 
106
107
  interface RuntimeRPC {
107
- fetch: (id: string, transformMode: TransformMode) => Promise<{
108
- externalize?: string;
109
- id?: string;
110
- }>;
111
- transform: (id: string, transformMode: TransformMode) => Promise<{
108
+ fetch: (id: string, importer: string | undefined, environment: string, options?: FetchFunctionOptions) => Promise<FetchResult | FetchCachedFileSystemResult>;
109
+ resolve: (id: string, importer: string | undefined, environment: string) => Promise<ResolveFunctionResult | null>;
110
+ transform: (id: string) => Promise<{
112
111
  code?: string;
113
112
  }>;
114
- resolveId: (id: string, importer: string | undefined, transformMode: TransformMode) => Promise<{
115
- external?: boolean | "absolute" | "relative";
116
- id: string;
117
- } | null>;
118
113
  onUserConsoleLog: (log: UserConsoleLog) => void;
119
114
  onUnhandledError: (err: unknown, type: string) => void;
120
115
  onQueued: (file: File) => void;
@@ -134,7 +129,6 @@ interface RunnerRPC {
134
129
  type WorkerRPC = BirpcReturn<RuntimeRPC, RunnerRPC>;
135
130
  interface ContextTestEnvironment {
136
131
  name: string;
137
- transformMode?: TransformMode;
138
132
  options: Record<string, any> | null;
139
133
  }
140
134
  type TestExecutionMethod = "run" | "collect";
@@ -155,10 +149,19 @@ interface WorkerGlobalState {
155
149
  rpc: WorkerRPC;
156
150
  current?: Task;
157
151
  filepath?: string;
152
+ metaEnv: {
153
+ [key: string]: any;
154
+ BASE_URL: string;
155
+ MODE: string;
156
+ DEV: boolean;
157
+ PROD: boolean;
158
+ SSR: boolean;
159
+ };
158
160
  environment: Environment;
159
161
  environmentTeardownRun?: boolean;
160
162
  onCancel: Promise<CancelReason>;
161
- moduleCache: Map<string, any>;
163
+ evaluatedModules: EvaluatedModules;
164
+ resolvingModules: Set<string>;
162
165
  moduleExecutionInfo: Map<string, any>;
163
166
  onCleanup: (listener: () => unknown) => void;
164
167
  providedContext: Record<string, any>;
@@ -1,5 +1,5 @@
1
1
  import { MessagePort } from 'node:worker_threads';
2
- import { C as ContextRPC } from './worker.d.zjyR34Pb.js';
2
+ import { C as ContextRPC } from './worker.d.D9QWnzAe.js';
3
3
 
4
4
  interface WorkerContext extends ContextRPC {
5
5
  port: MessagePort;
package/dist/cli.js CHANGED
@@ -1,13 +1,13 @@
1
- import { c as createCLI } from './chunks/cac.CY0IAxC4.js';
1
+ import { c as createCLI } from './chunks/cac.CKnbxhn2.js';
2
2
  import '@vitest/utils';
3
3
  import 'events';
4
4
  import 'pathe';
5
5
  import 'tinyrainbow';
6
- import './chunks/constants.CXzqaLmq.js';
7
- import './chunks/index.Bz6b0Ib7.js';
6
+ import './chunks/constants.D_Q9UYh-.js';
7
+ import './chunks/index.DQhAfQQU.js';
8
8
  import 'node:fs';
9
9
  import 'node:fs/promises';
10
- import './chunks/typechecker.CMNPqJOo.js';
10
+ import './chunks/typechecker.BgoW4nTA.js';
11
11
  import 'node:os';
12
12
  import 'node:perf_hooks';
13
13
  import '@vitest/utils/source-map';
package/dist/config.cjs CHANGED
@@ -4,19 +4,14 @@ var os = require('node:os');
4
4
  var stdEnv = require('std-env');
5
5
  var vite = require('vite');
6
6
 
7
- // if changed, update also jsdocs and docs
8
- const defaultBrowserPort = 63315;
9
- const extraInlineDeps = [
10
- /^(?!.*node_modules).*\.mjs$/,
11
- /^(?!.*node_modules).*\.cjs\.js$/,
12
- /vite\w*\/dist\/client\/env.mjs/
13
- ];
14
-
15
7
  const isNode = typeof process < "u" && typeof process.stdout < "u" && !process.versions?.deno && !globalThis.window;
16
8
  const isDeno = typeof process < "u" && typeof process.stdout < "u" && process.versions?.deno !== void 0;
17
9
  (isNode || isDeno) && process.platform === "win32";
18
10
  (isNode || isDeno) && process.stdout?.isTTY && !stdEnv.isCI;
19
11
 
12
+ // if changed, update also jsdocs and docs
13
+ const defaultBrowserPort = 63315;
14
+
20
15
  const defaultInclude = ["**/*.{test,spec}.?(c|m)[jt]s?(x)"];
21
16
  const defaultExclude = ["**/node_modules/**", "**/.git/**"];
22
17
  // These are the generic defaults for coverage. Providers may also set some provider specific defaults.
@@ -98,4 +93,3 @@ exports.defaultExclude = defaultExclude;
98
93
  exports.defaultInclude = defaultInclude;
99
94
  exports.defineConfig = defineConfig;
100
95
  exports.defineProject = defineProject;
101
- exports.extraInlineDeps = extraInlineDeps;
package/dist/config.d.ts CHANGED
@@ -1,29 +1,28 @@
1
1
  import { HookHandler, ConfigEnv, UserConfig } from 'vite';
2
2
  export { ConfigEnv, Plugin, UserConfig as ViteUserConfig, mergeConfig } from 'vite';
3
- import { I as InlineConfig, c as CoverageV8Options, R as ResolvedCoverageOptions, U as UserWorkspaceConfig, d as UserProjectConfigFn, e as UserProjectConfigExport } from './chunks/reporters.d.DWg40D2B.js';
4
- export { a as TestProjectConfiguration, g as TestProjectInlineConfiguration, f as TestUserConfig, W as WatcherTriggerPattern } from './chunks/reporters.d.DWg40D2B.js';
5
- import { V as VitestPluginContext } from './chunks/plugin.d.CLhMcYdD.js';
6
- import { F as FakeTimerInstallOpts } from './chunks/config.d.DZo8c7fw.js';
3
+ import { I as InlineConfig, c as CoverageV8Options, R as ResolvedCoverageOptions, U as UserWorkspaceConfig, d as UserProjectConfigFn, e as UserProjectConfigExport } from './chunks/reporters.d.CYE9sT5z.js';
4
+ export { a as TestProjectConfiguration, g as TestProjectInlineConfiguration, f as TestUserConfig, W as WatcherTriggerPattern } from './chunks/reporters.d.CYE9sT5z.js';
5
+ import { V as VitestPluginContext } from './chunks/plugin.d.CvOlgjxK.js';
6
+ import { F as FakeTimerInstallOpts } from './chunks/config.d.CKNVOKm0.js';
7
7
  import '@vitest/runner';
8
- import './chunks/environment.d.Bhm9oc0v.js';
8
+ import './chunks/environment.d.2fYMoz3o.js';
9
9
  import '@vitest/utils';
10
10
  import 'node:stream';
11
11
  import 'node:console';
12
- import './chunks/browser.d.BRP8scJf.js';
13
- import './chunks/worker.d.zjyR34Pb.js';
12
+ import './chunks/browser.d.Cawq_X_N.js';
13
+ import './chunks/worker.d.D9QWnzAe.js';
14
+ import 'vite/module-runner';
14
15
  import '@vitest/snapshot';
15
16
  import '@vitest/mocker';
16
17
  import '@vitest/utils/source-map';
17
18
  import '@vitest/pretty-format';
18
19
  import '@vitest/utils/diff';
19
- import 'vite-node';
20
20
  import 'chai';
21
21
  import 'vitest/optional-types.js';
22
22
  import './chunks/benchmark.d.DAaHLpsq.js';
23
23
  import '@vitest/runner/utils';
24
24
  import 'tinybench';
25
- import './chunks/coverage.d.CNYjU4GF.js';
26
- import 'vite-node/client';
25
+ import './chunks/coverage.d.BZtK59WP.js';
27
26
  import '@vitest/snapshot/manager';
28
27
  import 'node:fs';
29
28
 
@@ -43,7 +42,6 @@ declare module "vite" {
43
42
  }
44
43
 
45
44
  declare const defaultBrowserPort = 63315;
46
- declare const extraInlineDeps: RegExp[];
47
45
 
48
46
  declare const defaultInclude: string[];
49
47
  declare const defaultExclude: string[];
@@ -102,5 +100,5 @@ declare function defineProject(config: Promise<UserWorkspaceConfig>): Promise<Us
102
100
  declare function defineProject(config: UserProjectConfigFn): UserProjectConfigFn;
103
101
  declare function defineProject(config: UserProjectConfigExport): UserProjectConfigExport;
104
102
 
105
- export { UserProjectConfigExport, UserProjectConfigFn, UserWorkspaceConfig, configDefaults, coverageConfigDefaults, defaultBrowserPort, defaultExclude, defaultInclude, defineConfig, defineProject, extraInlineDeps };
103
+ export { UserProjectConfigExport, UserProjectConfigFn, UserWorkspaceConfig, configDefaults, coverageConfigDefaults, defaultBrowserPort, defaultExclude, defaultInclude, defineConfig, defineProject };
106
104
  export type { ViteUserConfigExport, ViteUserConfigFn, ViteUserConfigFnObject, ViteUserConfigFnPromise };
package/dist/config.js CHANGED
@@ -1,6 +1,6 @@
1
- export { d as defaultBrowserPort, e as extraInlineDeps } from './chunks/constants.CXzqaLmq.js';
2
1
  export { c as configDefaults, a as coverageConfigDefaults, d as defaultExclude, b as defaultInclude } from './chunks/defaults.CXFFjsi8.js';
3
2
  export { mergeConfig } from 'vite';
3
+ export { d as defaultBrowserPort } from './chunks/constants.D_Q9UYh-.js';
4
4
  import 'node:os';
5
5
  import './chunks/env.D4Lgay0q.js';
6
6
  import 'std-env';
@@ -1,26 +1,25 @@
1
- import { R as ResolvedCoverageOptions, V as Vitest, C as CoverageMap, b as ReportContext } from './chunks/reporters.d.DWg40D2B.js';
1
+ import { R as ResolvedCoverageOptions, V as Vitest, C as CoverageMap, b as ReportContext } from './chunks/reporters.d.CYE9sT5z.js';
2
2
  import { TransformResult } from 'vite';
3
- import { A as AfterSuiteRunMeta } from './chunks/environment.d.Bhm9oc0v.js';
3
+ import { A as AfterSuiteRunMeta } from './chunks/environment.d.2fYMoz3o.js';
4
4
  import '@vitest/runner';
5
5
  import '@vitest/utils';
6
6
  import 'node:stream';
7
7
  import 'node:console';
8
- import './chunks/browser.d.BRP8scJf.js';
9
- import './chunks/worker.d.zjyR34Pb.js';
10
- import './chunks/config.d.DZo8c7fw.js';
8
+ import './chunks/browser.d.Cawq_X_N.js';
9
+ import './chunks/worker.d.D9QWnzAe.js';
10
+ import 'vite/module-runner';
11
+ import './chunks/config.d.CKNVOKm0.js';
11
12
  import '@vitest/pretty-format';
12
13
  import '@vitest/snapshot';
13
14
  import '@vitest/utils/diff';
14
15
  import '@vitest/mocker';
15
16
  import '@vitest/utils/source-map';
16
- import 'vite-node';
17
17
  import 'chai';
18
18
  import 'vitest/optional-types.js';
19
19
  import './chunks/benchmark.d.DAaHLpsq.js';
20
20
  import '@vitest/runner/utils';
21
21
  import 'tinybench';
22
- import './chunks/coverage.d.CNYjU4GF.js';
23
- import 'vite-node/client';
22
+ import './chunks/coverage.d.BZtK59WP.js';
24
23
  import '@vitest/snapshot/manager';
25
24
  import 'node:fs';
26
25
 
@@ -46,7 +45,7 @@ interface ResolvedThreshold {
46
45
  * "project-b": ...
47
46
  * ```
48
47
  */
49
- type CoverageFiles = Map<NonNullable<AfterSuiteRunMeta["projectName"]> | symbol, Record<AfterSuiteRunMeta["transformMode"], {
48
+ type CoverageFiles = Map<NonNullable<AfterSuiteRunMeta["projectName"]> | symbol, Record<AfterSuiteRunMeta["environment"], {
50
49
  [TestFilenames: string]: string;
51
50
  }>>;
52
51
  declare class BaseCoverageProvider<Options extends ResolvedCoverageOptions<"istanbul" | "v8">> {
@@ -75,12 +74,12 @@ declare class BaseCoverageProvider<Options extends ResolvedCoverageOptions<"ista
75
74
  }>;
76
75
  resolveOptions(): Options;
77
76
  clean(clean?: boolean): Promise<void>;
78
- onAfterSuiteRun({ coverage, transformMode, projectName, testFiles }: AfterSuiteRunMeta): void;
77
+ onAfterSuiteRun({ coverage, environment, projectName, testFiles }: AfterSuiteRunMeta): void;
79
78
  readCoverageFiles<CoverageType>({ onFileRead, onFinished, onDebug }: {
80
79
  /** Callback invoked with a single coverage result */
81
80
  onFileRead: (data: CoverageType) => void;
82
81
  /** Callback invoked once all results of a project for specific transform mode are read */
83
- onFinished: (project: Vitest["projects"][number], transformMode: AfterSuiteRunMeta["transformMode"]) => Promise<void>;
82
+ onFinished: (project: Vitest["projects"][number], environment: string) => Promise<void>;
84
83
  onDebug: ((...logs: any[]) => void) & {
85
84
  enabled: boolean;
86
85
  };
package/dist/coverage.js CHANGED
@@ -1,17 +1,16 @@
1
- export { B as BaseCoverageProvider } from './chunks/coverage.C84l9G-M.js';
1
+ export { B as BaseCoverageProvider } from './chunks/coverage.B6cReEn1.js';
2
2
  import 'node:fs';
3
3
  import 'node:path';
4
+ import '@vitest/utils';
4
5
  import 'pathe';
5
6
  import 'picomatch';
6
7
  import 'tinyglobby';
7
8
  import 'tinyrainbow';
8
- import 'vite-node/utils';
9
9
  import './chunks/defaults.CXFFjsi8.js';
10
10
  import 'node:os';
11
11
  import './chunks/env.D4Lgay0q.js';
12
12
  import 'std-env';
13
13
  import 'node:crypto';
14
- import '@vitest/utils';
15
14
  import 'node:module';
16
15
  import 'node:process';
17
16
  import 'node:fs/promises';
@@ -20,16 +19,16 @@ import 'node:assert';
20
19
  import 'node:v8';
21
20
  import 'node:util';
22
21
  import 'vite';
23
- import './chunks/constants.CXzqaLmq.js';
22
+ import './chunks/constants.D_Q9UYh-.js';
24
23
  import 'node:tty';
25
24
  import 'node:events';
26
25
  import './chunks/index.Bgo3tNWt.js';
27
26
  import 'tinypool';
28
- import './chunks/typechecker.CMNPqJOo.js';
27
+ import './chunks/typechecker.BgoW4nTA.js';
29
28
  import 'node:perf_hooks';
30
29
  import '@vitest/utils/source-map';
31
30
  import 'tinyexec';
32
31
  import './path.js';
33
32
  import '@vitest/runner/utils';
34
33
  import 'node:worker_threads';
35
- import './chunks/coverage.DVF1vEu8.js';
34
+ import './chunks/coverage.D_JHT54q.js';
@@ -1,5 +1,5 @@
1
- import { E as Environment } from './chunks/environment.d.Bhm9oc0v.js';
2
- export { a as EnvironmentReturn, V as VmEnvironmentReturn } from './chunks/environment.d.Bhm9oc0v.js';
1
+ import { E as Environment } from './chunks/environment.d.2fYMoz3o.js';
2
+ export { a as EnvironmentReturn, V as VmEnvironmentReturn } from './chunks/environment.d.2fYMoz3o.js';
3
3
 
4
4
  declare const environments: {
5
5
  "node": Environment;
@@ -1,2 +1,2 @@
1
- export { e as builtinEnvironments, p as populateGlobal } from './chunks/index.CmSc2RE5.js';
1
+ export { e as builtinEnvironments, p as populateGlobal } from './chunks/index.BRtIe7r8.js';
2
2
  import 'node:console';
package/dist/index.d.ts CHANGED
@@ -1,14 +1,14 @@
1
- import { S as SerializedTestSpecification } from './chunks/browser.d.BRP8scJf.js';
2
- export { B as BrowserTesterOptions } from './chunks/browser.d.BRP8scJf.js';
3
- import './chunks/global.d.DAhT2emn.js';
1
+ import { S as SerializedTestSpecification } from './chunks/browser.d.Cawq_X_N.js';
2
+ export { B as BrowserTesterOptions } from './chunks/browser.d.Cawq_X_N.js';
3
+ import './chunks/global.d.K6uBQHzY.js';
4
4
  import { File, TestAnnotation, TaskResultPack, TaskEventPack, TaskPopulated } from '@vitest/runner';
5
5
  export { CancelReason, HookCleanupCallback, HookListener, ImportDuration, OnTestFailedHandler, OnTestFinishedHandler, RunMode, Task as RunnerTask, TaskBase as RunnerTaskBase, TaskEventPack as RunnerTaskEventPack, TaskResult as RunnerTaskResult, TaskResultPack as RunnerTaskResultPack, Test as RunnerTestCase, File as RunnerTestFile, Suite as RunnerTestSuite, SuiteAPI, SuiteCollector, SuiteFactory, TaskCustomOptions, TaskMeta, TaskState, TestAPI, TestAnnotation, TestContext, TestFunction, TestOptions, afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
6
- import { a as BirpcReturn } from './chunks/worker.d.zjyR34Pb.js';
7
- export { C as ContextRPC, c as ContextTestEnvironment, b as RunnerRPC, R as RuntimeRPC, T as TestExecutionMethod, W as WorkerGlobalState } from './chunks/worker.d.zjyR34Pb.js';
8
- import { a as SerializedConfig, F as FakeTimerInstallOpts, R as RuntimeOptions } from './chunks/config.d.DZo8c7fw.js';
9
- export { b as RuntimeConfig, S as SerializedCoverageConfig } from './chunks/config.d.DZo8c7fw.js';
10
- import { b as Awaitable, U as UserConsoleLog, L as LabelColor, M as ModuleGraphData, P as ProvidedContext } from './chunks/environment.d.Bhm9oc0v.js';
11
- export { A as AfterSuiteRunMeta } from './chunks/environment.d.Bhm9oc0v.js';
6
+ import { a as BirpcReturn } from './chunks/worker.d.D9QWnzAe.js';
7
+ export { C as ContextRPC, c as ContextTestEnvironment, b as RunnerRPC, R as RuntimeRPC, T as TestExecutionMethod, W as WorkerGlobalState } from './chunks/worker.d.D9QWnzAe.js';
8
+ import { a as SerializedConfig, F as FakeTimerInstallOpts, R as RuntimeOptions } from './chunks/config.d.CKNVOKm0.js';
9
+ export { b as RuntimeConfig, S as SerializedCoverageConfig } from './chunks/config.d.CKNVOKm0.js';
10
+ import { b as Awaitable, U as UserConsoleLog, L as LabelColor, M as ModuleGraphData, P as ProvidedContext } from './chunks/environment.d.2fYMoz3o.js';
11
+ export { A as AfterSuiteRunMeta } from './chunks/environment.d.2fYMoz3o.js';
12
12
  import { ExpectStatic } from '@vitest/expect';
13
13
  export { Assertion, AsymmetricMatchersContaining, DeeplyAllowMatchers, ExpectPollOptions, ExpectStatic, JestAssertion, Matchers } from '@vitest/expect';
14
14
  import { spyOn, fn, MaybeMockedDeep, MaybeMocked, MaybePartiallyMocked, MaybePartiallyMockedDeep, MockInstance } from '@vitest/spy';
@@ -20,6 +20,7 @@ export { ExpectTypeOf, expectTypeOf } from 'expect-type';
20
20
  export { SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotSerializer, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, UncheckedSnapshot } from '@vitest/snapshot';
21
21
  export { ParsedStack, SerializedError, TestError } from '@vitest/utils';
22
22
  export { DiffOptions } from '@vitest/utils/diff';
23
+ export { EvaluatedModules } from 'vite/module-runner';
23
24
  import * as chai from 'chai';
24
25
  export { chai };
25
26
  export { assert, should } from 'chai';
package/dist/index.js CHANGED
@@ -1,14 +1,15 @@
1
- export { c as createExpect, a as expect, i as inject, v as vi, b as vitest } from './chunks/vi.CA0EPI9Y.js';
2
- export { b as bench } from './chunks/benchmark.CYdenmiT.js';
3
- export { a as assertType } from './chunks/index.D1_MsKEt.js';
1
+ export { c as createExpect, a as expect, i as inject, v as vi, b as vitest } from './chunks/vi.DGAfBY4R.js';
2
+ export { b as bench } from './chunks/benchmark.CtuRzf-i.js';
3
+ export { a as assertType } from './chunks/index.QZr3S3vQ.js';
4
4
  export { expectTypeOf } from 'expect-type';
5
5
  export { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from '@vitest/runner';
6
+ export { EvaluatedModules } from 'vite/module-runner';
6
7
  import * as chai from 'chai';
7
8
  export { chai };
8
9
  export { assert, should } from 'chai';
9
10
  import '@vitest/expect';
10
11
  import '@vitest/runner/utils';
11
- import './chunks/utils.XdZDrNZV.js';
12
+ import './chunks/utils.B9FY3b73.js';
12
13
  import '@vitest/utils';
13
14
  import './chunks/_commonjsHelpers.BFTU3MAI.js';
14
15
  import '@vitest/snapshot';
@@ -0,0 +1,12 @@
1
+ import 'vite/module-runner';
2
+ export { b as VitestModuleEvaluator, a as VitestModuleEvaluatorOptions, c as createImportMetaEnvProxy, g as getDefaultRequestStubs, i as isPrimitive, u as unwrapId, w as wrapId } from './chunks/moduleRunner.d.mmOmOGrW.js';
3
+ import 'node:vm';
4
+ import './chunks/worker.d.D9QWnzAe.js';
5
+ import '@vitest/runner';
6
+ import './chunks/config.d.CKNVOKm0.js';
7
+ import '@vitest/pretty-format';
8
+ import '@vitest/snapshot';
9
+ import '@vitest/utils/diff';
10
+ import './chunks/environment.d.2fYMoz3o.js';
11
+ import '@vitest/mocker';
12
+ import './chunks/mocker.d.BE_2ls6u.js';