Skip to content

Commit 42ec325

Browse files
authored
Fix local compilation when in a workspace (#1082)
* fix local compilation when in a workspace * better * Update CHANGELOG.md
1 parent cd42e8b commit 42ec325

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
- Fix: bug where incremental analysis does not work when the project folder contains a dot. https://github.com/rescript-lang/rescript-vscode/pull/1080
1818

19+
- 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
20+
1921
## 1.62.0
2022

2123
#### :nail_care: Polish

server/src/incrementalCompilation.ts

+17-3
Original file line numberDiff line numberDiff line change
@@ -390,9 +390,23 @@ function triggerIncrementalCompilationOfFile(
390390
if (debug()) console.log("Did not find open project for " + filePath);
391391
return;
392392
}
393-
const workspaceRootPath = projectRootPath
394-
? utils.findProjectRootOfFile(projectRootPath, true)
395-
: null;
393+
394+
const projectRewatchLockfile = path.resolve(
395+
projectRootPath,
396+
c.rewatchLockPartialPath
397+
);
398+
399+
let foundRewatchLockfileInProjectRoot = false;
400+
if (fs.existsSync(projectRewatchLockfile)) {
401+
foundRewatchLockfileInProjectRoot = true;
402+
}
403+
404+
// if we find a rewatch.lock in the project root, it's a compilation of a local package
405+
// in the workspace.
406+
const workspaceRootPath =
407+
projectRootPath && !foundRewatchLockfileInProjectRoot
408+
? utils.findProjectRootOfFile(projectRootPath, true)
409+
: null;
396410

397411
const bscBinaryLocation = project.bscBinaryLocation;
398412
if (bscBinaryLocation == null) {

0 commit comments

Comments
 (0)