File tree 2 files changed +19
-12
lines changed 2 files changed +19
-12
lines changed Original file line number Diff line number Diff line change 1
1
import { resolve } from 'path' ;
2
+ import { pathToFileURL } from 'url' ;
2
3
import { describe , expect , it } from 'vitest' ;
3
4
import { testLibRootPath } from '../../test/util' ;
4
5
import { loadLibrary , tryLoadDynamicLibrary } from './loadLibrary' ;
@@ -22,15 +23,17 @@ describe('loadLibrary', () => {
22
23
23
24
expect ( rest ) . toEqual ( {
24
25
fallback : false ,
25
- path : resolve (
26
- testLibRootPath ,
27
- 'v11' ,
28
- 'node_modules' ,
29
- '@commitlint' ,
30
- 'load' ,
31
- 'lib' ,
32
- 'load.js' ,
33
- ) ,
26
+ path : pathToFileURL (
27
+ resolve (
28
+ testLibRootPath ,
29
+ 'v11' ,
30
+ 'node_modules' ,
31
+ '@commitlint' ,
32
+ 'load' ,
33
+ 'lib' ,
34
+ 'load.js' ,
35
+ ) ,
36
+ ) . href ,
34
37
} ) ;
35
38
36
39
expect ( await result ) . toMatchObject ( expect . any ( Function ) ) ;
Original file line number Diff line number Diff line change 1
1
import { resolve } from 'path' ;
2
+ import { pathToFileURL } from 'url' ;
2
3
import type { IpcRequestContext } from '../ipcTypes' ;
3
4
import { getPrefixForLibraryLoad } from './utils/getPrefixForLibraryLoad' ;
4
5
import { getSystemGlobalLibraryPath } from './utils/getSystemGlobalLibraryPath' ;
@@ -54,10 +55,13 @@ export const tryLoadDynamicLibrary = <T>(
54
55
] ,
55
56
} ) ;
56
57
57
- log ( `loading ${ name } dynamically via ${ resolvePath } ` ) ;
58
+ // Ensure the path is importable, e.g., on Windows
59
+ const pathHref = pathToFileURL ( resolvePath ) . href ;
60
+
61
+ log ( `loading ${ name } dynamically via ${ pathHref } ` ) ;
58
62
return {
59
- result : importDefaultExport < T > ( resolvePath ) ,
60
- path : resolvePath ,
63
+ result : importDefaultExport < T > ( pathHref ) ,
64
+ path : pathHref ,
61
65
fallback : false ,
62
66
} ;
63
67
} catch ( e ) {
You can’t perform that action at this time.
0 commit comments