Skip to content

Commit

Permalink
[next] Fix resolveDependency on Windows (#1666)
Browse files Browse the repository at this point in the history
* fix: Windows issue with resolveDependency util

* chore: add comment
  • Loading branch information
natemoo-re authored Oct 27, 2021
1 parent a07a598 commit 9f44a51
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/astro/src/core/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { AstroConfig } from '../@types/astro-core';
import type { ErrorPayload } from 'vite';
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
import { fileURLToPath, pathToFileURL } from 'url';
import resolve from 'resolve';

/** Normalize URL to its canonical form */
Expand Down Expand Up @@ -76,7 +76,9 @@ export function codeFrame(src: string, loc: ErrorPayload['err']['loc']): string
}

export function resolveDependency(dep: string, astroConfig: AstroConfig) {
return resolve.sync(dep, {
const resolved = resolve.sync(dep, {
basedir: fileURLToPath(astroConfig.projectRoot)
});
}
// For Windows compat, we need a fully resolved `file://` URL string
return pathToFileURL(resolved).toString();
}

0 comments on commit 9f44a51

Please sign in to comment.