Home / File/ invokeMethods.ts — vite Source File

invokeMethods.ts — vite Source File

Architecture documentation for invokeMethods.ts, a typescript file in the vite codebase. 0 imports, 4 dependents.

File typescript HMRClient WebSocketTransport 4 dependents 2 functions

Entity Profile

Dependency Diagram

graph LR
  e967e251_52a9_6dc8_9c8c_4a18ba126272["invokeMethods.ts"]
  bf48f7e9_65f6_54c3_7dce_f44769180bd7["types.ts"]
  bf48f7e9_65f6_54c3_7dce_f44769180bd7 --> e967e251_52a9_6dc8_9c8c_4a18ba126272
  18db4f26_79f1_5b7d_b291_4feeaf95538f["hmr.ts"]
  18db4f26_79f1_5b7d_b291_4feeaf95538f --> e967e251_52a9_6dc8_9c8c_4a18ba126272
  02c9d455_3ec0_f4e3_4293_04777d5340b3["server-runtime.spec.ts"]
  02c9d455_3ec0_f4e3_4293_04777d5340b3 --> e967e251_52a9_6dc8_9c8c_4a18ba126272
  a469d907_868c_e1c2_3f7a_7aaf42cc6a7a["moduleRunnerTransport.ts"]
  a469d907_868c_e1c2_3f7a_7aaf42cc6a7a --> e967e251_52a9_6dc8_9c8c_4a18ba126272
  style e967e251_52a9_6dc8_9c8c_4a18ba126272 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

export interface FetchFunctionOptions {
  cached?: boolean
  startOffset?: number
}

export type FetchResult =
  | CachedFetchResult
  | ExternalFetchResult
  | ViteFetchResult

export interface CachedFetchResult {
  /**
   * If module cached in the runner, we can just confirm
   * it wasn't invalidated on the server side.
   */
  cache: true
}

export interface ExternalFetchResult {
  /**
   * The path to the externalized module starting with file://,
   * by default this will be imported via a dynamic "import"
   * instead of being transformed by vite and loaded with vite runner
   */
  externalize: string
  /**
   * Type of the module. Will be used to determine if import statement is correct.
   * For example, if Vite needs to throw an error if variable is not actually exported
   */
  type: 'module' | 'commonjs' | 'builtin' | 'network'
}

export interface ViteFetchResult {
  /**
   * Code that will be evaluated by vite runner
   * by default this will be wrapped in an async function
   */
  code: string
  /**
   * File path of the module on disk.
   * This will be resolved as import.meta.url/filename
   * Will be equal to `null` for virtual modules
   */
  file: string | null
  /**
   * Module ID in the server module graph.
   */
  id: string
  /**
   * Module URL used in the import.
   */
  url: string
  /**
   * Invalidate module on the client side.
   */
  invalidate: boolean
}

export type InvokeSendData<
  T extends keyof InvokeMethods = keyof InvokeMethods,
> = {
  name: T
  /** 'send' is for requests without an id */
  id: 'send' | `send:${string}`
  data: Parameters<InvokeMethods[T]>
}

export type InvokeResponseData<
  T extends keyof InvokeMethods = keyof InvokeMethods,
> = {
  name: T
  /** 'response' is for responses without an id */
  id: 'response' | `response:${string}`
  data:
    | { result: Awaited<ReturnType<InvokeMethods[T]>>; error?: undefined }
    | { result?: undefined; error: any }
}

export type InvokeMethods = {
  fetchModule: (
    id: string,
    importer?: string,
    options?: FetchFunctionOptions,
  ) => Promise<FetchResult>

  getBuiltins: () => Promise<
    Array<
      | { type: 'string'; value: string }
      | { type: 'RegExp'; source: string; flags: string }
    >
  >
}

Domain

Subdomains

Functions

Frequently Asked Questions

What does invokeMethods.ts do?
invokeMethods.ts is a source file in the vite codebase, written in typescript. It belongs to the HMRClient domain, WebSocketTransport subdomain.
What functions are defined in invokeMethods.ts?
invokeMethods.ts defines 2 function(s): Promise, id.
What files import invokeMethods.ts?
invokeMethods.ts is imported by 4 file(s): hmr.ts, moduleRunnerTransport.ts, server-runtime.spec.ts, types.ts.
Where is invokeMethods.ts in the architecture?
invokeMethods.ts is located at packages/vite/src/shared/invokeMethods.ts (domain: HMRClient, subdomain: WebSocketTransport, directory: packages/vite/src/shared).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free