From 0187b7535e7b005a4b3da98d5623f3e6b5779e73 Mon Sep 17 00:00:00 2001 From: Jaap Frolich Date: Tue, 8 Apr 2025 20:48:28 +0200 Subject: [PATCH 1/3] fix local compilation when in a workspace --- server/src/incrementalCompilation.ts | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/server/src/incrementalCompilation.ts b/server/src/incrementalCompilation.ts index 576e87cec..1aee565b8 100644 --- a/server/src/incrementalCompilation.ts +++ b/server/src/incrementalCompilation.ts @@ -390,9 +390,24 @@ function triggerIncrementalCompilationOfFile( if (debug()) console.log("Did not find open project for " + filePath); return; } - const workspaceRootPath = projectRootPath - ? utils.findProjectRootOfFile(projectRootPath, true) - : null; + + const projectRewatchLockfile = path.resolve( + projectRootPath, + c.rewatchLockPartialPath + ); + + let foundRewatchLockfileInProjectRoot = false; + try { + fs.statSync(projectRewatchLockfile); + foundRewatchLockfileInProjectRoot = true; + } catch {} + + // if we find a rewatch.lock in the project root, it's a compilation of a local package + // in the workspace. + const workspaceRootPath = + projectRootPath && !foundRewatchLockfileInProjectRoot + ? utils.findProjectRootOfFile(projectRootPath, true) + : null; const bscBinaryLocation = project.bscBinaryLocation; if (bscBinaryLocation == null) { From 443e7c3e20adaac14c8ccc9289743b38242a94f4 Mon Sep 17 00:00:00 2001 From: Jaap Frolich Date: Tue, 8 Apr 2025 22:03:45 +0200 Subject: [PATCH 2/3] better --- server/src/incrementalCompilation.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/server/src/incrementalCompilation.ts b/server/src/incrementalCompilation.ts index 1aee565b8..4bb824556 100644 --- a/server/src/incrementalCompilation.ts +++ b/server/src/incrementalCompilation.ts @@ -397,10 +397,9 @@ function triggerIncrementalCompilationOfFile( ); let foundRewatchLockfileInProjectRoot = false; - try { - fs.statSync(projectRewatchLockfile); + if (fs.existsSync(projectRewatchLockfile)) { foundRewatchLockfileInProjectRoot = true; - } catch {} + } // if we find a rewatch.lock in the project root, it's a compilation of a local package // in the workspace. From 67c35e8a023d1b8785e3df247c27be3f52d4247b Mon Sep 17 00:00:00 2001 From: Jaap Frolich Date: Tue, 8 Apr 2025 22:25:51 +0200 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b998cdcc..02a4e43b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,8 @@ - Fix: bug where incremental analysis does not work when the project folder contains a dot. https://github.com/rescript-lang/rescript-vscode/pull/1080 +- Fix: bug where incremental compilation crashes when rewatch is being run in a specific package vs the root of the monorepo. https://github.com/rescript-lang/rescript-vscode/pull/1082 + ## 1.62.0 #### :nail_care: Polish