From 2920da5cf311e387276e6e95450223f67107b6bf Mon Sep 17 00:00:00 2001
From: Ives van Hoorne <ives@codesandbox.io>
Date: Thu, 3 Oct 2024 10:33:24 -0700
Subject: [PATCH] fix: use resolution version for fetching transient
 dependencies (#8628)

---
 .../src/npm/dynamic/resolve-dependency.ts              | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/packages/sandpack-core/src/npm/dynamic/resolve-dependency.ts b/packages/sandpack-core/src/npm/dynamic/resolve-dependency.ts
index 858ce60042c..b9412a9a44a 100644
--- a/packages/sandpack-core/src/npm/dynamic/resolve-dependency.ts
+++ b/packages/sandpack-core/src/npm/dynamic/resolve-dependency.ts
@@ -18,6 +18,10 @@ async function getLatestVersionForSemver(
   dep: string,
   version: string
 ): Promise<string> {
+  if (isAbsoluteVersion(version)) {
+    return Promise.resolve(version);
+  }
+
   const p = await getPackageJSON(dep, version);
   return JSON.parse(p).version;
 }
@@ -37,10 +41,6 @@ function getAbsoluteVersion(
   depVersion: string,
   parsedResolutions: { [name: string]: IParsedResolution[] }
 ): Promise<string> {
-  if (isAbsoluteVersion(depVersion)) {
-    return Promise.resolve(depVersion);
-  }
-
   // Try getting it from the resolutions field first, if that doesn't work
   // we try to get the latest version from the semver.
   const applicableResolutions = parsedResolutions[depName];
@@ -106,7 +106,7 @@ async function getDependencyDependencies(
         };
         await getDependencyDependencies(
           depName,
-          depVersion,
+          absoluteVersion,
           parsedResolutions,
           peerDependencyResult
         );