Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 11 additions & 9 deletions server/src/incrementalCompilation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading