From 8e652dcdc9e4f518046efac07e1c7ea56b5cc5d3 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Thu, 17 Nov 2022 09:54:23 -0500 Subject: [PATCH] Account for directories --- packages/astro/src/vite-plugin-load-fallback/index.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/astro/src/vite-plugin-load-fallback/index.ts b/packages/astro/src/vite-plugin-load-fallback/index.ts index d1892ccfa8ea..6a37af223074 100644 --- a/packages/astro/src/vite-plugin-load-fallback/index.ts +++ b/packages/astro/src/vite-plugin-load-fallback/index.ts @@ -46,9 +46,13 @@ export default function loadFallbackPlugin({ // See if this can be loaded from our fs if (parent) { const candidateId = npath.posix.join(npath.posix.dirname(parent), id); - if(fs.existsSync(candidateId)) { - return candidateId; - } + try { + // Check to see if this file exists and is not a directory. + const stats = await fs.promises.stat(candidateId); + if(!stats.isDirectory()) { + return candidateId; + } + } catch {} } let resolved = await this.resolve(id, parent, { skipSelf: true });