@cloudflare/vitest-pool-workers 0.13.4 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1702,7 +1702,7 @@ async function listDurableObjectIds(request, mf, url) {
1702
1702
  const ids = [];
1703
1703
  try {
1704
1704
  const names = await fs$1.readdir(namespacePath);
1705
- for (const name of names) if (name.endsWith(".sqlite")) ids.push(name.substring(0, name.length - 7));
1705
+ for (const name of names) if (name.endsWith(".sqlite") && name !== "metadata.sqlite") ids.push(name.substring(0, name.length - 7));
1706
1706
  } catch (e) {
1707
1707
  if (!isFileNotFoundError(e)) throw e;
1708
1708
  }
@@ -1729,10 +1729,17 @@ const workerdBuiltinModules = new Set([...[
1729
1729
  "node-internal:url",
1730
1730
  "node-internal:timers",
1731
1731
  "node-internal:sqlite",
1732
+ "node:_http_agent",
1733
+ "node:_http_client",
1734
+ "node:_http_common",
1735
+ "node:_http_incoming",
1736
+ "node:_http_outgoing",
1737
+ "node:_http_server",
1732
1738
  "node:_stream_duplex",
1733
1739
  "node:_stream_passthrough",
1734
1740
  "node:_stream_readable",
1735
1741
  "node:_stream_transform",
1742
+ "node:_stream_wrap",
1736
1743
  "node:_stream_writable",
1737
1744
  "node:_tls_common",
1738
1745
  "node:_tls_wrap",
@@ -1740,19 +1747,37 @@ const workerdBuiltinModules = new Set([...[
1740
1747
  "node:assert/strict",
1741
1748
  "node:async_hooks",
1742
1749
  "node:buffer",
1750
+ "node:child_process",
1751
+ "node:cluster",
1752
+ "node:console",
1743
1753
  "node:constants",
1744
1754
  "node:crypto",
1755
+ "node:dgram",
1745
1756
  "node:diagnostics_channel",
1746
1757
  "node:dns",
1747
1758
  "node:dns/promises",
1759
+ "node:domain",
1748
1760
  "node:events",
1761
+ "node:fs",
1749
1762
  "node:fs/promises",
1763
+ "node:http",
1764
+ "node:http2",
1765
+ "node:https",
1766
+ "node:inspector",
1767
+ "node:inspector/promises",
1750
1768
  "node:module",
1751
1769
  "node:net",
1770
+ "node:os",
1752
1771
  "node:path",
1753
1772
  "node:path/posix",
1754
1773
  "node:path/win32",
1774
+ "node:perf_hooks",
1775
+ "node:punycode",
1755
1776
  "node:querystring",
1777
+ "node:readline",
1778
+ "node:readline/promises",
1779
+ "node:repl",
1780
+ "node:sqlite",
1756
1781
  "node:stream",
1757
1782
  "node:stream/consumers",
1758
1783
  "node:stream/promises",
@@ -1762,9 +1787,15 @@ const workerdBuiltinModules = new Set([...[
1762
1787
  "node:timers",
1763
1788
  "node:timers/promises",
1764
1789
  "node:tls",
1790
+ "node:trace_events",
1791
+ "node:tty",
1765
1792
  "node:url",
1766
1793
  "node:util",
1767
1794
  "node:util/types",
1795
+ "node:v8",
1796
+ "node:vm",
1797
+ "node:wasi",
1798
+ "node:worker_threads",
1768
1799
  "node:zlib",
1769
1800
  "node-internal:constants",
1770
1801
  "node-internal:crypto_cipher",
@@ -1794,6 +1825,7 @@ const workerdBuiltinModules = new Set([...[
1794
1825
  "node-internal:internal_fs",
1795
1826
  "node-internal:internal_fs_callback",
1796
1827
  "node-internal:internal_fs_constants",
1828
+ "node-internal:internal_fs_glob",
1797
1829
  "node-internal:internal_fs_promises",
1798
1830
  "node-internal:internal_fs_streams",
1799
1831
  "node-internal:internal_fs_sync",
@@ -1984,20 +2016,20 @@ function withSourceUrl(contents, url) {
1984
2016
  function withImportMetaUrl(contents, url) {
1985
2017
  return contents.replaceAll("import.meta.url", JSON.stringify(url.toString()));
1986
2018
  }
1987
- const moduleExtensions = [
2019
+ const requireExtensions = [
1988
2020
  ".js",
1989
2021
  ".mjs",
1990
2022
  ".cjs",
1991
2023
  ".json"
1992
2024
  ];
1993
- function maybeGetTargetFilePath(target) {
2025
+ function maybeGetTargetFilePath(target, isRequire) {
1994
2026
  if (isFile(target)) return target;
1995
- for (const extension of moduleExtensions) {
2027
+ if (isRequire) for (const extension of requireExtensions) {
1996
2028
  const targetWithExtension = target + extension;
1997
2029
  if (fs.existsSync(targetWithExtension)) return targetWithExtension;
1998
2030
  }
1999
2031
  if (target.endsWith(disableCjsEsmShimSuffix)) return target;
2000
- if (isDirectory(target)) return maybeGetTargetFilePath(target + "/index");
2032
+ if (isDirectory(target)) return maybeGetTargetFilePath(target + "/index", isRequire);
2001
2033
  }
2002
2034
  /**
2003
2035
  * `target` is the path to the "file" `workerd` is trying to load,
@@ -2046,10 +2078,10 @@ async function viteResolve(vite, specifier, referrer, isRequire) {
2046
2078
  }
2047
2079
  async function resolve(vite, method, target, specifier, referrer) {
2048
2080
  const referrerDir = posixPath.dirname(referrer);
2049
- let filePath = maybeGetTargetFilePath(target);
2081
+ let filePath = maybeGetTargetFilePath(target, method === "require");
2050
2082
  if (filePath !== void 0) return filePath;
2051
2083
  if (referrerDir !== "/" && workerdBuiltinModules.has(specifier)) return `/${specifier}`;
2052
- filePath = maybeGetTargetFilePath(posixPath.join(libPath, specifier.replaceAll(":", "/")));
2084
+ filePath = maybeGetTargetFilePath(posixPath.join(libPath, specifier.replaceAll(":", "/")), true);
2053
2085
  if (filePath !== void 0) return filePath;
2054
2086
  return viteResolve(vite, specifier, referrer, method === "require");
2055
2087
  }
@@ -2585,7 +2617,9 @@ const symbolizerWarning = "warning: Not symbolizing stack traces because $LLVM_S
2585
2617
  const ignoreMessages = [
2586
2618
  "disconnected: operation canceled",
2587
2619
  "disconnected: worker_do_not_log; Request failed due to internal error",
2588
- "disconnected: WebSocket was aborted"
2620
+ "disconnected: WebSocket was aborted",
2621
+ "CODE_MOVED for unknown code block",
2622
+ "broken.outputGateBroken; jsg.Error: Instance dispose"
2589
2623
  ];
2590
2624
  function trimSymbolizerWarning(chunk) {
2591
2625
  return chunk.includes(symbolizerWarning) ? chunk.substring(chunk.indexOf("\n") + 1) : chunk;
@@ -2887,14 +2921,22 @@ function getPackageJson(dirPath) {
2887
2921
  dirPath = nextDirPath;
2888
2922
  }
2889
2923
  }
2924
+ /**
2925
+ * Extract the upstream vitest version from an alternative distribution's
2926
+ * package.json. Distributions like `@voidzero-dev/vite-plus-test` declare
2927
+ * the bundled vitest version in `bundledVersions.vitest`.
2928
+ */
2929
+ function getUpstreamVitestVersion(pkgJson) {
2930
+ return pkgJson.bundledVersions?.vitest;
2931
+ }
2890
2932
  function assertCompatibleVitestVersion(ctx) {
2891
2933
  const poolPkgJson = getPackageJson(__dirname);
2892
2934
  const vitestPkgJson = getPackageJson(ctx.distPath);
2893
2935
  assert(poolPkgJson !== void 0, "Expected to find `package.json` for `@cloudflare/vitest-pool-workers`");
2894
2936
  assert(vitestPkgJson !== void 0, "Expected to find `package.json` for `vitest`");
2895
2937
  const expectedVitestVersion = poolPkgJson.peerDependencies?.vitest;
2896
- const actualVitestVersion = vitestPkgJson.version;
2897
2938
  assert(expectedVitestVersion !== void 0, "Expected to find `@cloudflare/vitest-pool-workers`'s `vitest` version constraint");
2939
+ const actualVitestVersion = vitestPkgJson.name === "vitest" ? vitestPkgJson.version : getUpstreamVitestVersion(vitestPkgJson) ?? vitestPkgJson.version;
2898
2940
  assert(actualVitestVersion !== void 0, "Expected to find `vitest`'s version");
2899
2941
  if ((0, import_satisfies.default)(actualVitestVersion, "3.x")) {
2900
2942
  const message = `You're running \`vitest@${actualVitestVersion}\`, but this version of \`@cloudflare/vitest-pool-workers\` only supports \`vitest ${expectedVitestVersion}\`.`;