From 092e35e51898beeaf16fc5cf7ebbb73b29d33f29 Mon Sep 17 00:00:00 2001 From: nojaf Date: Thu, 18 Dec 2025 09:28:25 +0100 Subject: [PATCH 1/3] Take namespace into account for incremental cleanup --- server/src/incrementalCompilation.ts | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/server/src/incrementalCompilation.ts b/server/src/incrementalCompilation.ts index 030cdea8e..2575f39e5 100644 --- a/server/src/incrementalCompilation.ts +++ b/server/src/incrementalCompilation.ts @@ -295,19 +295,21 @@ function triggerIncrementalCompilationOfFile( INCREMENTAL_FILE_FOLDER_LOCATION, ) as NormalizedPath; - // projectRootPath is already NormalizedPath, appending a constant string still makes it a NormalizedPath - let originalTypeFileLocation = path.resolve( + const relSourcePath = path.relative(projectRootPath, filePath); + const relSourceDir = path.dirname(relSourcePath); + const typeExt = ext === ".res" ? ".cmt" : ".cmti"; + const originalTypeFileName = + project.namespaceName != null + ? `${moduleName}-${project.namespaceName}${typeExt}` + : `${moduleName}${typeExt}`; + // projectRootPath is already NormalizedPath, appending constant strings still yields a NormalizedPath + const originalTypeFileLocation = path.resolve( projectRootPath, c.compilerDirPartialPath, - path.relative(projectRootPath, filePath), + relSourceDir, + originalTypeFileName, ) as NormalizedPath; - const parsed = path.parse(originalTypeFileLocation); - parsed.ext = ext === ".res" ? ".cmt" : ".cmti"; - parsed.base = ""; - // As originalTypeFileLocation was a NormalizedPath, path.format ensures we can assume string is now NormalizedPath - originalTypeFileLocation = path.format(parsed) as NormalizedPath; - incrementalFileCacheEntry = { file: { originalTypeFileLocation, From 0898a6b8b3d6b02c077a2453afe75d79e4a91b62 Mon Sep 17 00:00:00 2001 From: nojaf Date: Thu, 18 Dec 2025 09:41:48 +0100 Subject: [PATCH 2/3] Add changelog entry --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 01f980611..9930445ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,12 @@ > - :house: [Internal] > - :nail_care: [Polish] +## [Unreleased] + +#### :bug: Bug fix + +- Take namespace into account for incremental cleanup. https://github.com/rescript-lang/rescript-vscode/pull/1164 + ## 1.72.0 #### :bug: Bug fix From 750a28b0e75571fc54fa349b59014102b36ebc23 Mon Sep 17 00:00:00 2001 From: nojaf Date: Thu, 18 Dec 2025 09:50:43 +0100 Subject: [PATCH 3/3] Log server version on initialize --- server/src/server.ts | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/server/src/server.ts b/server/src/server.ts index 5eedee868..66572de0b 100644 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -29,7 +29,7 @@ import * as ic from "./incrementalCompilation"; import config, { extensionConfiguration, initialConfiguration } from "./config"; import { projectsFiles } from "./projectFiles"; import { NormalizedPath } from "./utils"; -import { initializeLogger, getLogger, setLogLevel, LogLevel } from "./logger"; +import { initializeLogger, getLogger, setLogLevel } from "./logger"; function applyUserConfiguration(configuration: extensionConfiguration) { // We always want to spread the initial configuration to ensure all defaults are respected. @@ -1285,27 +1285,30 @@ function openCompiledFile(msg: p.RequestMessage): p.Message { return response; } +async function getServerVersion(): Promise { + // Read the server version from package.json + let serverVersion: string | undefined; + try { + const packageJsonPath = path.join(__dirname, "..", "package.json"); + const packageJsonContent = await fsAsync.readFile(packageJsonPath, { + encoding: "utf-8", + }); + const packageJson: { version?: unknown } = JSON.parse(packageJsonContent); + serverVersion = + typeof packageJson.version === "string" ? packageJson.version : undefined; + } catch (e) { + // If we can't read the version, that's okay - we'll just omit it + serverVersion = undefined; + } + return serverVersion; +} + async function dumpServerState( msg: p.RequestMessage, ): Promise { // Custom debug endpoint: dump current server state (config + projectsFiles) try { - // Read the server version from package.json - let serverVersion: string | undefined; - try { - const packageJsonPath = path.join(__dirname, "..", "package.json"); - const packageJsonContent = await fsAsync.readFile(packageJsonPath, { - encoding: "utf-8", - }); - const packageJson: { version?: unknown } = JSON.parse(packageJsonContent); - serverVersion = - typeof packageJson.version === "string" - ? packageJson.version - : undefined; - } catch (e) { - // If we can't read the version, that's okay - we'll just omit it - serverVersion = undefined; - } + const serverVersion = await getServerVersion(); const projects = Array.from(projectsFiles.entries()).map( ([projectRootPath, pf]) => ({ @@ -1477,7 +1480,10 @@ async function onMessage(msg: p.Message) { }; send(response); } else if (msg.method === "initialize") { - getLogger().info("Received initialize request from client."); + const serverVersion = await getServerVersion(); + getLogger().info( + `Received initialize request from client. Server version: ${serverVersion}`, + ); // Save initial configuration, if present let initParams = msg.params as InitializeParams; for (const workspaceFolder of initParams.workspaceFolders || []) {