Skip to content

Commit 14ca642

Browse files
author
Szymon.Poltorak
committed
fix: path resolution
1 parent 52e0e6b commit 14ca642

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

testing/test-setup-config/src/lib/vitest-tsconfig-path-aliases.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
import path from 'node:path';
2+
import { fileURLToPath } from 'node:url';
13
import { loadConfig } from 'tsconfig-paths';
24
import type { Alias, AliasOptions } from 'vite';
35

46
export function tsconfigPathAliases(projectRootUrl?: URL): AliasOptions {
57
const tsconfigPath = projectRootUrl
6-
? new URL('tsconfig.base.json', projectRootUrl).pathname
8+
? path.resolve(fileURLToPath(projectRootUrl), 'tsconfig.base.json')
79
: 'tsconfig.base.json';
810
const result = loadConfig(tsconfigPath);
911
if (result.resultType === 'failed') {
@@ -18,7 +20,7 @@ export function tsconfigPathAliases(projectRootUrl?: URL): AliasOptions {
1820
([importPath, relativePath]): Alias => ({
1921
find: importPath,
2022
replacement: projectRootUrl
21-
? new URL(relativePath, projectRootUrl).pathname
23+
? path.resolve(fileURLToPath(projectRootUrl), relativePath)
2224
: new URL(`../${relativePath}`, import.meta.url).pathname,
2325
}),
2426
);

0 commit comments

Comments
 (0)