1- import { pathToFileURL } from 'node:url' ;
1+ import path from 'node:path' ;
2+ import { fileURLToPath , pathToFileURL } from 'node:url' ;
23import {
34 type UserConfig as ViteUserConfig ,
45 defineConfig ,
@@ -68,7 +69,9 @@ function toAbsolutePaths(
6869 paths ?: readonly string [ ] ,
6970) : string [ ] {
7071 return paths && paths . length > 0
71- ? paths . filter ( Boolean ) . map ( p => new URL ( p , projectRootUrl ) . pathname )
72+ ? paths
73+ . filter ( Boolean )
74+ . map ( p => path . resolve ( fileURLToPath ( projectRootUrl ) , p ) )
7275 : [ ] ;
7376}
7477
@@ -92,7 +95,7 @@ function defaultGlobalSetup(
9295) : string [ ] | undefined {
9396 return kind === 'e2e'
9497 ? undefined
95- : [ new URL ( 'global-setup.ts' , projectRootUrl ) . pathname ] ;
98+ : [ path . resolve ( fileURLToPath ( projectRootUrl ) , 'global-setup.ts' ) ] ;
9699}
97100
98101function buildCoverageConfig ( params : {
@@ -102,12 +105,12 @@ function buildCoverageConfig(params: {
102105 overrideExclude ?: string [ ] ;
103106} ) : CoverageOptions {
104107 const defaultExclude = [ 'mocks/**' , '**/types.ts' ] ;
105- const reportsDirectory = new URL (
108+ const reportsDirectory = path . resolve (
109+ fileURLToPath ( params . projectRootUrl ) ,
106110 params . kind === 'e2e'
107111 ? `e2e/${ params . projectKey } /.coverage`
108112 : `packages/${ params . projectKey } /.coverage/${ params . kind } -tests` ,
109- params . projectRootUrl ,
110- ) . pathname ;
113+ ) ;
111114 return {
112115 reporter : [ 'text' , 'lcov' ] ,
113116 reportsDirectory,
@@ -128,15 +131,18 @@ function buildBaseConfig(params: {
128131 overrideExclude : string [ ] ;
129132} ) : VitestOverrides {
130133 const cfg : VitestOverrides = {
131- cacheDir : new URL (
134+ cacheDir : path . resolve (
135+ fileURLToPath ( params . projectRootUrl ) ,
132136 `node_modules/.vite/${ params . cacheDirName } ` ,
133- params . projectRootUrl ,
134- ) . pathname ,
137+ ) ,
135138 test : {
136139 reporters : [ 'basic' ] ,
137140 globals : true ,
138141 cache : {
139- dir : new URL ( 'node_modules/.vitest' , params . projectRootUrl ) . pathname ,
142+ dir : path . resolve (
143+ fileURLToPath ( params . projectRootUrl ) ,
144+ 'node_modules/.vitest' ,
145+ ) ,
140146 } ,
141147 alias : tsconfigPathAliases ( params . projectRootUrl ) ,
142148 pool : 'threads' ,
0 commit comments