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

Function getCachedTransformResult

packages/vite/src/node/server/transformRequest.ts:209–235  ·  view source on GitHub ↗
(
  environment: DevEnvironment,
  url: string,
  module: EnvironmentModuleNode,
  timestamp: number,
)

Source from the content-addressed store, hash-verified

207}
208
209async function getCachedTransformResult(
210 environment: DevEnvironment,
211 url: string,
212 module: EnvironmentModuleNode,
213 timestamp: number,
214) {
215 const prettyUrl = debugCache ? prettifyUrl(url, environment.config.root) : ''
216
217 // tries to handle soft invalidation of the module if available,
218 // returns a boolean true is successful, or false if no handling is needed
219 const softInvalidatedTransformResult = await handleModuleSoftInvalidation(
220 environment,
221 module,
222 timestamp,
223 )
224 if (softInvalidatedTransformResult) {
225 debugCache?.(`[memory-hmr] ${prettyUrl}`)
226 return softInvalidatedTransformResult
227 }
228
229 // check if we have a fresh cache
230 const cached = module.transformResult
231 if (cached) {
232 debugCache?.(`[memory] ${prettyUrl}`)
233 return cached
234 }
235}
236
237async function loadAndTransform(
238 environment: DevEnvironment,

Callers 1

doTransformFunction · 0.85

Calls 2

prettifyUrlFunction · 0.90

Tested by

no test coverage detected