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

Method getModulesByFile

packages/vite/src/node/server/mixedModuleGraph.ts:341–364  ·  view source on GitHub ↗
(file: string)

Source from the content-addressed store, hash-verified

339 }
340
341 getModulesByFile(file: string): Set<ModuleNode> | undefined {
342 // Until Vite 5.1.x, the moduleGraph contained modules from both the browser and server
343 // We maintain backwards compatibility by returning a Set of module proxies assuming
344 // that the modules for a certain file are the same in both the browser and server
345 const clientModules = this._client.getModulesByFile(file)
346 const ssrModules = this._ssr.getModulesByFile(file)
347 if (!clientModules && !ssrModules) {
348 return undefined
349 }
350 const result = new Set<ModuleNode>()
351 if (clientModules) {
352 for (const mod of clientModules) {
353 result.add(this.getBackwardCompatibleBrowserModuleNode(mod)!)
354 }
355 }
356 if (ssrModules) {
357 for (const mod of ssrModules) {
358 if (mod.id == null || !this._client.getModuleById(mod.id)) {
359 result.add(this.getBackwardCompatibleServerModuleNode(mod)!)
360 }
361 }
362 }
363 return result
364 }
365
366 onFileChange(file: string): void {
367 this._client.onFileChange(file)

Callers 4

handleHMRUpdateFunction · 0.45
urlResolverFunction · 0.45
getUrlIdFunction · 0.45
formatErrorFunction · 0.45

Calls 4

addMethod · 0.80
getModuleByIdMethod · 0.45

Tested by

no test coverage detected