⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content
Open
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
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@

#### :bug: Bug fix

- Fix Code Analyzer binary lookup for ReScript v12+ projects.
- Fix Code Analyzer cwd/binary lookup in monorepos (run from workspace root).
- Fix monorepo build detection by only watching the workspace root `.compiler.log`.
- Fix Start Build for ReScript v12+ projects by preferring `rescript.exe`.
- Take namespace into account for incremental cleanup. https://github.com/rescript-lang/rescript-vscode/pull/1164
- Potential race condition in incremental compilation. https://github.com/rescript-lang/rescript-vscode/pull/1167
- Fix extension crash triggered by incremental compilation. https://github.com/rescript-lang/rescript-vscode/pull/1169
Expand Down
7 changes: 6 additions & 1 deletion client/src/commands/code_analysis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,14 @@ export const runCodeAnalysisWithReanalyze = (
let currentDocument = window.activeTextEditor.document;
let cwd = targetDir ?? path.dirname(currentDocument.uri.fsPath);

// Resolve the project root from `cwd` (which is the workspace root when code analysis is started),
// rather than from the currently-open file (which may be in a subpackage).
let projectRootPath: NormalizedPath | null = findProjectRootOfFileInDir(
currentDocument.uri.fsPath,
path.join(cwd, "bsconfig.json"),
);
if (projectRootPath == null) {
projectRootPath = findProjectRootOfFileInDir(currentDocument.uri.fsPath);
}

// Try v12+ path first: @rescript/{platform}-{arch}/bin/rescript-tools.exe
// Then fall back to legacy paths via getBinaryPath
Expand Down
11 changes: 5 additions & 6 deletions client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,12 +442,11 @@ export function activate(context: ExtensionContext) {

inCodeAnalysisState.active = true;

// Pointing reanalyze to the dir of the current file path is fine, because
// reanalyze will walk upwards looking for a bsconfig.json in order to find
// the correct project root.
inCodeAnalysisState.activatedFromDirectory = path.dirname(
currentDocument.uri.fsPath,
);
// Run reanalyze from the workspace root (so monorepos consistently analyze the root project),
// instead of from whatever file happened to be active when analysis was started.
const wsFolder = workspace.getWorkspaceFolder(currentDocument.uri);
inCodeAnalysisState.activatedFromDirectory =
wsFolder?.uri.fsPath ?? path.dirname(currentDocument.uri.fsPath);

codeAnalysisRunningStatusBarItem.command =
"rescript-vscode.stop_code_analysis";
Expand Down
31 changes: 21 additions & 10 deletions server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,28 @@ let findRescriptBinary = async (
): Promise<utils.NormalizedPath | null> => {
if (
config.extensionConfiguration.binaryPath != null &&
fs.existsSync(
path.join(config.extensionConfiguration.binaryPath, "rescript"),
)
(fs.existsSync(
path.join(config.extensionConfiguration.binaryPath, "rescript.exe"),
) ||
fs.existsSync(
path.join(config.extensionConfiguration.binaryPath, "rescript"),
))
) {
return utils.normalizePath(
path.join(config.extensionConfiguration.binaryPath, "rescript"),
fs.existsSync(
path.join(config.extensionConfiguration.binaryPath, "rescript.exe"),
)
? path.join(config.extensionConfiguration.binaryPath, "rescript.exe")
: path.join(config.extensionConfiguration.binaryPath, "rescript"),
);
}

return utils.findRescriptBinary(projectRootPath);
// Prefer the native rescript.exe (v12+) for spawning `build -w`.
// Fall back to the legacy/JS wrapper `rescript` path if needed.
return (
(await utils.findRescriptExeBinary(projectRootPath)) ??
(await utils.findRescriptBinary(projectRootPath))
);
};

let createInterfaceRequest = new v.RequestType<
Expand Down Expand Up @@ -1388,11 +1400,10 @@ async function onMessage(msg: p.Message) {
const watchers = Array.from(workspaceFolders).flatMap(
(projectRootPath) => [
{
globPattern: path.join(
projectRootPath,
"**",
c.compilerLogPartialPath,
),
// Only watch the root compiler log for each workspace folder.
// In monorepos, `**/lib/bs/.compiler.log` matches every package and dependency,
// causing a burst of events per save.
globPattern: path.join(projectRootPath, c.compilerLogPartialPath),
kind: p.WatchKind.Change | p.WatchKind.Create | p.WatchKind.Delete,
},
{
Expand Down