From 4b7d30c4888c58a1a17084e1b192f15361746fdc Mon Sep 17 00:00:00 2001 From: jp-knj Date: Mon, 2 Feb 2026 14:15:50 +0900 Subject: [PATCH] fix(astro-markflow): use static import for writeFile in buildEnd hook The dynamic `await import('node:fs/promises')` in buildEnd goes through Vite's module runner, which is already closed by the time buildEnd fires. Use the static import already available at the top of the file. Co-Authored-By: Claude Opus 4.5 --- packages/astro-markflow/src/vite-plugin.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/astro-markflow/src/vite-plugin.ts b/packages/astro-markflow/src/vite-plugin.ts index 5bbb6cf..fbe3d8d 100644 --- a/packages/astro-markflow/src/vite-plugin.ts +++ b/packages/astro-markflow/src/vite-plugin.ts @@ -3,7 +3,7 @@ * @module vite-plugin */ -import { readFile } from 'node:fs/promises'; +import { readFile, writeFile } from 'node:fs/promises'; import { createRequire } from 'node:module'; import path from 'node:path'; import { transformWithEsbuild, type ResolvedConfig, type Plugin } from 'vite'; @@ -919,7 +919,6 @@ export function markflowPlugin(userOptions: MarkflowPluginOptions = {}): Plugin }, }; - const { writeFile } = await import('node:fs/promises'); const outputPath = path.join(resolvedConfig?.root ?? '.', 'markflow-stats.json'); await writeFile(outputPath, JSON.stringify(stats, null, 2)); console.info(`[markflow] Stats written to ${outputPath}`);