[next] Fix resolveDependency
on Windows (#1666)
* fix: Windows issue with resolveDependency util * chore: add comment
This commit is contained in:
parent
a07a598122
commit
9f44a513ee
1 changed files with 5 additions and 3 deletions
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue