`readFile` through the LRU content cache (null = read failed, also cached).
(filePath: string)
| 923 | |
| 924 | /** `readFile` through the LRU content cache (null = read failed, also cached). */ |
| 925 | private readFileCached(filePath: string): string | null { |
| 926 | if (this.fileCache.has(filePath)) { |
| 927 | return this.fileCache.get(filePath)!; |
| 928 | } |
| 929 | const fullPath = path.join(this.projectRoot, filePath); |
| 930 | try { |
| 931 | // Import resolvers may follow package metadata to an archive (`file:*.har`, |
| 932 | // for example). Reject anything extraction would not accept before UTF-8 |
| 933 | // decoding can multiply a large binary blob into gigabytes of V8 heap. |
| 934 | const content = readSourceText(fullPath); |
| 935 | this.fileCache.set(filePath, content); |
| 936 | return content; |
| 937 | } catch (error) { |
| 938 | logDebug('Failed to read file for resolution', { filePath, error: String(error) }); |
| 939 | this.fileCache.set(filePath, null); |
| 940 | return null; |
| 941 | } |
| 942 | } |
| 943 | |
| 944 | /** |
| 945 | * `readFileCached(filePath)?.includes(needle)` for an ASCII needle, searched |
no test coverage detected