hmr.ts — vite Source File
Architecture documentation for hmr.ts, a typescript file in the vite codebase. 5 imports, 4 dependents.
Entity Profile
Dependency Diagram
graph LR 56154347_d0e1_1403_ce0e_25508620362c["hmr.ts"] a469d907_868c_e1c2_3f7a_7aaf42cc6a7a["moduleRunnerTransport.ts"] 56154347_d0e1_1403_ce0e_25508620362c --> a469d907_868c_e1c2_3f7a_7aaf42cc6a7a 4240fa9d_33c0_7795_b6b9_88a71b66843b["NormalizedModuleRunnerTransport"] 56154347_d0e1_1403_ce0e_25508620362c --> 4240fa9d_33c0_7795_b6b9_88a71b66843b ccb8a028_b1ec_3743_cfbe_0ac5315bc7c3["hmrPayload"] 56154347_d0e1_1403_ce0e_25508620362c --> ccb8a028_b1ec_3743_cfbe_0ac5315bc7c3 2afeac62_c9af_73a3_ec8c_6b0d5e385665["hot"] 56154347_d0e1_1403_ce0e_25508620362c --> 2afeac62_c9af_73a3_ec8c_6b0d5e385665 57ef6a6f_78a2_5d0d_3e76_fba06d52d534["customEvent"] 56154347_d0e1_1403_ce0e_25508620362c --> 57ef6a6f_78a2_5d0d_3e76_fba06d52d534 85908ff5_4d12_826d_8235_531f91538758["client.ts"] 85908ff5_4d12_826d_8235_531f91538758 --> 56154347_d0e1_1403_ce0e_25508620362c 6376d6db_9498_4e43_a973_0c6e0f34ba5c["hmrLogger.ts"] 6376d6db_9498_4e43_a973_0c6e0f34ba5c --> 56154347_d0e1_1403_ce0e_25508620362c 29e248d2_9983_1037_00e6_8bcd9ee87840["runner.ts"] 29e248d2_9983_1037_00e6_8bcd9ee87840 --> 56154347_d0e1_1403_ce0e_25508620362c bf48f7e9_65f6_54c3_7dce_f44769180bd7["types.ts"] bf48f7e9_65f6_54c3_7dce_f44769180bd7 --> 56154347_d0e1_1403_ce0e_25508620362c style 56154347_d0e1_1403_ce0e_25508620362c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import type { HotPayload, Update } from '#types/hmrPayload'
import type { ModuleNamespace, ViteHotContext } from '#types/hot'
import type { InferCustomEventPayload } from '#types/customEvent'
import type { NormalizedModuleRunnerTransport } from './moduleRunnerTransport'
type CustomListenersMap = Map<string, ((data: any) => void)[]>
interface HotModule {
id: string
callbacks: HotCallback[]
}
interface HotCallback {
// the dependencies must be fetchable paths
deps: string[]
fn: (modules: Array<ModuleNamespace | undefined>) => void
}
export interface HMRLogger {
error(msg: string | Error): void
debug(...msg: unknown[]): void
}
export class HMRContext implements ViteHotContext {
private newListeners: CustomListenersMap
constructor(
private hmrClient: HMRClient,
private ownerPath: string,
) {
if (!hmrClient.dataMap.has(ownerPath)) {
hmrClient.dataMap.set(ownerPath, {})
}
// when a file is hot updated, a new context is created
// clear its stale callbacks
const mod = hmrClient.hotModulesMap.get(ownerPath)
if (mod) {
mod.callbacks = []
}
// clear stale custom event listeners
const staleListeners = hmrClient.ctxToListenersMap.get(ownerPath)
if (staleListeners) {
for (const [event, staleFns] of staleListeners) {
const listeners = hmrClient.customListenersMap.get(event)
if (listeners) {
hmrClient.customListenersMap.set(
event,
listeners.filter((l) => !staleFns.includes(l)),
)
}
}
}
this.newListeners = new Map()
hmrClient.ctxToListenersMap.set(ownerPath, this.newListeners)
}
get data(): any {
// ... (250 more lines)
Domain
Subdomains
Classes
Dependencies
- NormalizedModuleRunnerTransport
- customEvent
- hmrPayload
- hot
- moduleRunnerTransport.ts
Imported By
Source
Frequently Asked Questions
What does hmr.ts do?
hmr.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 hmr.ts?
hmr.ts defines 2 function(s): data, modules.
What does hmr.ts depend on?
hmr.ts imports 5 module(s): NormalizedModuleRunnerTransport, customEvent, hmrPayload, hot, moduleRunnerTransport.ts.
What files import hmr.ts?
hmr.ts is imported by 4 file(s): client.ts, hmrLogger.ts, runner.ts, types.ts.
Where is hmr.ts in the architecture?
hmr.ts is located at packages/vite/src/shared/hmr.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