[next] Fix resolveDependency on Windows (#1666)

* fix: Windows issue with resolveDependency util

* chore: add comment
This commit is contained in:
Nate Moore 2021-10-27 09:11:20 -07:00 committed by GitHub
parent a07a598122
commit 9f44a513ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 */
@ -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();
}