Home / File/ moduleGraph.ts — vite Source File

moduleGraph.ts — vite Source File

Architecture documentation for moduleGraph.ts, a typescript file in the vite codebase. 14 imports, 9 dependents.

File typescript ViteCore ConfigEngine 14 imports 9 dependents 2 classes

Entity Profile

Dependency Diagram

graph LR
  a3adc511_3c03_7f25_9d76_5d3ed9987eb5["moduleGraph.ts"]
  c3eb47df_971b_0616_6c9f_29b3ded72224["css.ts"]
  a3adc511_3c03_7f25_9d76_5d3ed9987eb5 --> c3eb47df_971b_0616_6c9f_29b3ded72224
  234581fb_7a15_7750_8a19_e6fefe7d215b["isDirectCSSRequest"]
  a3adc511_3c03_7f25_9d76_5d3ed9987eb5 --> 234581fb_7a15_7750_8a19_e6fefe7d215b
  031bc221_67a8_c579_f2bf_bb30a08beeb2["utils.ts"]
  a3adc511_3c03_7f25_9d76_5d3ed9987eb5 --> 031bc221_67a8_c579_f2bf_bb30a08beeb2
  74ee9886_2456_3964_e90e_5fc67925229d["monotonicDateNow"]
  a3adc511_3c03_7f25_9d76_5d3ed9987eb5 --> 74ee9886_2456_3964_e90e_5fc67925229d
  a4adb1a7_cf54_091f_eb63_8217e684a8e1["normalizePath"]
  a3adc511_3c03_7f25_9d76_5d3ed9987eb5 --> a4adb1a7_cf54_091f_eb63_8217e684a8e1
  92b179fa_3139_d3e0_f865_77312413686b["removeImportQuery"]
  a3adc511_3c03_7f25_9d76_5d3ed9987eb5 --> 92b179fa_3139_d3e0_f865_77312413686b
  3f57c8be_be57_4cf4_aa11_4ed077229c70["removeTimestampQuery"]
  a3adc511_3c03_7f25_9d76_5d3ed9987eb5 --> 3f57c8be_be57_4cf4_aa11_4ed077229c70
  545df65b_7f67_94d3_e2e8_a592d5e64b8f["constants.ts"]
  a3adc511_3c03_7f25_9d76_5d3ed9987eb5 --> 545df65b_7f67_94d3_e2e8_a592d5e64b8f
  abfc9e70_3c15_b3f0_a595_3cf27afb7e64["utils.ts"]
  a3adc511_3c03_7f25_9d76_5d3ed9987eb5 --> abfc9e70_3c15_b3f0_a595_3cf27afb7e64
  10b9dea8_362c_1af2_93be_afa4dd9aed9e["cleanUrl"]
  a3adc511_3c03_7f25_9d76_5d3ed9987eb5 --> 10b9dea8_362c_1af2_93be_afa4dd9aed9e
  ee4fcff9_3096_e290_234c_be9d1a2c8a4b["transformRequest.ts"]
  a3adc511_3c03_7f25_9d76_5d3ed9987eb5 --> ee4fcff9_3096_e290_234c_be9d1a2c8a4b
  0d0da384_0353_2feb_0949_4e35f8f5b097["TransformResult"]
  a3adc511_3c03_7f25_9d76_5d3ed9987eb5 --> 0d0da384_0353_2feb_0949_4e35f8f5b097
  51e96894_3556_ed5c_1ede_97d449867adf["node:path"]
  a3adc511_3c03_7f25_9d76_5d3ed9987eb5 --> 51e96894_3556_ed5c_1ede_97d449867adf
  693ca867_249b_3e5a_0ce1_8930413b7fcd["rolldown"]
  a3adc511_3c03_7f25_9d76_5d3ed9987eb5 --> 693ca867_249b_3e5a_0ce1_8930413b7fcd
  style a3adc511_3c03_7f25_9d76_5d3ed9987eb5 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { extname } from 'node:path'
import type { ModuleInfo, PartialResolvedId } from 'rolldown'
import { isDirectCSSRequest } from '../plugins/css'
import {
  monotonicDateNow,
  normalizePath,
  removeImportQuery,
  removeTimestampQuery,
} from '../utils'
import { FS_PREFIX } from '../constants'
import { cleanUrl } from '../../shared/utils'
import type { TransformResult } from './transformRequest'

export class EnvironmentModuleNode {
  environment: string
  /**
   * Public served url path, starts with /
   */
  url: string
  /**
   * Resolved file system path + query
   */
  id: string | null = null
  file: string | null = null
  type: 'js' | 'css' | 'asset'
  info?: ModuleInfo
  meta?: Record<string, any>
  importers: Set<EnvironmentModuleNode> = new Set()

  importedModules: Set<EnvironmentModuleNode> = new Set()

  acceptedHmrDeps: Set<EnvironmentModuleNode> = new Set()
  acceptedHmrExports: Set<string> | null = null
  importedBindings: Map<string, Set<string>> | null = null
  isSelfAccepting?: boolean
  transformResult: TransformResult | null = null

  // ssrModule and ssrError are no longer needed. They are on the module runner module cache.
  // Once `ssrLoadModule` is re-implemented on top of the new APIs, we can delete these.
  ssrModule: Record<string, any> | null = null
  ssrError: Error | null = null

  lastHMRTimestamp = 0
  /**
   * `import.meta.hot.invalidate` is called by the client.
   * If there's multiple clients, multiple `invalidate` request is received.
   * This property is used to dedupe those request to avoid multiple updates happening.
   * @internal
   */
  lastHMRInvalidationReceived = false
  lastInvalidationTimestamp = 0
  /**
   * If the module only needs to update its imports timestamp (e.g. within an HMR chain),
   * it is considered soft-invalidated. In this state, its `transformResult` should exist,
   * and the next `transformRequest` for this module will replace the timestamps.
   *
   * By default the value is `undefined` if it's not soft/hard-invalidated. If it gets
   * soft-invalidated, this will contain the previous `transformResult` value. If it gets
   * hard-invalidated, this will be set to `'HARD_INVALIDATED'`.
   * @internal
// ... (430 more lines)

Domain

Subdomains

Types

Frequently Asked Questions

What does moduleGraph.ts do?
moduleGraph.ts is a source file in the vite codebase, written in typescript. It belongs to the ViteCore domain, ConfigEngine subdomain.
What does moduleGraph.ts depend on?
moduleGraph.ts imports 14 module(s): TransformResult, cleanUrl, constants.ts, css.ts, isDirectCSSRequest, monotonicDateNow, node:path, normalizePath, and 6 more.
What files import moduleGraph.ts?
moduleGraph.ts is imported by 9 file(s): css.ts, environment.ts, hmr.ts, importMetaGlob.ts, mixedModuleGraph.ts, moduleGraph.spec.ts, plugin.ts, pluginContainer.ts, and 1 more.
Where is moduleGraph.ts in the architecture?
moduleGraph.ts is located at packages/vite/src/node/server/moduleGraph.ts (domain: ViteCore, subdomain: ConfigEngine, directory: packages/vite/src/node/server).

Analyze Your Own Codebase

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

Try Supermodel Free