Skip to content

Fix local compilation when in a workspace #1082

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 17 additions & 3 deletions server/src/incrementalCompilation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down