Skip to content
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
5 changes: 5 additions & 0 deletions .changeset/tender-spoons-sin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@flint.fyi/core": patch
---

Normalize file dependencies to ensure cache hits.
14 changes: 11 additions & 3 deletions packages/core/src/running/finalizeFileResults.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { debugForFile } from "debug-for-file";
import { resolve } from "node:path";

import { DirectivesFilterer } from "../directives/DirectivesFilterer.ts";
import { directiveReports } from "../directives/reports/directiveReports.ts";
import { normalizePath } from "../host/normalizePath.ts";
import type { LinterHost } from "../types/host.ts";
import type { LanguageFileDiagnostic } from "../types/languages.ts";
import type { FileReport } from "../types/reports.ts";
import type { LanguageAndFile } from "./types.ts";
Expand All @@ -19,6 +22,7 @@ export function finalizeFileResults(
filePath: string,
languageAndFiles: LanguageAndFile[],
reports: FileReport[],
host: LinterHost,
skipDiagnostics?: boolean,
) {
const directivesFilterer = new DirectivesFilterer();
Expand All @@ -35,9 +39,13 @@ export function finalizeFileResults(

if (cache?.dependencies) {
for (const dependency of cache.dependencies) {
if (!fileDependencies.has(dependency)) {
log("Adding file dependency %s for file %s", dependency, filePath);
fileDependencies.add(dependency);
const normalized = normalizePath(
resolve(dependency),
host.isCaseSensitiveFS(),
);
if (!fileDependencies.has(normalized)) {
log("Adding file dependency %s for file %s", normalized, filePath);
fileDependencies.add(normalized);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/running/runConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export async function runConfig(
filePath,
languageAndFiles,
reportsByFilePath.get(filePath).flat(),
host,
skipDiagnostics,
),
]),
Expand Down