File tree Expand file tree Collapse file tree 4 files changed +25
-17
lines changed
Expand file tree Collapse file tree 4 files changed +25
-17
lines changed Original file line number Diff line number Diff line change 1010> - :house : [ Internal]
1111> - :nail_care : [ Polish]
1212
13+ ## [ Unreleased]
14+
15+ #### :nail_care : Polish
16+
17+ - Resolve symlinks when finding platform binaries. https://github.com/rescript-lang/rescript-vscode/pull/1154
18+
1319## 1.70.0
1420
1521#### :bug : Bug fix
Original file line number Diff line number Diff line change @@ -154,23 +154,14 @@ async function findRuntimePath(
154154 ) ;
155155}
156156
157- function findRuntimeCached ( ) : (
158- project : NormalizedPath ,
159- ) => Promise < NormalizedPath [ ] > {
160- const cache = new Map < NormalizedPath , NormalizedPath [ ] > ( ) ;
161- return async ( project : NormalizedPath ) => {
162- if ( cache . has ( project ) ) {
163- return cache . get ( project ) ! ;
164- }
165- const runtimes = await findRuntimePath ( project ) ;
166- cache . set ( project , runtimes ) ;
167- return runtimes ;
168- } ;
169- }
170-
171157/**
172158 * Find all installed @rescript/runtime directories in the given project path.
173159 * In a perfect world, there should be exactly one.
174- * This function is cached per project path.
160+ * Note: This function is not cached here. Caching is handled by the caller
161+ * (see getRuntimePathFromWorkspaceRoot in utils.ts).
175162 */
176- export const findRescriptRuntimesInProject = findRuntimeCached ( ) ;
163+ export async function findRescriptRuntimesInProject (
164+ project : NormalizedPath ,
165+ ) : Promise < NormalizedPath [ ] > {
166+ return await findRuntimePath ( project ) ;
167+ }
Original file line number Diff line number Diff line change @@ -1580,6 +1580,7 @@ async function onMessage(msg: p.Message) {
15801580 config : config . extensionConfiguration ,
15811581 projects,
15821582 workspaceFolders : Array . from ( workspaceFolders ) ,
1583+ runtimePathCache : utils . getRuntimePathCacheSnapshot ( ) ,
15831584 } ;
15841585
15851586 let response : p . ResponseMessage = {
Original file line number Diff line number Diff line change @@ -226,8 +226,10 @@ let findBinary = async (
226226 // TODO: export `binPaths` from `rescript` package so that we don't need to
227227 // copy the logic for figuring out `target`.
228228 const target = `${ process . platform } -${ process . arch } ` ;
229+ // Use realpathSync to resolve symlinks, which is necessary for package
230+ // managers like Deno and pnpm that use symlinked node_modules structures.
229231 const targetPackagePath = path . join (
230- rescriptDir ,
232+ fs . realpathSync ( rescriptDir ) ,
231233 ".." ,
232234 `@rescript/${ target } /bin.js` ,
233235 ) ;
@@ -570,6 +572,14 @@ export async function getRuntimePathFromProjectRoot(
570572 return result ;
571573}
572574
575+ /**
576+ * Returns a snapshot of the runtime path cache as a plain object.
577+ * Useful for debugging and state dumps.
578+ */
579+ export function getRuntimePathCacheSnapshot ( ) : Record < string , string | null > {
580+ return Object . fromEntries ( runtimePathCache ) ;
581+ }
582+
573583export const getNamespaceNameFromConfigFile = (
574584 projDir : NormalizedPath ,
575585) : execResult < string > => {
You can’t perform that action at this time.
0 commit comments