@@ -51,14 +51,17 @@ async function findNodeModulesDirs(
51
51
return nodeModulesDirs ;
52
52
}
53
53
54
- // Custom function to find Deno vendorized @rescript /runtime directories
55
- async function findDenoRescriptRuntime ( nodeModulesPath : string ) {
54
+ // Custom function to find Deno or pnpm vendorized @rescript /runtime directories
55
+ async function findRescriptRuntimeInAlternativeLayout (
56
+ subfolder : ".deno" | ".pnpm" ,
57
+ nodeModulesPath : string ,
58
+ ) {
56
59
// We only care about the Deno vendorized layout:
57
60
// <nodeModulesPath>/.deno/@rescript+runtime@<version>/node_modules/@rescript/runtime
58
- const denoRoot = join ( nodeModulesPath , ".deno" ) ;
61
+ const alternativeRoot = join ( nodeModulesPath , subfolder ) ;
59
62
let entries : string [ ] ;
60
63
try {
61
- entries = await readdir ( denoRoot ) ;
64
+ entries = await readdir ( alternativeRoot ) ;
62
65
} catch {
63
66
return [ ] ;
64
67
}
@@ -71,7 +74,7 @@ async function findDenoRescriptRuntime(nodeModulesPath: string) {
71
74
const results : string [ ] = [ ] ;
72
75
for ( const dir of vendorDirs ) {
73
76
const runtimePath = join (
74
- denoRoot ,
77
+ alternativeRoot ,
75
78
dir ,
76
79
"node_modules" ,
77
80
"@rescript" ,
@@ -102,15 +105,28 @@ async function findRuntimePath(project: string) {
102
105
const stat = await statAsync ( standardPath ) ;
103
106
if ( stat . isDirectory ( ) ) {
104
107
results . push ( standardPath ) ;
105
- // If we found standard layout, no need to search for Deno layouts
108
+ // If we found standard layout, no need to search for pnpm or Deno layouts
106
109
return results ;
107
110
}
108
111
} catch ( e ) {
109
112
// Directory doesn't exist, continue
110
113
}
111
114
115
+ // Only check for pnpm vendorized layouts if standard layout wasn't found
116
+ const pnpmResults = await findRescriptRuntimeInAlternativeLayout (
117
+ ".pnpm" ,
118
+ nm ,
119
+ ) ;
120
+ results . push ( ...pnpmResults ) ;
121
+ if ( results . length > 0 ) {
122
+ return results ;
123
+ }
124
+
112
125
// Only check for Deno vendorized layouts if standard layout wasn't found
113
- const denoResults = await findDenoRescriptRuntime ( nm ) ;
126
+ const denoResults = await findRescriptRuntimeInAlternativeLayout (
127
+ ".deno" ,
128
+ nm ,
129
+ ) ;
114
130
results . push ( ...denoResults ) ;
115
131
116
132
return results ;
0 commit comments