File tree 1 file changed +4
-2
lines changed
packages/vitest/src/node/pools
1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change
1
+ import { createHash } from 'node:crypto'
1
2
import { mkdir , writeFile } from 'node:fs/promises'
2
3
import type { RawSourceMap } from 'vite-node'
3
4
import { join } from 'pathe'
@@ -30,14 +31,15 @@ export function createMethodsRPC(project: WorkspaceProject): RuntimeRPC {
30
31
const code = result . code
31
32
if ( result . externalize )
32
33
return result
33
- if ( 'id' in result )
34
+ if ( 'id' in result && typeof result . id === 'string' )
34
35
return { id : result . id as string }
35
36
36
37
if ( ! code )
37
38
throw new Error ( `Failed to fetch module ${ id } ` )
38
39
39
40
const dir = join ( project . tmpDir , transformMode )
40
- const tmp = join ( dir , id . replace ( / [ / \\ ? % * : | " < > ] / g, '_' ) . replace ( '\0' , '__x00__' ) )
41
+ const name = createHash ( 'sha1' ) . update ( id ) . digest ( 'hex' )
42
+ const tmp = join ( dir , name )
41
43
if ( promises . has ( tmp ) ) {
42
44
await promises . get ( tmp )
43
45
return { id : tmp }
You can’t perform that action at this time.
0 commit comments