@cloudflare/vitest-pool-workers 0.13.4 → 0.13.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.
@@ -1984,20 +1984,20 @@ function withSourceUrl(contents, url) {
1984
1984
  function withImportMetaUrl(contents, url) {
1985
1985
  return contents.replaceAll("import.meta.url", JSON.stringify(url.toString()));
1986
1986
  }
1987
- const moduleExtensions = [
1987
+ const requireExtensions = [
1988
1988
  ".js",
1989
1989
  ".mjs",
1990
1990
  ".cjs",
1991
1991
  ".json"
1992
1992
  ];
1993
- function maybeGetTargetFilePath(target) {
1993
+ function maybeGetTargetFilePath(target, isRequire) {
1994
1994
  if (isFile(target)) return target;
1995
- for (const extension of moduleExtensions) {
1995
+ if (isRequire) for (const extension of requireExtensions) {
1996
1996
  const targetWithExtension = target + extension;
1997
1997
  if (fs.existsSync(targetWithExtension)) return targetWithExtension;
1998
1998
  }
1999
1999
  if (target.endsWith(disableCjsEsmShimSuffix)) return target;
2000
- if (isDirectory(target)) return maybeGetTargetFilePath(target + "/index");
2000
+ if (isDirectory(target)) return maybeGetTargetFilePath(target + "/index", isRequire);
2001
2001
  }
2002
2002
  /**
2003
2003
  * `target` is the path to the "file" `workerd` is trying to load,
@@ -2046,10 +2046,10 @@ async function viteResolve(vite, specifier, referrer, isRequire) {
2046
2046
  }
2047
2047
  async function resolve(vite, method, target, specifier, referrer) {
2048
2048
  const referrerDir = posixPath.dirname(referrer);
2049
- let filePath = maybeGetTargetFilePath(target);
2049
+ let filePath = maybeGetTargetFilePath(target, method === "require");
2050
2050
  if (filePath !== void 0) return filePath;
2051
2051
  if (referrerDir !== "/" && workerdBuiltinModules.has(specifier)) return `/${specifier}`;
2052
- filePath = maybeGetTargetFilePath(posixPath.join(libPath, specifier.replaceAll(":", "/")));
2052
+ filePath = maybeGetTargetFilePath(posixPath.join(libPath, specifier.replaceAll(":", "/")), true);
2053
2053
  if (filePath !== void 0) return filePath;
2054
2054
  return viteResolve(vite, specifier, referrer, method === "require");
2055
2055
  }