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: don't import vite in worker #2759

Merged
merged 4 commits into from Jan 27, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/vitest/src/runtime/execute.ts
@@ -1,7 +1,7 @@
import { ViteNodeRunner } from 'vite-node/client'
import { isInternalRequest } from 'vite-node/utils'
import type { ViteNodeRunnerOptions } from 'vite-node'
import { normalizePath } from 'vite'
import { normalize } from 'pathe'
import { isNodeBuiltin } from 'mlly'
import type { MockMap } from '../types/mocker'
import { getCurrentEnvironment, getWorkerState } from '../utils'
Expand Down Expand Up @@ -68,7 +68,7 @@ export class VitestRunner extends ViteNodeRunner {
const workerState = getWorkerState()

// support `import.meta.vitest` for test entry
if (workerState.filepath && normalizePath(workerState.filepath) === normalizePath(context.__filename)) {
if (workerState.filepath && normalize(workerState.filepath) === normalize(context.__filename)) {
// @ts-expect-error injected untyped global
Object.defineProperty(context.__vite_ssr_import_meta__, 'vitest', { get: () => globalThis.__vitest_index__ })
}
Expand Down