Skip to content

Commit

Permalink
chore: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Aug 15, 2024
1 parent bc9887b commit 9ff4d79
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 21 deletions.
10 changes: 0 additions & 10 deletions packages/browser/src/node/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,6 @@ export function setupBrowserRpc(server: BrowserServer) {
}
}

function invalidateModuleById(id: string) {
const moduleGraph = server.vite.moduleGraph
const module = moduleGraph.getModuleById(id)
if (module) {
moduleGraph.invalidateModule(module, new Set(), Date.now(), true)
return true
}
return false
}

function setupClient(sessionId: string, ws: WebSocket) {
const mockResolver = new ServerMockResolver(server.vite, {
moduleDirectories: project.config.server?.deps?.moduleDirectories,
Expand Down
3 changes: 1 addition & 2 deletions packages/browser/src/node/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { ServerIdResolution, ServerMockResolution } from '@vitest/mocker/node'
import type { BirpcReturn } from 'birpc'
import type { AfterSuiteRunMeta, CancelReason, RunnerTestFile, SnapshotResult, TaskResultPack, UserConsoleLog } from 'vitest'
import type { Reporter } from 'vitest/reporters'
import type { AfterSuiteRunMeta, CancelReason, Reporter, RunnerTestFile, SnapshotResult, TaskResultPack, UserConsoleLog } from 'vitest'

export interface WebSocketBrowserHandlers {
resolveSnapshotPath: (testPath: string) => string
Expand Down
2 changes: 1 addition & 1 deletion packages/mocker/src/node/esmWalker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export function esmWalker(
}
}

eswalk(root, {
eswalk(root as Node, {
enter(node, parent) {
if (node.type === 'ImportDeclaration') {
return this.skip()
Expand Down
9 changes: 1 addition & 8 deletions packages/mocker/src/node/hoistMocksPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import type {
ImportDeclaration,
ImportExpression,
VariableDeclaration,
Node as _Node,
} from 'estree'
import { findNodeAround } from 'acorn-walk'
import type { Plugin, Rollup } from 'vite'
import { createFilter } from 'vite'
import type { Node, Positioned } from './esmWalker'
import { esmWalker } from './esmWalker'

export interface HoistMocksPluginOptions {
Expand Down Expand Up @@ -64,13 +64,6 @@ export function hoistMocksPlugin(options: HoistMocksPluginOptions = {}): Plugin
}
}

type Positioned<T> = T & {
start: number
end: number
}

type Node = Positioned<_Node>

const API_NOT_FOUND_ERROR = `There are some problems in resolving the mocks API.
You may encounter this issue when importing the mocks API from another module other than 'vitest'.
To fix this issue you can either:
Expand Down

0 comments on commit 9ff4d79

Please sign in to comment.