From cef5a7fc8e93b904376aba1f5572b51848c1b0f4 Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Thu, 30 Jul 2026 03:10:50 +0530 Subject: [PATCH] refactor(loader): read content files with fs/promises createContentLoader already maps files with bounded concurrency, but the sync stat/read calls serialized the actual I/O. Co-Authored-By: Claude Fable 5 --- src/node/contentLoader.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/node/contentLoader.ts b/src/node/contentLoader.ts index 8b925132..7f4d1cb2 100644 --- a/src/node/contentLoader.ts +++ b/src/node/contentLoader.ts @@ -1,5 +1,5 @@ import matter from 'gray-matter' -import fs from 'node:fs' +import { readFile, stat } from 'node:fs/promises' import path from 'node:path' import pMap from 'p-map' import { normalizePath } from 'vite' @@ -116,12 +116,12 @@ export function createContentLoader( async (file) => { if (!file.endsWith('.md')) return null - const timestamp = fs.statSync(file).mtimeMs + const timestamp = (await stat(file)).mtimeMs const cached = cache.get(file) if (cached && timestamp === cached.timestamp) return cached.data - const src = fs.readFileSync(file, 'utf8') + const src = await readFile(file, 'utf8') const renderExcerpt = options.excerpt const { data: frontmatter, excerpt } = matter(