Home / Function/ reloadOnTsconfigChange() — vite Function Reference

reloadOnTsconfigChange() — vite Function Reference

Architecture documentation for the reloadOnTsconfigChange() function in esbuild.ts from the vite codebase.

Entity Profile

Dependency Diagram

graph TD
  cd64b0f3_7332_3a75_1ff2_cc686e04a12b["reloadOnTsconfigChange()"]
  926e3b98_b813_2ff8_abb3_16447ab95544["esbuild.ts"]
  cd64b0f3_7332_3a75_1ff2_cc686e04a12b -->|defined in| 926e3b98_b813_2ff8_abb3_16447ab95544
  24ecf2a1_3c09_d451_76f3_9485b4e993f8["_createServer()"]
  24ecf2a1_3c09_d451_76f3_9485b4e993f8 -->|calls| cd64b0f3_7332_3a75_1ff2_cc686e04a12b
  3de29a47_1def_0c91_7d68_ab9432fe0bd3["getTSConfckCache()"]
  cd64b0f3_7332_3a75_1ff2_cc686e04a12b -->|calls| 3de29a47_1def_0c91_7d68_ab9432fe0bd3
  style cd64b0f3_7332_3a75_1ff2_cc686e04a12b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/vite/src/node/plugins/esbuild.ts lines 554–590

export async function reloadOnTsconfigChange(
  server: ViteDevServer,
  changedFile: string,
): Promise<void> {
  // any tsconfig.json that's added in the workspace could be closer to a code file than a previously cached one
  // any json file in the tsconfig cache could have been used to compile ts
  if (changedFile.endsWith('.json')) {
    const cache = getTSConfckCache(server.config)
    if (
      changedFile.endsWith('/tsconfig.json') ||
      cache.hasParseResult(changedFile)
    ) {
      server.config.logger.info(
        `changed tsconfig file detected: ${changedFile} - Clearing cache and forcing full-reload to ensure TypeScript is compiled with updated config values.`,
        { clear: server.config.clearScreen, timestamp: true },
      )

      // TODO: more finegrained invalidation than the nuclear option below

      // clear module graph to remove code compiled with outdated config
      for (const environment of Object.values(server.environments)) {
        environment.moduleGraph.invalidateAll()
      }

      // reset tsconfck cache so that recompile works with up2date configs
      cache.clear()

      // reload environments
      for (const environment of Object.values(server.environments)) {
        environment.hot.send({
          type: 'full-reload',
          path: '*',
        })
      }
    }
  }
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does reloadOnTsconfigChange() do?
reloadOnTsconfigChange() is a function in the vite codebase, defined in packages/vite/src/node/plugins/esbuild.ts.
Where is reloadOnTsconfigChange() defined?
reloadOnTsconfigChange() is defined in packages/vite/src/node/plugins/esbuild.ts at line 554.
What does reloadOnTsconfigChange() call?
reloadOnTsconfigChange() calls 1 function(s): getTSConfckCache.
What calls reloadOnTsconfigChange()?
reloadOnTsconfigChange() is called by 1 function(s): _createServer.

Analyze Your Own Codebase

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

Try Supermodel Free