Skip to content

Commit 4beb5c8

Browse files
committed
Fix csb.dev packages not resolving correctly
1 parent bab6f06 commit 4beb5c8

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

packages/app/src/sandbox/eval/npm/fetch-npm-module.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,26 @@ async function findDependencyVersion(
350350
defaultExtensions
351351
);
352352

353+
// If the dependency is in the root we get it from the manifest, as the manifest
354+
// contains all the versions that we really wanted to resolve in the first place.
355+
// An example of this is csb.dev packages, the package.json version doesn't say the
356+
// actual version, but the semver it relates to. In this case we really want to have
357+
// the actual url
358+
if (
359+
foundPackageJSONPath ===
360+
pathUtils.join('/node_modules', dependencyName, 'package.json')
361+
) {
362+
const rootDependency = manifest.dependencies.find(
363+
dep => dep.name === dependencyName
364+
);
365+
if (rootDependency) {
366+
return {
367+
packageJSONPath: foundPackageJSONPath,
368+
version: rootDependency.version,
369+
};
370+
}
371+
}
372+
353373
const packageJSON =
354374
manager.transpiledModules[foundPackageJSONPath] &&
355375
manager.transpiledModules[foundPackageJSONPath].module.code;

packages/app/src/sandbox/version-resolving/resolve-dependency.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export async function resolveDependencyInfo(dep: string, version: string) {
6666
contents: {},
6767
dependency: {
6868
name: dep,
69-
version: packageJSON.version,
69+
version,
7070
},
7171
peerDependencies: {},
7272
dependencyDependencies: {},

0 commit comments

Comments
 (0)