Skip to content

Commit

Permalink
chore: fix cached vite-node
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Jun 22, 2023
1 parent fd0722c commit cfb60f8
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions packages/vitest/src/runtime/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { processError } from '@vitest/utils/error'
import type { MockMap } from '../types/mocker'
import type { ContextRPC, ContextTestEnvironment, ResolvedConfig, WorkerGlobalState } from '../types'
import { distDir } from '../paths'
import { getWorkerState } from '../utils/global'
import { VitestMocker } from './mocker'
import { ExternalModulesExecutor } from './external-executor'

Expand Down Expand Up @@ -60,7 +61,7 @@ export interface ContextExecutorOptions {
export async function startVitestExecutor(ctx: ContextRPC, options: ContextExecutorOptions) {
const { config } = ctx

const rpc = () => options.state.rpc
const rpc = () => getWorkerState().rpc

const processExit = process.exit

Expand All @@ -87,17 +88,19 @@ export async function startVitestExecutor(ctx: ContextRPC, options: ContextExecu

return await createVitestExecutor({
fetchModule(id) {
return rpc().fetch(id, ctx.environment.name)
const state = getWorkerState()
return rpc().fetch(id, state.environment)
},
resolveId(id, importer) {
return rpc().resolveId(id, importer, ctx.environment.name)
const state = getWorkerState()
return rpc().resolveId(id, importer, state.environment)
},
moduleCache,
mockMap,
interopDefault: config.deps.interopDefault,
moduleDirectories: config.deps.moduleDirectories,
root: config.root,
base: config.base,
get interopDefault() { return config.deps.interopDefault },
get moduleDirectories() { return config.deps.moduleDirectories },
get root() { return config.root },
get base() { return config.base },
...options,
})
}
Expand Down

0 comments on commit cfb60f8

Please sign in to comment.