Skip to content

Commit

Permalink
Account for directories
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewp committed Nov 17, 2022
1 parent 85ce341 commit 8e652dc
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/astro/src/vite-plugin-load-fallback/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down

0 comments on commit 8e652dc

Please sign in to comment.