`readFile` through the LRU content cache (null = read failed, also cached).
(filePath: string)
| 825 | |
| 826 | /** `readFile` through the LRU content cache (null = read failed, also cached). */ |
| 827 | private readFileCached(filePath: string): string | null { |
| 828 | if (this.fileCache.has(filePath)) { |
| 829 | return this.fileCache.get(filePath)!; |
| 830 | } |
| 831 | const fullPath = path.join(this.projectRoot, filePath); |
| 832 | try { |
| 833 | // Import resolvers may follow package metadata to an archive (`file:*.har`, |
| 834 | // for example). Reject anything extraction would not accept before UTF-8 |
| 835 | // decoding can multiply a large binary blob into gigabytes of V8 heap. |
| 836 | const content = readSourceText(fullPath); |
| 837 | this.fileCache.set(filePath, content); |
| 838 | return content; |
| 839 | } catch (error) { |
| 840 | logDebug('Failed to read file for resolution', { filePath, error: String(error) }); |
| 841 | this.fileCache.set(filePath, null); |
| 842 | return null; |
| 843 | } |
| 844 | } |
| 845 | |
| 846 | /** |
| 847 | * `readFileCached(filePath)?.includes(needle)` for an ASCII needle, searched |
no test coverage detected