mirror of
https://github.com/withastro/astro.git
synced 2025-01-20 22:12:38 -05:00
[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 type { ErrorPayload } from 'vite';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath, pathToFileURL } from 'url';
|
||||||
import resolve from 'resolve';
|
import resolve from 'resolve';
|
||||||
|
|
||||||
/** Normalize URL to its canonical form */
|
/** 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) {
|
export function resolveDependency(dep: string, astroConfig: AstroConfig) {
|
||||||
return resolve.sync(dep, {
|
const resolved = resolve.sync(dep, {
|
||||||
basedir: fileURLToPath(astroConfig.projectRoot)
|
basedir: fileURLToPath(astroConfig.projectRoot)
|
||||||
});
|
});
|
||||||
}
|
// For Windows compat, we need a fully resolved `file://` URL string
|
||||||
|
return pathToFileURL(resolved).toString();
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue