Skip to content

Commit 6d6e46b

Browse files
authored
feat!: inline @vitest/runner package, do not publish it anymore (#10511)
1 parent 680ac2e commit 6d6e46b

148 files changed

Lines changed: 903 additions & 1274 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/api/advanced/runner.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export interface VitestRunner {
9595
/**
9696
* Publicly available configuration.
9797
*/
98-
config: VitestRunnerConfig
98+
config: SerializedConfig
9999
/**
100100
* The name of the current pool. Can affect how stack trace is inferred on the server side.
101101
*/

docs/api/advanced/vitest.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ This is a global [`ViteDevServer`](https://vite.dev/guide/api-javascript#vitedev
2727
Public `state` is an experimental API (except `vitest.state.getReportedEntity`). Breaking changes might not follow SemVer, please pin Vitest's version when using it.
2828
:::
2929

30-
Global state stores information about the current tests. It uses the same API from `@vitest/runner` by default, but we recommend using the [Reported Tasks API](/api/advanced/reporters#reported-tasks) instead by calling `state.getReportedEntity()` on the `@vitest/runner` API:
30+
Global state stores information about the current tests. It uses internal serializable Task API by default, but we recommend using the [Reported Tasks API](/api/advanced/reporters#reported-tasks) instead by calling `state.getReportedEntity()`:
3131

3232
```ts
3333
const task = vitest.state.idMap.get(taskId) // old API

packages/browser/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@
9292
"@types/node": "catalog:",
9393
"@types/pngjs": "^6.0.5",
9494
"@types/ws": "catalog:",
95-
"@vitest/runner": "workspace:*",
9695
"birpc": "catalog:",
9796
"flatted": "catalog:",
9897
"ivya": "^1.8.2",

packages/browser/src/client/channel.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import type { CancelReason, FileSpecification } from '@vitest/runner'
1+
import type { CancelReason } from 'vitest'
2+
import type { FileSpecification } from 'vitest/internal/browser'
23
import type { OTELCarrier } from 'vitest/internal/traces'
34
import { getBrowserState } from './utils'
45

packages/browser/src/client/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { ModuleMocker } from '@vitest/mocker/browser'
2-
import type { CancelReason } from '@vitest/runner'
32
import type { BirpcReturn } from 'birpc'
3+
import type { CancelReason } from 'vitest'
44
import type { MarkOptions } from 'vitest/browser'
55
import type { WebSocketBrowserEvents, WebSocketBrowserHandlers } from '../types'
66
import type { IframeOrchestrator } from './orchestrator'

packages/browser/src/client/orchestrator.ts

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import type { Context as OTELContext } from '@opentelemetry/api'
22
import type { GlobalChannelIncomingEvent, IframeChannelIncomingEvent, IframeChannelOutgoingEvent, IframeViewportDoneEvent, IframeViewportFailEvent } from '@vitest/browser/client'
3-
import type { FileSpecification } from '@vitest/runner'
43
import type { BrowserTesterOptions, SerializedConfig } from 'vitest'
4+
import type { FileSpecification } from 'vitest/internal/browser'
55
import { channel, client, globalChannel } from '@vitest/browser/client'
66
import { relative } from 'pathe'
77
import { Traces } from 'vitest/internal/traces'
8+
// This needs to be tree shaken properly to not include the whole runner by accident
9+
import { generateFileHash } from '../../../vitest/src/utils/tasks.js'
810
import { getUiAPI } from './ui'
911
import { getBrowserState, getConfig } from './utils'
1012

@@ -481,39 +483,6 @@ function generateFileId(file: string) {
481483
)
482484
}
483485

484-
// TODO: copied from packages/runner/src/utils/collect.ts
485-
interface HashMeta {
486-
typecheck?: boolean
487-
__vitest_label__?: string
488-
}
489-
490-
function generateFileHash(
491-
file: string,
492-
projectName: string | undefined,
493-
meta?: HashMeta,
494-
): string {
495-
const seed = [
496-
file,
497-
projectName || '',
498-
meta?.typecheck ? '__typecheck__' : '',
499-
meta?.__vitest_label__ || '',
500-
].join('\0')
501-
return generateHash(seed)
502-
}
503-
504-
function generateHash(str: string): string {
505-
let hash = 0
506-
if (str.length === 0) {
507-
return `${hash}`
508-
}
509-
for (let i = 0; i < str.length; i++) {
510-
const char = str.charCodeAt(i)
511-
hash = (hash << 5) - hash + char
512-
hash = hash & hash // Convert to 32bit integer
513-
}
514-
return `${hash}`
515-
}
516-
517486
async function setIframeViewport(
518487
width: number,
519488
height: number,

packages/browser/src/client/tester/expect/toMatchScreenshot.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import type { VisualRegressionArtifact } from '@vitest/runner'
2-
import type { AsyncMatcherResult, MatcherState } from 'vitest'
1+
import type { AsyncMatcherResult, MatcherState, VisualRegressionArtifact } from 'vitest'
32
import type { BrowserPage, ScreenshotMatcherOptions } from '../../../../context'
43
import type { ScreenshotMatcherArguments, ScreenshotMatcherOutput } from '../../../shared/screenshotMatcher/types'
54
import type { Locator } from '../locators'

packages/browser/src/client/tester/runner.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
import type {
22
CancelReason,
3-
File,
4-
Suite,
5-
Task,
6-
TaskEventPack,
7-
TaskResultPack,
8-
Test,
3+
RunnerTestFile as File,
4+
SerializedConfig,
5+
RunnerTestSuite as Suite,
6+
RunnerTask as Task,
7+
RunnerTaskEventPack as TaskEventPack,
8+
RunnerTaskResultPack as TaskResultPack,
9+
RunnerTestCase as Test,
910
TestAnnotation,
1011
TestArtifact,
12+
TestExecutionMethod,
1113
TestTryOptions,
12-
VitestRunner,
13-
} from '@vitest/runner'
14-
import type { SerializedConfig, TestExecutionMethod, WorkerGlobalState } from 'vitest'
14+
VitestTestRunner as VitestRunner,
15+
WorkerGlobalState,
16+
} from 'vitest'
1517
import type { VitestBrowserClientMocker } from './mocker'
1618
import type { CommandsManager } from './tester-utils'
1719
import { globalChannel, onCancel } from '@vitest/browser/client'
18-
import { getTestName } from '@vitest/runner/utils'
1920
import { recordArtifact, TestRunner } from 'vitest'
2021
import { page, userEvent } from 'vitest/browser'
2122
import {
@@ -26,6 +27,7 @@ import {
2627
takeCoverageInsideWorker,
2728
} from 'vitest/internal/browser'
2829
import { createStackString, parseStacktrace } from '../../../../utils/src/source-map'
30+
import { getTestName } from '../../../../vitest/src/utils/tasks'
2931
import { getBrowserState, getWorkerState, moduleRunner, now } from '../utils'
3032
import { rpc } from './rpc'
3133
import { VitestBrowserSnapshotEnvironment } from './snapshot'

packages/browser/src/client/tester/tester.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { BrowserRPC, IframeChannelEvent } from '@vitest/browser/client'
2-
import type { FileSpecification } from '@vitest/runner'
2+
import type { FileSpecification } from 'vitest/internal/browser'
33
import { channel, client, onCancel, registerPageMarkHandler } from '@vitest/browser/client'
44
import { parse } from 'flatted'
55
import { page, server, userEvent } from 'vitest/browser'

packages/browser/src/client/tester/trace.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Task } from '@vitest/runner'
1+
import type { RunnerTask as Task } from 'vitest'
22
import type { BrowserTraceEntryKind } from 'vitest/browser'
33
import type { BrowserRPC } from '../client'
44
import type { SerializedLocator } from './locators'

0 commit comments

Comments
 (0)