Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: improve performance of forks pool #5592

Merged
merged 10 commits into from
May 1, 2024
Prev Previous commit
Next Next commit
chore: fix web-worker fetchModule
  • Loading branch information
sheremet-va committed May 1, 2024
commit b1d6cbe418e9ea2f8be784d143582eb8f8900c4d
10 changes: 8 additions & 2 deletions packages/web-worker/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { readFile } from 'node:fs/promises'
import type { WorkerGlobalState } from 'vitest'
import ponyfillStructuredClone from '@ungap/structured-clone'
import createDebug from 'debug'
Expand Down Expand Up @@ -65,8 +66,13 @@ export function getRunnerOptions(): any {
const { config, rpc, mockMap, moduleCache } = state

return {
fetchModule(id: string) {
return rpc.fetch(id, 'web')
async fetchModule(id: string) {
const result = await rpc.fetch(id, 'web')
if (result.id && !result.externalize) {
const code = await readFile(result.id, 'utf-8')
return { code }
}
return result
},
resolveId(id: string, importer?: string) {
return rpc.resolveId(id, importer, 'web')
Expand Down