vitest 5.1.0 → 5.1.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.
Files changed (60) hide show
  1. package/dist/browser.d.ts +6 -5
  2. package/dist/browser.js +7 -7
  3. package/dist/chunks/{base.Cof-UHJf.js → base.C2su7_N0.js} +12 -12
  4. package/dist/chunks/{browser.d.C7tWgUvw.d.ts → browser.d.B-QwH_F6.d.ts} +3 -3
  5. package/dist/chunks/{cac.BYbt0aJp.js → cac.BK306qhQ.js} +15 -10
  6. package/dist/chunks/{cli-api.COfZo8lK.js → cli-api.D6E8EtSi.js} +317 -134
  7. package/dist/chunks/{config.d.B3YV4t0O.d.ts → config.d.BpJq6tRA.d.ts} +7 -1
  8. package/dist/chunks/{console.CQZ877Hi.js → console.VJUxd1rM.js} +2 -2
  9. package/dist/chunks/{creator.DHWmytIK.js → creator.CoOCr85O.js} +12 -10
  10. package/dist/chunks/{display.BlTmubjj.js → display.Cj2h2zsY.js} +1 -1
  11. package/dist/chunks/{doctor.B-oPbwps.js → doctor.SRjZIZuA.js} +1 -1
  12. package/dist/chunks/{environment.d.BFQtFKdZ.d.ts → environment.d.rlpAM-ON.d.ts} +1 -1
  13. package/dist/chunks/{globals.ZKtKSkEf.js → globals.Mxora3_v.js} +10 -10
  14. package/dist/chunks/{index.Bi0NXYPf.js → index.C7Nn66Gy.js} +21 -9
  15. package/dist/chunks/{index.DmDMHCg8.js → index.CAmut2NG.js} +25 -1
  16. package/dist/chunks/{index.CZzC1gGg.js → index.DNcttN5a.js} +31 -20
  17. package/dist/chunks/{index.w_oBZ9N8.js → index.Da_szXbS.js} +3 -3
  18. package/dist/chunks/{index.Di8au7q4.js → index.ER9afepi.js} +210 -88
  19. package/dist/chunks/{index.D0heQG4v.js → index.Or9psEGe.js} +1 -1
  20. package/dist/chunks/{init-forks.BaDXQSD8.js → init-forks.q4IoGYZe.js} +7 -1
  21. package/dist/chunks/{init-threads.ZX_Vov0z.js → init-threads.Bf1Frg9S.js} +1 -1
  22. package/dist/chunks/{init.CO4AB7HZ.js → init.dGO4K2C0.js} +16 -8
  23. package/dist/chunks/{inspector.CvyFGlXm.js → inspector.D6o1NPo1.js} +12 -1
  24. package/dist/chunks/{modules.BJuCwlRJ.js → moduleSourceMap.Dp1WduWi.js} +31 -1
  25. package/dist/chunks/{native.upB-V0CK.js → native.D5q1ylZC.js} +2 -1
  26. package/dist/chunks/{nativeModuleMocker.Dh5azSB4.js → nativeModuleMocker.ihb3q7Cg.js} +4 -2
  27. package/dist/chunks/{plugin.d.LRFSN46m.d.ts → plugin.d.Du7hHZwb.d.ts} +32 -29
  28. package/dist/chunks/{plugins.DPQHVT0p.js → plugins.BPruPOR8.js} +1 -1
  29. package/dist/chunks/{rawSnapshot.DqSiqIEx.js → rawSnapshot.DvoRLRNr.js} +2 -2
  30. package/dist/chunks/{rpc.Uhkwr2NM.js → rpc.CNYWPa97.js} +3 -19
  31. package/dist/chunks/{rpc.d.3FOhdFx8.d.ts → rpc.d.DHfuwqP0.d.ts} +2 -2
  32. package/dist/chunks/{run.CjdgFZiW.js → run.zBhXlcZQ.js} +113 -49
  33. package/dist/chunks/{setup-common.CqAQCXzx.js → setup-common.wwc_NYRJ.js} +3 -3
  34. package/dist/chunks/{source-map.DakdQc29.js → source-map.DPHGMWvM.js} +3 -1
  35. package/dist/chunks/{source-map.d.BkG8YK_3.d.ts → source-map.d.xB6_75fl.d.ts} +2 -1
  36. package/dist/chunks/{spy.DDMXghXv.js → spy.BO0hTE3G.js} +76 -53
  37. package/dist/chunks/{task-utils.d.D-gFPNFi.d.ts → task-utils.d.DgSjIb7r.d.ts} +1 -1
  38. package/dist/chunks/{utils.BBk_icFG.js → utils.sAsh2ClK.js} +2 -6
  39. package/dist/chunks/{vm.b4MbCAJQ.js → vm.agn4qnmT.js} +4 -4
  40. package/dist/chunks/{worker.d.CyJRpyfZ.d.ts → worker.d.BigfbIsH.d.ts} +3 -3
  41. package/dist/cli.js +1 -1
  42. package/dist/config.d.ts +8 -8
  43. package/dist/index.d.ts +10 -10
  44. package/dist/index.js +10 -10
  45. package/dist/module-evaluator.d.ts +3 -3
  46. package/dist/module-evaluator.js +1 -1
  47. package/dist/node.d.ts +11 -10
  48. package/dist/node.js +17 -15
  49. package/dist/runtime.d.ts +5 -4
  50. package/dist/runtime.js +5 -3
  51. package/dist/spy.js +1 -1
  52. package/dist/worker.d.ts +4 -4
  53. package/dist/worker.js +19 -18
  54. package/dist/workers/forks.js +20 -19
  55. package/dist/workers/runVmTests.js +14 -14
  56. package/dist/workers/threads.js +20 -19
  57. package/dist/workers/vmForks.js +14 -13
  58. package/dist/workers/vmThreads.js +14 -13
  59. package/dist/workers/watchdog.js +20 -0
  60. package/package.json +19 -19
@@ -8,23 +8,25 @@ import * as vite from 'vite';
8
8
  import { createServer, normalizePath, isFileLoadingAllowed, fetchModule, parseAst, searchForWorkspaceRoot, version, isRunnableDevEnvironment, mergeConfig, resolveConfig as resolveConfig$1 } from 'vite';
9
9
  import { a as defaultPort, c as configFiles, d as defaultBrowserPort, b as defaultInspectPort } from './constants.DLYM6cZY.js';
10
10
  import { c as configDefaults, e as benchmarkConfigDefaults } from './defaults.B1FCaFfh.js';
11
+ import { i as isInspectorOpen } from './inspector.D6o1NPo1.js';
11
12
  import { b as isWindows, i as isForceColor, a as isTTY } from './env.BKKtU2WC.js';
12
13
  import * as os from 'node:os';
13
14
  import os__default, { availableParallelism, homedir, tmpdir } from 'node:os';
14
- import crypto from 'node:crypto';
15
+ import crypto, { hash } from 'node:crypto';
15
16
  import { isBuiltin, builtinModules, createRequire } from 'node:module';
16
17
  import { rootDir, distDir } from '../path.js';
17
- import { i as isBuiltin$1, a as isBrowserExternal, t as toBuiltin } from './modules.BJuCwlRJ.js';
18
+ import { i as isBuiltin$1, a as isBrowserExternal, s as splitSourceMap, w as withInlineSourceMap, t as toBuiltin } from './moduleSourceMap.Dp1WduWi.js';
18
19
  import MagicString from 'magic-string';
19
20
  import { findMockRedirect, hoistMocksPlugin, automockPlugin } from '@vitest/mocker/node';
20
21
  import { Console } from 'node:console';
21
22
  import { Writable } from 'node:stream';
22
23
  import { stripVTControlCharacters } from 'node:util';
23
- import { i as inspect } from './display.BlTmubjj.js';
24
+ import { i as inspect } from './display.Cj2h2zsY.js';
25
+ import { execFile, fork } from 'node:child_process';
24
26
  import { performance as performance$1 } from 'node:perf_hooks';
25
- import { T as TraceMap, o as originalPositionFor, i as generatedPositionFor, j as eachMapping, k as stackIgnorePatterns, e as parseErrorStacktrace } from './source-map.DakdQc29.js';
27
+ import { T as TraceMap, o as originalPositionFor, i as generatedPositionFor, j as eachMapping, k as stackIgnorePatterns, e as parseErrorStacktrace } from './source-map.DPHGMWvM.js';
26
28
  import { x } from 'tinyexec';
27
- import { C as validateTags, A as limitConcurrency, D as shuffle } from './run.CjdgFZiW.js';
29
+ import { D as validateTags, B as limitConcurrency, E as shuffle } from './run.zBhXlcZQ.js';
28
30
  import { createDebug } from 'obug';
29
31
  import { createFileTask as createFileTask$1, createTaskName, calculateSuiteHash, convertTasksToEvents, hasFailed, generateFileHash } from '../task-utils.js';
30
32
  import { readFile, mkdir, writeFile, rm, stat } from 'node:fs/promises';
@@ -33,8 +35,9 @@ import * as esModuleLexer from 'es-module-lexer';
33
35
  import { ssrImportKey, ssrModuleExportsKey, ssrExportAllKey, ssrImportMetaKey, ModuleRunner } from 'vite/module-runner';
34
36
  import path, { resolve as resolve$1 } from 'node:path';
35
37
  import { p as positionToOffset, l as lineSplitRE } from './offset.Dy-5Fdfn.js';
36
- import { k as errorBanner, c as F_POINTER, l as divider, q as truncateString, w as withLabel, e as formatProjectName } from './utils.BBk_icFG.js';
38
+ import { j as errorBanner, c as F_POINTER, k as divider, o as truncateString, w as withLabel, e as formatProjectName } from './utils.sAsh2ClK.js';
37
39
  import { VitestModuleEvaluator } from '#module-evaluator';
40
+ import { V as VitestEvaluatedModules, c as createBirpc } from './index.CAmut2NG.js';
38
41
  import pm from 'picomatch';
39
42
  import { t as trackNativeImports, c as collectDependencies, n as nativeImports, g as getEvaluatedImports } from './module-dependencies._2Eei3FO.js';
40
43
  import { g as getCoverageFilesDirectory } from './coverage.jGCktcGP.js';
@@ -42,11 +45,9 @@ import { isAgent, isCI, provider } from 'std-env';
42
45
  import process$1 from 'node:process';
43
46
  import { isatty } from 'node:tty';
44
47
  import EventEmitter$1, { EventEmitter } from 'node:events';
45
- import { c as createBirpc } from './index.DmDMHCg8.js';
46
- import { fork } from 'node:child_process';
47
48
  import { Worker } from 'node:worker_threads';
48
- import { v as version$1 } from './cac.BYbt0aJp.js';
49
- import { g as getDefaultExportFromCjs } from './index.D0heQG4v.js';
49
+ import { v as version$1 } from './cac.BK306qhQ.js';
50
+ import { g as getDefaultExportFromCjs } from './index.Or9psEGe.js';
50
51
  import require$$0 from 'readline';
51
52
  import require$$0$1 from 'events';
52
53
 
@@ -637,8 +638,6 @@ function detectCodeBlock(content) {
637
638
  };
638
639
  }
639
640
 
640
- const hash = crypto.hash ?? ((algorithm, data, outputEncoding) => crypto.createHash(algorithm).update(data).digest(outputEncoding));
641
-
642
641
  class VitestResolver {
643
642
  options;
644
643
  externalizeConcurrentCache = /* @__PURE__ */ new Map();
@@ -959,10 +958,13 @@ class ModuleTransformService {
959
958
  if (moduleGraphModule.file) trace.setAttribute("code.file.path", moduleGraphModule.file);
960
959
  if (options?.cached && cached) return { cache: true };
961
960
  const externalize = await this.resolver.shouldExternalize(moduleGraphModule.id);
962
- if (externalize) return {
963
- externalize,
964
- type: "module"
965
- };
961
+ if (externalize) {
962
+ if (this.fsCacheEnabled) this.fsCache.recordManifestExternal(this.config, environment, moduleGraphModule.url, externalize);
963
+ return {
964
+ externalize,
965
+ type: "module"
966
+ };
967
+ }
966
968
  const cachePath = await this.getCachePath(environment, moduleGraphModule);
967
969
  // full fs caching is disabled, but we still want to keep tmp files if makeTmpCopies is enabled
968
970
  // this is primarily used by the forks pool to avoid using process.send(bigBuffer)
@@ -984,6 +986,7 @@ class ModuleTransformService {
984
986
  return result;
985
987
  });
986
988
  }
989
+ this.fsCache.recordManifestModule(this.config, environment, moduleGraphModule.url, cachePath);
987
990
  if (saveCachePromises.has(cachePath)) return saveCachePromises.get(cachePath).then((result) => {
988
991
  this.recordResult(trace, result);
989
992
  return result;
@@ -1074,10 +1077,11 @@ class ModuleTransformService {
1074
1077
  if (!cachedModule) return;
1075
1078
  const importedModules = await this.resolveCachedImports(environment, cachedModule);
1076
1079
  if (!importedModules) return;
1080
+ if (cachedModule.file) this.fsCache.watchFile(cachedModule.file);
1077
1081
  // Notify coverage provider that cached results were read
1078
1082
  if (cachedModule.hasCoverageData) this.fsCache.restoreCoverageData(environment, cachedModule.id, cachedModule.coverageData);
1079
1083
  // keep the module graph in sync
1080
- let map = extractSourceMap(cachedModule.code);
1084
+ let map = cachedModule.sourceMap ? parseSourceMap(cachedModule.sourceMap) : null;
1081
1085
  if (map && cachedModule.file) map.file = cachedModule.file;
1082
1086
  // mappings is a special source map identifier in rollup
1083
1087
  if (!map && cachedModule.mappings) map = { mappings: "" };
@@ -1090,7 +1094,8 @@ class ModuleTransformService {
1090
1094
  dynamicDeps: cachedModule.dynamicDeps,
1091
1095
  __vitestTmp: cachePath,
1092
1096
  __vitestModuleType: moduleType,
1093
- __vitestStaticMocks: cachedModule.staticMocks
1097
+ __vitestStaticMocks: cachedModule.staticMocks,
1098
+ __vitestSourceMap: cachedModule.sourceMap ?? null
1094
1099
  };
1095
1100
  // we populate the module graph to make the watch mode work because it relies on importers
1096
1101
  if (importer) {
@@ -1195,41 +1200,38 @@ function getSafeModulePaths(environment) {
1195
1200
  }
1196
1201
  let SOURCEMAPPING_URL = "sourceMa";
1197
1202
  SOURCEMAPPING_URL += "ppingURL";
1198
- const MODULE_RUNNER_SOURCEMAPPING_SOURCE = "//# sourceMappingSource=vite-generated";
1203
+ // the source map is sent next to the code, so V8 doesn't compile it with every module
1199
1204
  function processResultSource(environment, result) {
1200
1205
  if (!("code" in result)) return result;
1201
1206
  const node = environment.moduleGraph.getModuleById(result.id);
1202
- if (node?.transformResult)
1203
- // this also overrides node.transformResult.code which is also what the module
1204
- // runner does under the hood by default (we disable source maps inlining)
1205
- inlineSourceMap(node.transformResult);
1207
+ const sourceMap = node?.transformResult ? getSourceMap(node.transformResult) : void 0;
1206
1208
  return {
1207
1209
  ...result,
1208
- code: node?.transformResult?.code || result.code
1210
+ code: node?.transformResult?.code || result.code,
1211
+ sourceMap
1209
1212
  };
1210
1213
  }
1211
1214
  const OTHER_SOURCE_MAP_REGEXP = new RegExp(`//# ${SOURCEMAPPING_URL}=data:application/json[^,]+base64,([A-Za-z0-9+/=]+)$`, "gm");
1212
- // we have to inline the source map ourselves, because
1215
+ // we don't let Vite inline the source map, because
1213
1216
  // - we don't need //# sourceURL since we are running code in VM
1214
1217
  // - important in stack traces and the V8 coverage
1215
1218
  // - we need to inject an empty line for --inspect-brk
1216
- function inlineSourceMap(result) {
1219
+ function getSourceMap(result) {
1220
+ if (result.__vitestSourceMap !== void 0) return result.__vitestSourceMap ?? void 0;
1217
1221
  const map = result.map;
1218
- let code = result.code;
1219
- if (!map || !("version" in map) || code.includes(MODULE_RUNNER_SOURCEMAPPING_SOURCE)) return result;
1220
- // to reduce the payload size, we only inline vite node source map, because it's also the only one we use
1222
+ if (!map || !("version" in map)) {
1223
+ result.__vitestSourceMap = null;
1224
+ return;
1225
+ }
1226
+ // to reduce the payload size, we only keep vite node source map, because it's also the only one we use
1221
1227
  OTHER_SOURCE_MAP_REGEXP.lastIndex = 0;
1222
- if (OTHER_SOURCE_MAP_REGEXP.test(code)) code = code.replace(OTHER_SOURCE_MAP_REGEXP, "");
1228
+ if (OTHER_SOURCE_MAP_REGEXP.test(result.code)) result.code = result.code.replace(OTHER_SOURCE_MAP_REGEXP, "");
1223
1229
  const sourceMap = { ...map };
1224
1230
  // If the first line is not present on source maps, add simple 1:1 mapping ([0,0,0,0], [1,0,0,0])
1225
1231
  // so that debuggers can be set to break on first line
1226
1232
  if (sourceMap.mappings[0] === ";") sourceMap.mappings = `AAAA,CAAA${sourceMap.mappings}`;
1227
- result.code = `${code.trimEnd()}\n${MODULE_RUNNER_SOURCEMAPPING_SOURCE}\n//# ${SOURCEMAPPING_URL}=${genSourceMapUrl(sourceMap)}\n`;
1228
- return result;
1229
- }
1230
- function genSourceMapUrl(map) {
1231
- if (typeof map !== "string") map = JSON.stringify(map);
1232
- return `data:application/json;base64,${Buffer.from(map).toString("base64")}`;
1233
+ result.__vitestSourceMap = JSON.stringify(sourceMap);
1234
+ return result.__vitestSourceMap;
1233
1235
  }
1234
1236
  function getCachedResult(result, tmp) {
1235
1237
  return {
@@ -1242,15 +1244,9 @@ function getCachedResult(result, tmp) {
1242
1244
  moduleType: result.moduleType
1243
1245
  };
1244
1246
  }
1245
- const MODULE_RUNNER_SOURCEMAPPING_REGEXP = new RegExp(`//# ${SOURCEMAPPING_URL}=data:application/json;base64,(.+)`);
1246
- function extractSourceMap(code) {
1247
- const pattern = `//# ${SOURCEMAPPING_URL}=data:application/json;base64,`;
1248
- const lastIndex = code.lastIndexOf(pattern);
1249
- if (lastIndex === -1) return null;
1250
- const mapString = MODULE_RUNNER_SOURCEMAPPING_REGEXP.exec(code.slice(lastIndex))?.[1];
1251
- if (!mapString) return null;
1252
- const sourceMap = JSON.parse(Buffer.from(mapString, "base64").toString("utf-8"));
1253
- // remove source map mapping added by "inlineSourceMap" to keep the original behaviour of transformRequest
1247
+ function parseSourceMap(map) {
1248
+ const sourceMap = JSON.parse(map);
1249
+ // remove source map mapping added by "getSourceMap" to keep the original behaviour of transformRequest
1254
1250
  if (sourceMap.mappings.startsWith("AAAA,CAAA;"))
1255
1251
  // 9 because we want to only remove "AAAA,CAAA", but keep ; at the start
1256
1252
  sourceMap.mappings = sourceMap.mappings.slice(9);
@@ -1292,6 +1288,26 @@ function isTestFunctionName(name) {
1292
1288
  function isVitestFunctionName(name) {
1293
1289
  return name === "describe" || name === "suite" || isTestFunctionName(name);
1294
1290
  }
1291
+ function isStringNode(node) {
1292
+ return node.type === "Literal" && typeof node.value === "string" || node.type === "TemplateLiteral" || node.type === "BinaryExpression" && node.operator === "+" && (isStringNode(node.left) || isStringNode(node.right));
1293
+ }
1294
+ function isNumberNode(node) {
1295
+ return node.type === "Literal" && typeof node.value === "number" || node.type === "UnaryExpression" && node.operator === "-" && isNumberNode(node.argument);
1296
+ }
1297
+ function isTaskNameNode(node) {
1298
+ switch (node.type) {
1299
+ case "Identifier":
1300
+ case "MemberExpression": return true;
1301
+ case "ConditionalExpression": return isTaskNameNode(node.consequent) && isTaskNameNode(node.alternate);
1302
+ case "LogicalExpression": return node.operator !== "&&" && isTaskNameNode(node.left) && isTaskNameNode(node.right);
1303
+ // an imported binding is transformed into `(0, __vite_ssr_import_0__.name)`
1304
+ case "SequenceExpression": {
1305
+ const [e0, e1] = node.expressions;
1306
+ return node.expressions.length === 2 && e0.type === "Literal" && e0.value === 0 && isTaskNameNode(e1);
1307
+ }
1308
+ default: return isStringNode(node) || isNumberNode(node);
1309
+ }
1310
+ }
1295
1311
  function astParseFile(filepath, code) {
1296
1312
  const ast = parseAst(code);
1297
1313
  if (verbose) verbose("Collecting", filepath, code);
@@ -1354,12 +1370,13 @@ function astParseFile(filepath, code) {
1354
1370
  if (callee.type === "CallExpression" || callee.type === "SequenceExpression" || callee.type === "TaggedTemplateExpression") start = callee.end;
1355
1371
  else start = node.start;
1356
1372
  const messageNode = node.arguments?.[0];
1357
- if (messageNode == null) {
1373
+ if (messageNode == null || !isTaskNameNode(messageNode)) {
1358
1374
  verbose?.(`Skipping node at ${node.start} because it doesn't have a name`);
1359
1375
  return;
1360
1376
  }
1361
1377
  let message;
1362
- if (messageNode?.type === "Literal" || messageNode?.type === "TemplateLiteral") message = code.slice(messageNode.start + 1, messageNode.end - 1);
1378
+ if (messageNode.type === "Literal" && typeof messageNode.value === "number") message = String(messageNode.value);
1379
+ else if (messageNode.type === "Literal" || messageNode.type === "TemplateLiteral") message = code.slice(messageNode.start + 1, messageNode.end - 1);
1363
1380
  else {
1364
1381
  message = code.slice(messageNode.start, messageNode.end);
1365
1382
  if (message.endsWith(".name")) message = message.slice(0, -5);
@@ -2841,6 +2858,8 @@ function stripLiteral(code, options) {
2841
2858
  return result;
2842
2859
  }
2843
2860
 
2861
+ // `=`, `||=`, `??=`, `+=`, etc., but not `==` or `===`
2862
+ const ASSIGNMENT_RE = /\s*(?:\*\*|<<|>>>?|&&|\|\||\?\?|[-+*/%&|^])?=(?!=)/y;
2844
2863
  // so people can reassign envs at runtime
2845
2864
  // import.meta.env.VITE_NAME = 'app' -> process.env.VITE_NAME = 'app'
2846
2865
  function MetaEnvReplacerPlugin() {
@@ -2850,11 +2869,17 @@ function MetaEnvReplacerPlugin() {
2850
2869
  transform(code, id) {
2851
2870
  if (!/\bimport\.meta\.env\b/.test(code)) return null;
2852
2871
  let s = null;
2853
- const envs = stripLiteral(code).matchAll(/\bimport\.meta\.env\b/g);
2872
+ const cleanCode = stripLiteral(code);
2873
+ const envs = cleanCode.matchAll(/\bimport\.meta\.env\b/g);
2854
2874
  for (const env of envs) {
2855
- s ||= new MagicString(code);
2856
2875
  const startIndex = env.index;
2857
2876
  const endIndex = startIndex + env[0].length;
2877
+ // `import.meta.env = ...` is left as is, since `Object.assign(...) = ...`
2878
+ // is not a valid assignment target. Reads and property writes like
2879
+ // `import.meta.env.FOO = 1` are still rewritten.
2880
+ ASSIGNMENT_RE.lastIndex = endIndex;
2881
+ if (ASSIGNMENT_RE.test(cleanCode)) continue;
2882
+ s ||= new MagicString(code);
2858
2883
  s.overwrite(startIndex, endIndex, `Object.assign(/* istanbul ignore next */ globalThis.__vitest_worker__?.metaEnv ?? import.meta.env)`);
2859
2884
  }
2860
2885
  if (s) return {
@@ -3078,8 +3103,9 @@ Possible solutions:
3078
3103
  return typesErrors;
3079
3104
  }
3080
3105
  async stop() {
3081
- this.process?.kill();
3106
+ const child = this.process;
3082
3107
  this.process = void 0;
3108
+ if (child) await killProcessTree(child);
3083
3109
  }
3084
3110
  async ensurePackageInstalled(ctx, checker) {
3085
3111
  if (checker !== "tsc" && checker !== "vue-tsc") return;
@@ -3247,6 +3273,24 @@ function findGeneratedPosition(traceMap, { line, column, source }) {
3247
3273
  column: null
3248
3274
  };
3249
3275
  }
3276
+ function killProcessTree(child) {
3277
+ // on Windows the checker runs behind a `cmd.exe` shim, and `kill()` stops only the shim
3278
+ if (process.platform !== "win32" || child.pid == null || child.exitCode != null) {
3279
+ child.kill();
3280
+ return Promise.resolve();
3281
+ }
3282
+ return new Promise((resolve) => {
3283
+ execFile("taskkill", [
3284
+ "/pid",
3285
+ String(child.pid),
3286
+ "/T",
3287
+ "/F"
3288
+ ], { windowsHide: true }, (error) => {
3289
+ if (error) child.kill();
3290
+ resolve();
3291
+ });
3292
+ });
3293
+ }
3250
3294
 
3251
3295
  // use Logger with custom Console to capture entire error printing
3252
3296
  function capturePrintError(error, ctx, options) {
@@ -3578,21 +3622,23 @@ class ServerModuleRunner extends ModuleRunner {
3578
3622
  constructor(environment, transformService, config) {
3579
3623
  super({
3580
3624
  hmr: false,
3625
+ evaluatedModules: new VitestEvaluatedModules(),
3581
3626
  transport: { async invoke(event) {
3582
3627
  if (event.type !== "custom") throw new Error(`Vitest Module Runner doesn't support Vite HMR events.`);
3583
3628
  const { name, data } = event.data;
3584
3629
  if (name === "getBuiltins") return await environment.hot.handleInvoke(event);
3585
3630
  if (name !== "fetchModule") return { error: /* @__PURE__ */ new Error(`Unknown method: ${name}. Expected "fetchModule".`) };
3586
3631
  try {
3587
- const result = await transformService.fetch(data[0], data[1], environment, false, data[2]);
3632
+ let result = await transformService.fetch(data[0], data[1], environment, false, data[2]);
3588
3633
  if ("tmp" in result) {
3589
- const code = await readFile(result.tmp, "utf-8");
3590
- return { result: {
3634
+ const { code, sourceMap } = splitSourceMap(await readFile(result.tmp, "utf-8"));
3635
+ result = {
3591
3636
  ...result,
3592
- code
3593
- } };
3637
+ code,
3638
+ sourceMap
3639
+ };
3594
3640
  }
3595
- return { result };
3641
+ return { result: config.inspector.openInMainProcess ? withInlineSourceMap(result) : result };
3596
3642
  } catch (error) {
3597
3643
  return { error };
3598
3644
  }
@@ -3872,7 +3918,7 @@ function processWildcard(dep, moduleDirectories) {
3872
3918
  if (typeof dep !== "string") return dep;
3873
3919
  if (typeof dep === "string" && dep.includes("*")) {
3874
3920
  const directories = (moduleDirectories || ["/node_modules/"]).map((r) => escapeRegExp(r));
3875
- return new RegExp(`(${directories.join("|")})${dep.replace(/\*/g, "[\\w/]+")}`);
3921
+ return new RegExp(`(${directories.join("|")})${escapeRegExp(dep).replaceAll("\\*", "[\\w/.-]+")}`);
3876
3922
  }
3877
3923
  return dep;
3878
3924
  }
@@ -4411,6 +4457,16 @@ function createBrowserPool(vitest) {
4411
4457
  isCancelled = true;
4412
4458
  cancel();
4413
4459
  });
4460
+ // an invalidated module keeps its url, so a browser context that cached it
4461
+ // in an earlier run would serve the old code
4462
+ if (vitest._browserCacheStale) {
4463
+ vitest._browserCacheStale = false;
4464
+ // runs don't overlap (`runFiles` waits for the previous one), so no worker should be
4465
+ // active here; the check only keeps a running worker from being stopped
4466
+ Array.from(workers.values()).filter((worker) => !activeWorkers.has(worker)).forEach((worker) => stopWorker(worker));
4467
+ await Promise.all(exitPromises);
4468
+ if (isCancelled) return;
4469
+ }
4414
4470
  const groupedFiles = await groupSpecifications(specs);
4415
4471
  const tasks = await Promise.all(Array.from(groupedFiles.entries(), async ([project, files]) => {
4416
4472
  await project._initBrowserProvider();
@@ -4874,13 +4930,7 @@ const warmExternals = /* @__PURE__ */ new WeakMap();
4874
4930
  function createMethodsRPC(project, methodsOptions = {}) {
4875
4931
  const vitest = project.vitest;
4876
4932
  const cacheFs = methodsOptions.cacheFs ?? false;
4877
- project.vitest.state.metadata[project.name] ??= {
4878
- externalized: {},
4879
- duration: {},
4880
- tmps: {}
4881
- };
4882
- if (project.config.dumpDir && !existsSync(project.config.dumpDir)) mkdirSync(project.config.dumpDir, { recursive: true });
4883
- project.vitest.state.metadata[project.name].dumpDir = project.config.dumpDir;
4933
+ project.vitest.state.metadata[project.name] ??= { duration: {} };
4884
4934
  function getEnvironment(environmentName) {
4885
4935
  const environment = project.vite.environments[environmentName];
4886
4936
  if (!environment) throw new Error(`The environment ${environmentName} was not defined in the Vite config.`);
@@ -4892,7 +4942,6 @@ function createMethodsRPC(project, methodsOptions = {}) {
4892
4942
  return await project._transformService.fetch(url, importer, environment, cacheFs, options, otelCarrier).then((result) => {
4893
4943
  const metadata = state.metadata[project.name];
4894
4944
  if ("externalize" in result) {
4895
- metadata.externalized[url] = result.externalize;
4896
4945
  // builtins and network urls are already resolved inside the worker
4897
4946
  // without a round-trip, only module externalizations are worth sharing
4898
4947
  if (result.type === "module" && url[0] === "/") {
@@ -4904,7 +4953,6 @@ function createMethodsRPC(project, methodsOptions = {}) {
4904
4953
  externals[url] = result;
4905
4954
  }
4906
4955
  }
4907
- if ("tmp" in result) metadata.tmps[url] = result.tmp;
4908
4956
  if (accountModuleDuration) {
4909
4957
  const duration = performance.now() - start;
4910
4958
  metadata.duration[url] ??= [];
@@ -5440,6 +5488,60 @@ class PoolRunner {
5440
5488
  }
5441
5489
  }
5442
5490
 
5491
+ let watchdog;
5492
+ const watched = /* @__PURE__ */ new Set();
5493
+ function watchProcess(child, distPath) {
5494
+ const pid = child.pid;
5495
+ if (pid == null) return;
5496
+ watchdog ??= startWatchdog(distPath);
5497
+ watched.add(pid);
5498
+ send({
5499
+ type: "watch",
5500
+ pid
5501
+ });
5502
+ child.once("exit", () => {
5503
+ watched.delete(pid);
5504
+ send({
5505
+ type: "unwatch",
5506
+ pid
5507
+ });
5508
+ });
5509
+ }
5510
+ function stopWatchdog() {
5511
+ if (watchdog && watched.size === 0) {
5512
+ watchdog.disconnect();
5513
+ watchdog = void 0;
5514
+ }
5515
+ }
5516
+ function send(message) {
5517
+ if (watchdog?.connected) watchdog.send(message);
5518
+ }
5519
+ function startWatchdog(distPath) {
5520
+ /** Loads {@link file://./../../runtime/workers/watchdog.ts} */
5521
+ const child = fork(resolve$1(distPath, "workers/watchdog.js"), [], {
5522
+ stdio: [
5523
+ "ignore",
5524
+ "ignore",
5525
+ "ignore",
5526
+ "ipc"
5527
+ ],
5528
+ execArgv: [],
5529
+ env: {
5530
+ ...process.env,
5531
+ NODE_OPTIONS: void 0
5532
+ }
5533
+ });
5534
+ // must never keep the main process alive
5535
+ child.unref();
5536
+ child.channel?.unref();
5537
+ // losing the watchdog only loses the cleanup, the test run is not affected
5538
+ child.on("error", () => {});
5539
+ child.once("exit", () => {
5540
+ if (watchdog === child) watchdog = void 0;
5541
+ });
5542
+ return child;
5543
+ }
5544
+
5443
5545
  // After a worker dies, its remaining stdio is drained into the parent-side
5444
5546
  // readables asynchronously. Waiting for `end`/`close` before unpiping ensures
5445
5547
  // the tail of the output still reaches the shared logger streams.
@@ -5462,6 +5564,7 @@ class ForksPoolWorker {
5462
5564
  entrypoint;
5463
5565
  execArgv;
5464
5566
  env;
5567
+ distPath;
5465
5568
  _fork;
5466
5569
  stdout;
5467
5570
  stderr;
@@ -5472,6 +5575,7 @@ class ForksPoolWorker {
5472
5575
  this.env = options.env;
5473
5576
  this.stdout = options.project.vitest.logger.outputStream;
5474
5577
  this.stderr = options.project.vitest.logger.errorStream;
5578
+ this.distPath = options.distPath;
5475
5579
  /** Loads {@link file://./../../../runtime/workers/forks.ts} */
5476
5580
  this.entrypoint = resolve$1(options.distPath, "workers/forks.js");
5477
5581
  }
@@ -5494,6 +5598,7 @@ class ForksPoolWorker {
5494
5598
  serialization: "advanced"
5495
5599
  });
5496
5600
  this._fork.on("error", this.emitError);
5601
+ watchProcess(this._fork, this.distPath);
5497
5602
  // `end: false`: the logger streams are shared by every worker, so one
5498
5603
  // ending worker stream must not end them for everyone else
5499
5604
  if (this._fork.stdout) {
@@ -5940,7 +6045,7 @@ class Pool {
5940
6045
  await resolver.promise.catch((error) => span?.recordException(error)).finally(() => span?.end());
5941
6046
  const index = this.activeTasks.indexOf(activeTask);
5942
6047
  if (index !== -1) this.activeTasks.splice(index, 1);
5943
- if (!task.isolate && !runner.isTerminated && !isMemoryLimitReached && this.queue[0]?.task.isolate === false && isEqualRunner(runner, this.queue[0].task)) {
6048
+ if (!task.isolate && runner.isStarted && !isMemoryLimitReached && this.queue[0]?.task.isolate === false && isEqualRunner(runner, this.queue[0].task)) {
5944
6049
  this.sharedRunners.push(runner);
5945
6050
  return this.schedule();
5946
6051
  }
@@ -5981,6 +6086,7 @@ catch (error) {
5981
6086
  }
5982
6087
  async close() {
5983
6088
  await this.cancel();
6089
+ stopWatchdog();
5984
6090
  }
5985
6091
  getPoolRunner(task, method) {
5986
6092
  if (task.isolate === false) {
@@ -6080,20 +6186,13 @@ function createPool(ctx) {
6080
6186
  state: ctx.state
6081
6187
  }, ctx.logger);
6082
6188
  const options = resolveOptions(ctx);
6083
- const Sequencer = ctx.config.sequence.sequencer;
6084
- const sequencer = new Sequencer(ctx);
6085
6189
  let browserPool;
6086
6190
  async function executeTests(method, specs, invalidates) {
6087
6191
  ctx.onCancel(() => pool.cancel());
6088
- if (ctx.config.shard) {
6089
- if (!ctx.config.passWithNoTests && ctx.config.shard.count > specs.length) throw new Error(`--shard <count> must be a smaller than count of test files. Resolved ${specs.length} test files for --shard=${ctx.config.shard.index}/${ctx.config.shard.count}.`);
6090
- specs = await sequencer.shard(Array.from(specs));
6091
- }
6092
6192
  const taskGroups = [];
6093
6193
  let workerId = 1;
6094
- const sorted = await sequencer.sort(specs);
6095
6194
  const { environments, tags } = await getSpecificationsOptions(specs);
6096
- const groups = groupSpecs(sorted, environments);
6195
+ const groups = groupSpecs(specs, environments);
6097
6196
  const projectEnvs = /* @__PURE__ */ new WeakMap();
6098
6197
  const projectExecArgvs = /* @__PURE__ */ new WeakMap();
6099
6198
  for (const group of groups) {
@@ -6366,13 +6465,21 @@ async function globProjectTestFiles(include, exclude, includeSource, cwd) {
6366
6465
  function filterTestFiles(testFiles, filters, dir) {
6367
6466
  if (!filters.length) return testFiles;
6368
6467
  if (process.platform === "win32") filters = filters.map((f) => slash(f));
6468
+ const patterns = filters.map((f) => {
6469
+ const relativePath = f.endsWith("/") ? join(relative(dir, f), "/") : relative(dir, f);
6470
+ return {
6471
+ filter: f,
6472
+ isAbsolute: isAbsolute(f),
6473
+ lowerCase: f.toLocaleLowerCase(),
6474
+ relativeLowerCase: relativePath.toLocaleLowerCase()
6475
+ };
6476
+ });
6369
6477
  return testFiles.filter((t) => {
6370
6478
  const testFile = relative(dir, t).toLocaleLowerCase();
6371
- return filters.some((f) => {
6479
+ return patterns.some((p) => {
6372
6480
  // if filter is a full file path, we should include it if it's in the same folder
6373
- if (isAbsolute(f) && t.startsWith(f)) return true;
6374
- const relativePath = f.endsWith("/") ? join(relative(dir, f), "/") : relative(dir, f);
6375
- return testFile.includes(f.toLocaleLowerCase()) || testFile.includes(relativePath.toLocaleLowerCase());
6481
+ if (p.isAbsolute && t.startsWith(p.filter)) return true;
6482
+ return testFile.includes(p.lowerCase) || testFile.includes(p.relativeLowerCase);
6376
6483
  });
6377
6484
  });
6378
6485
  }
@@ -7859,9 +7966,18 @@ async function getFileSizes(files) {
7859
7966
  class RandomSequencer extends BaseSequencer {
7860
7967
  async sort(files) {
7861
7968
  const { sequence } = this.ctx.config;
7862
- return shuffle(files, sequence.seed);
7969
+ // the glob order can change between runs, so only the seed may decide the order
7970
+ const sorted = [...files].sort(compareSpecifications);
7971
+ return shuffle(sorted, sequence.seed);
7863
7972
  }
7864
7973
  }
7974
+ function compareSpecifications(a, b) {
7975
+ return compareStrings(a.project.name, b.project.name) || compareStrings(a.moduleId, b.moduleId) || compareStrings(a.pool, b.pool);
7976
+ }
7977
+ // `localeCompare` depends on the locale of the machine, which makes `--seed` unreproducible
7978
+ function compareStrings(a, b) {
7979
+ return a < b ? -1 : a > b ? 1 : 0;
7980
+ }
7865
7981
 
7866
7982
  var jsTokens_1;
7867
7983
  var hasRequiredJsTokens;
@@ -8851,7 +8967,8 @@ function resolveTestConfig(logger, options, viteConfig, globalConfig) {
8851
8967
  ...resolved.inspector,
8852
8968
  ...parseInspector(inspector),
8853
8969
  enabled: !!inspector,
8854
- waitForDebugger: options.inspector?.waitForDebugger ?? !!resolved.inspectBrk
8970
+ waitForDebugger: options.inspector?.waitForDebugger ?? !!resolved.inspectBrk,
8971
+ openInMainProcess: isInspectorOpen()
8855
8972
  };
8856
8973
  if (viteConfig.base !== "/") resolved.base = viteConfig.base;
8857
8974
  resolved.clearScreen = resolved.clearScreen ?? viteConfig.clearScreen ?? true;
@@ -9127,7 +9244,7 @@ function resolveTestConfig(logger, options, viteConfig, globalConfig) {
9127
9244
  };
9128
9245
  resolved.typecheck ??= {};
9129
9246
  resolved.typecheck.enabled ??= false;
9130
- if (resolved.typecheck.enabled && !warnedTypeCheck) {
9247
+ if (resolved.typecheck.enabled && !warnedTypeCheck && !process.env.VITEST_DISABLE_EXPERIMENTAL_LOG) {
9131
9248
  warnedTypeCheck = true;
9132
9249
  logger.console.warn($.yellow("Testing types with tsc and vue-tsc is an experimental feature.\nBreaking changes might not follow SemVer, please pin Vitest's version when using it."));
9133
9250
  }
@@ -9186,10 +9303,8 @@ function resolveTestConfig(logger, options, viteConfig, globalConfig) {
9186
9303
  })) resolved.includeTaskLocation ??= true;
9187
9304
  resolved.server ??= {};
9188
9305
  resolved.server.deps ??= {};
9189
- if (resolved.server.debug?.dump || process.env.VITEST_DEBUG_DUMP) {
9190
- const userFolder = resolved.server.debug?.dump || process.env.VITEST_DEBUG_DUMP;
9191
- resolved.dumpDir = resolve(resolved.root, typeof userFolder === "string" && userFolder !== "true" ? userFolder : ".vitest-dump", resolved.name || "root");
9192
- }
9306
+ // projects inherit the root option, so they warn only when they set it themselves
9307
+ if (resolved.server.debug && (!globalConfig || !globalConfig.server.debug)) logger.deprecate("`server.debug` is deprecated and has no effect. To inspect or edit the transformed code, look up the module in the `fsModuleCache` manifest: https://vitest.dev/config/fsmodulecache#manifest");
9193
9308
  resolved.testTimeout ??= resolved.browser.enabled ? 15e3 : 5e3;
9194
9309
  resolved.hookTimeout ??= resolved.browser.enabled ? 3e4 : 1e4;
9195
9310
  resolved.experimental ??= {};
@@ -9236,8 +9351,15 @@ function resolveTestConfig(logger, options, viteConfig, globalConfig) {
9236
9351
  logger.deprecate("`experimental.fsModuleCachePath` is deprecated. Use the top-level `fsModuleCachePath` option instead.");
9237
9352
  if (options.fsModuleCachePath === void 0) resolved.fsModuleCachePath = legacyExperimental.fsModuleCachePath;
9238
9353
  }
9354
+ // the config and the CLI take priority over the environment
9355
+ const fsModuleCacheEnv = process.env.VITEST_FS_MODULE_CACHE;
9356
+ if (resolved.fsModuleCache == null && fsModuleCacheEnv) {
9357
+ resolved.fsModuleCache = fsModuleCacheEnv !== "false" && fsModuleCacheEnv !== "0";
9358
+ resolved.providedOptions.fsModuleCache = true;
9359
+ }
9239
9360
  resolved.fsModuleCache ??= true;
9240
- if (resolved.fsModuleCachePath) resolved.fsModuleCachePath = resolve(resolved.root, resolved.fsModuleCachePath);
9361
+ const fsModuleCachePath = resolved.fsModuleCachePath || process.env.VITEST_FS_MODULE_CACHE_PATH;
9362
+ if (fsModuleCachePath) resolved.fsModuleCachePath = resolve(resolved.root, fsModuleCachePath);
9241
9363
  return resolved;
9242
9364
  }
9243
9365
  /**
@@ -15662,4 +15784,4 @@ var index = /*#__PURE__*/_mergeNamespaces({
15662
15784
  default: prompt
15663
15785
  }, [promptsExports]);
15664
15786
 
15665
- export { generateCodeFrame as A, BaseSequencer as B, printStack as C, LocationFilterFileNotFoundError as D, GitCommandError as E, ForksPoolWorker as F, GitNotFoundError as G, VitestResolver as H, IncludeTaskLocationDisabledError as I, createClusterServer as J, attachProjectsFromEntries as K, Logger as L, ModuleTransformService as M, TestProject as N, resolveAndAttachProjects as O, PluginHarness as P, RandomSequencer as Q, RangeLocationFilterProvidedError as R, ServerModuleRunner as S, ThreadsPoolWorker as T, createPool as U, VitestPackageInstaller as V, astCollectTests as W, createFailedFileTask as X, matchesProjectFilter as Y, nanoid as Z, stdout as _, BrowserConnectionError as a, FilesNotFoundError as b, TypecheckPoolWorker as c, VmForksPoolWorker as d, VmThreadsPoolWorker as e, createDebugger as f, createMethodsRPC as g, createViteLogger as h, escapeTestName as i, getFilePoolName as j, isFileServingAllowed as k, resolveConfig as l, resolveFsAllow as m, findConfigFile as n, parse as o, prompt as p, getSpecificationDocblock as q, resolveApiServerConfig as r, stringify as s, resolveStaticMocks as t, getStaticMocks as u, hash as v, resolveCoverageReporters as w, createIndexLocationsMap as x, getOutputFile as y, groupBy as z };
15787
+ export { printStack as A, BaseSequencer as B, LocationFilterFileNotFoundError as C, GitCommandError as D, VitestResolver as E, ForksPoolWorker as F, GitNotFoundError as G, createClusterServer as H, IncludeTaskLocationDisabledError as I, attachProjectsFromEntries as J, TestProject as K, Logger as L, ModuleTransformService as M, resolveAndAttachProjects as N, RandomSequencer as O, PluginHarness as P, createPool as Q, RangeLocationFilterProvidedError as R, ServerModuleRunner as S, ThreadsPoolWorker as T, astCollectTests as U, VitestPackageInstaller as V, createFailedFileTask as W, matchesProjectFilter as X, nanoid as Y, stdout as Z, BrowserConnectionError as a, FilesNotFoundError as b, TypecheckPoolWorker as c, VmForksPoolWorker as d, VmThreadsPoolWorker as e, createDebugger as f, createMethodsRPC as g, createViteLogger as h, escapeTestName as i, getFilePoolName as j, isFileServingAllowed as k, resolveConfig as l, resolveFsAllow as m, findConfigFile as n, parse as o, prompt as p, getSpecificationDocblock as q, resolveApiServerConfig as r, stringify as s, resolveStaticMocks as t, getStaticMocks as u, resolveCoverageReporters as v, createIndexLocationsMap as w, getOutputFile as x, groupBy as y, generateCodeFrame as z };
@@ -156,7 +156,7 @@ const serialize$5 = (val, config, indentation, depth, refs, printer) => {
156
156
  if (stringedValue === "StringMatching" || stringedValue === "StringNotMatching") return stringedValue + SPACE$2 + printer(val.sample, config, indentation, depth, refs);
157
157
  if (stringedValue === "StringContaining" || stringedValue === "StringNotContaining") return stringedValue + SPACE$2 + printer(val.sample, config, indentation, depth, refs);
158
158
  if (typeof val.toAsymmetricMatcher !== "function") throw new TypeError(`Asymmetric matcher ${val.constructor.name} does not implement toAsymmetricMatcher()`);
159
- return val.toAsymmetricMatcher();
159
+ return val.toAsymmetricMatcher().replaceAll("\n", `\n${indentation}`);
160
160
  };
161
161
  const test$5 = (val) => val && val.$$typeof === asymmetricMatcher;
162
162
  const plugin$5 = {
@@ -1,4 +1,4 @@
1
- import { i as init } from './init.CO4AB7HZ.js';
1
+ import { i as init } from './init.dGO4K2C0.js';
2
2
 
3
3
  if (!process.send) throw new Error("Expected worker to be run in node:child_process");
4
4
  // Store globals in case tests overwrite them
@@ -10,6 +10,7 @@ const processRemoveAllListeners = process.removeAllListeners.bind(process);
10
10
  // Work-around for nodejs/node#55094
11
11
  if (process.execArgv.some((execArg) => execArg.startsWith("--prof") || execArg.startsWith("--cpu-prof") || execArg.startsWith("--heap-prof") || execArg.startsWith("--diagnostic-dir"))) processOn("SIGTERM", () => processExit());
12
12
  processOn("error", onError);
13
+ processOn("disconnect", onDisconnect);
13
14
  function workerInit(options) {
14
15
  const { runTests } = options;
15
16
  init({
@@ -19,6 +20,7 @@ function workerInit(options) {
19
20
  teardown: () => {
20
21
  processRemoveAllListeners("message");
21
22
  processOff("error", onError);
23
+ processOff("disconnect", onDisconnect);
22
24
  // the guard installed by the test runner stays active between test
23
25
  // files: with `isolate: false` a late process.exit would kill the
24
26
  // other files sharing this process
@@ -34,5 +36,9 @@ function workerInit(options) {
34
36
  function onError(error) {
35
37
  if (error?.code === "ERR_IPC_CHANNEL_CLOSED" || error?.code === "EPIPE") processExit(1);
36
38
  }
39
+ // Main process has died, there is no one to report results to
40
+ function onDisconnect() {
41
+ processExit(1);
42
+ }
37
43
 
38
44
  export { workerInit as w };
@@ -1,5 +1,5 @@
1
1
  import { isMainThread, parentPort } from 'node:worker_threads';
2
- import { i as init } from './init.CO4AB7HZ.js';
2
+ import { i as init } from './init.dGO4K2C0.js';
3
3
 
4
4
  if (isMainThread || !parentPort) throw new Error("Expected worker to be run in node:worker_threads");
5
5
  function workerInit(options) {