Skip to content

Commit

Permalink
chore: wait only not evaluated modules
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Nov 28, 2022
1 parent 53e119e commit a9ab9df
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/vite-node/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ export class ViteNodeRunner {
},
})

Object.assign(mod, { code: transformed, exports })
Object.assign(mod, { code: transformed, exports, evaluated: false })

const __filename = fileURLToPath(url)
const moduleProxy = {
Expand Down Expand Up @@ -349,6 +349,8 @@ export class ViteNodeRunner {

await fn(...Object.values(context))

mod.evaluated = true

return exports
}

Expand Down
1 change: 1 addition & 0 deletions packages/vite-node/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export type CreateHotContextFunction = (runner: ViteNodeRunner, url: string) =>
export interface ModuleCache {
promise?: Promise<any>
exports?: any
evaluated?: boolean
code?: string
map?: RawSourceMap
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest/src/integrations/vi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ class VitestUtils {
const state = getWorkerState()
const promises: Promise<unknown>[] = []
for (const mod of state.moduleCache.values()) {
if (mod.promise)
if (mod.promise && !mod.evaluated)
promises.push(mod.promise)
}
if (!promises.length)
Expand Down

0 comments on commit a9ab9df

Please sign in to comment.