Skip to content

Commit

Permalink
docs: add experimental jsdoc to runtime APIs available from "vite" en…
Browse files Browse the repository at this point in the history
…try point
  • Loading branch information
sheremet-va committed Jan 31, 2024
1 parent 0573c0d commit 4c0d3fa
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/vite/src/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ export type {
ServerHMRChannel,
HMRBroadcasterClient,
} from './server/hmr'

export type { FetchFunction } from './ssr/runtime/index'
export { createViteRuntime } from './ssr/runtime/node/mainThreadRuntime'
export type { MainThreadRuntimeOptions } from './ssr/runtime/node/mainThreadRuntime'
Expand Down
3 changes: 2 additions & 1 deletion packages/vite/src/node/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,8 @@ export interface ViteDevServer {
opts?: { fixStacktrace?: boolean },
): Promise<Record<string, any>>
/**
* Fetch information about the module
* Fetch information about the module for Vite SSR runtime.
* @experimental
*/
ssrFetchModule(id: string, importer?: string): Promise<FetchResult>
/**
Expand Down
4 changes: 4 additions & 0 deletions packages/vite/src/node/ssr/fetchModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ export interface FetchModuleOptions {
processSourceMap?<T extends NonNullable<TransformResult['map']>>(map: T): T
}

/**
* Fetch module information for Vite runtime.
* @experimental
*/
export async function fetchModule(
server: ViteDevServer,
url: string,
Expand Down
7 changes: 7 additions & 0 deletions packages/vite/src/node/ssr/runtime/node/mainThreadRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import type { ViteModuleRunner, ViteRuntimeOptions } from '../types'
import type { HMRLogger } from '../../../../shared/hmr'
import { ServerHMRConnector } from './serverHmrConnector'

/**
* @experimental
*/
export interface MainThreadRuntimeOptions
extends Omit<ViteRuntimeOptions, 'root' | 'fetchModule' | 'hmr'> {
/**
Expand Down Expand Up @@ -60,6 +63,10 @@ function resolveSourceMapOptions(options: MainThreadRuntimeOptions) {
return prepareStackTrace
}

/**
* Create an instance of the Vite SSR runtime that support HMR.
* @experimental
*/
export async function createViteRuntime(
server: ViteDevServer,
options: MainThreadRuntimeOptions = {},
Expand Down
4 changes: 4 additions & 0 deletions packages/vite/src/node/ssr/runtime/node/serverHmrConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ class ServerHMRBroadcasterClient implements HMRBroadcasterClient {
}
}

/**
* The connector class to establish HMR communication between the server and the Vite runtime.
* @experimental
*/
export class ServerHMRConnector implements HMRRuntimeConnection {
private handlers: ((payload: HMRPayload) => void)[] = []
private hmrChannel: ServerHMRChannel
Expand Down
3 changes: 3 additions & 0 deletions packages/vite/src/node/ssr/runtime/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ export type ResolvedResult = (ExternalFetchResult | ViteFetchResult) & {
id: string
}

/**
* @experimental
*/
export type FetchFunction = (
id: string,
importer?: string,
Expand Down

0 comments on commit 4c0d3fa

Please sign in to comment.