diff --git a/packages/vitest/package.json b/packages/vitest/package.json index 7c85ff2c45e8..74bf14bdd93d 100644 --- a/packages/vitest/package.json +++ b/packages/vitest/package.json @@ -184,7 +184,6 @@ "birpc": "0.2.14", "chai-subset": "^1.6.0", "cli-truncate": "^3.1.0", - "event-target-polyfill": "^0.0.3", "execa": "^7.1.1", "expect-type": "^0.16.0", "fast-glob": "^3.3.0", diff --git a/packages/vitest/src/runtime/runners/benchmark.ts b/packages/vitest/src/runtime/runners/benchmark.ts index 5ac05565cc65..8ad538863fe3 100644 --- a/packages/vitest/src/runtime/runners/benchmark.ts +++ b/packages/vitest/src/runtime/runners/benchmark.ts @@ -8,13 +8,6 @@ import type { BenchTask, Benchmark, BenchmarkResult } from '../../types/benchmar import type { ResolvedConfig } from '../../types/config' import type { VitestExecutor } from '../execute' -async function importTinybench() { - if (!globalThis.EventTarget) - await import('event-target-polyfill' as any) - - return (await import('tinybench')) -} - function createBenchmarkResult(name: string): BenchmarkResult { return { name, @@ -26,8 +19,9 @@ function createBenchmarkResult(name: string): BenchmarkResult { const benchmarkTasks = new WeakMap() -async function runBenchmarkSuite(suite: Suite, runner: VitestRunner) { - const { Task, Bench } = await importTinybench() +async function runBenchmarkSuite(suite: Suite, runner: NodeBenchmarkRunner) { + const { Task, Bench } = await runner.importTinybench() + const start = performance.now() const benchmarkGroup: Benchmark[] = [] @@ -132,6 +126,10 @@ export class NodeBenchmarkRunner implements VitestRunner { constructor(public config: ResolvedConfig) {} + async importTinybench() { + return await import('tinybench') + } + importFile(filepath: string, source: VitestRunnerImportSource): unknown { if (source === 'setup') getWorkerState().moduleCache.delete(filepath) diff --git a/packages/vitest/src/types/config.ts b/packages/vitest/src/types/config.ts index f20aeb446592..eba3a1ec2d2e 100644 --- a/packages/vitest/src/types/config.ts +++ b/packages/vitest/src/types/config.ts @@ -736,10 +736,7 @@ export interface ResolvedConfig extends Omit, 'config' | 'f api?: ApiConfig - benchmark?: Required> & { - outputFile?: BenchmarkUserOptions['outputFile'] - } - + benchmark?: Required> & Pick shard?: { index: number count: number diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3dd05ae6979b..fde3e6b88fe7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1428,9 +1428,6 @@ importers: cli-truncate: specifier: ^3.1.0 version: 3.1.0 - event-target-polyfill: - specifier: ^0.0.3 - version: 0.0.3 execa: specifier: ^7.1.1 version: 7.1.1 @@ -17202,10 +17199,6 @@ packages: engines: {node: '>= 0.6'} dev: true - /event-target-polyfill@0.0.3: - resolution: {integrity: sha512-ZMc6UuvmbinrCk4RzGyVmRyIsAyxMRlp4CqSrcQRO8Dy0A9ldbiRy5kdtBj4OtP7EClGdqGfIqo9JmOClMsGLQ==} - dev: true - /event-target-shim@5.0.1: resolution: {integrity: sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==} engines: {node: '>=6'}