Skip to content

Commit

Permalink
refactor: mark modules evalueated on promise (#2437)
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Dec 5, 2022
1 parent cbf91ba commit b1f734c
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions packages/vite-node/src/client.ts
Expand Up @@ -178,7 +178,11 @@ export class ViteNodeRunner {
return mod.promise

const promise = this.directRequest(id, fsPath, callstack)
Object.assign(mod, { promise })
Object.assign(mod, { promise, evaluated: false })

promise.finally(() => {
mod.evaluated = true
})

return await promise
}
Expand Down Expand Up @@ -246,7 +250,6 @@ export class ViteNodeRunner {
debugNative(externalize)
const exports = await this.interopedImport(externalize)
mod.exports = exports
mod.evaluated = true
return exports
}

Expand Down Expand Up @@ -347,12 +350,7 @@ export class ViteNodeRunner {
columnOffset: -codeDefinition.length,
})

try {
await fn(...Object.values(context))
}
finally {
mod.evaluated = true
}
await fn(...Object.values(context))

return exports
}
Expand Down

0 comments on commit b1f734c

Please sign in to comment.