MCPcopy
hub / github.com/vitejs/vite / invalidateModule

Method invalidateModule

packages/vite/src/node/server/environment.ts:289–325  ·  view source on GitHub ↗
(
    m: {
      path: string
      message?: string
      firstInvalidatedBy: string
    },
    _client: NormalizedHotChannelClient,
  )

Source from the content-addressed store, hash-verified

287 }
288
289 protected invalidateModule(
290 m: {
291 path: string
292 message?: string
293 firstInvalidatedBy: string
294 },
295 _client: NormalizedHotChannelClient,
296 ): void {
297 if (this.bundledDev) {
298 this.bundledDev.invalidateModule(m, _client)
299 return
300 }
301
302 const mod = this.moduleGraph.urlToModuleMap.get(m.path)
303 if (
304 mod &&
305 mod.isSelfAccepting &&
306 mod.lastHMRTimestamp > 0 &&
307 !mod.lastHMRInvalidationReceived
308 ) {
309 mod.lastHMRInvalidationReceived = true
310 this.logger.info(
311 colors.yellow(`hmr invalidate `) +
312 colors.dim(m.path) +
313 (m.message ? ` ${m.message}` : ''),
314 { timestamp: true },
315 )
316 const file = getShortName(mod.file!, this.config.root)
317 updateModules(
318 this,
319 file,
320 [...mod.importers].filter((imp) => imp !== mod), // ignore self-imports
321 mod.lastHMRTimestamp,
322 m.firstInvalidatedBy,
323 )
324 }
325 }
326
327 async close(): Promise<void> {
328 this._closing = true

Callers 1

constructorMethod · 0.95

Calls 4

getShortNameFunction · 0.90
updateModulesFunction · 0.90
infoMethod · 0.65
getMethod · 0.45

Tested by

no test coverage detected