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 diff --git a/server/src/incrementalCompilation.ts b/server/src/incrementalCompilation.ts index 576e87cec..4bb824556 100644 --- a/server/src/incrementalCompilation.ts +++ b/server/src/incrementalCompilation.ts @@ -390,9 +390,23 @@ 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; + if (fs.existsSync(projectRewatchLockfile)) { + foundRewatchLockfileInProjectRoot = true; + } + + // 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) {