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

Function getUrlId

packages/vite/src/node/plugins/forwardConsole.ts:64–84  ·  view source on GitHub ↗
(id)

Source from the content-addressed store, hash-verified

62 const error = payload.data
63 const stacks = parseErrorStacktrace(error, {
64 getUrlId(id) {
65 const moduleGraph = environment.moduleGraph
66 const mod = moduleGraph.getModuleById(id)
67 if (mod) {
68 return id
69 }
70 const resolvedPath = normalizePath(
71 path.resolve(environment.config.root, id.slice(1)),
72 )
73 const modUrl = moduleGraph.getModuleById(resolvedPath)
74 if (modUrl) {
75 return resolvedPath
76 }
77 // some browsers (looking at you, safari) don't report queries in stack traces
78 // the next best thing is to try the first id that this file resolves to
79 const files = moduleGraph.getModulesByFile(resolvedPath)
80 if (files && files.size) {
81 return files.values().next().value!.id!
82 }
83 return id
84 },
85 getSourceMap(id) {
86 if (sourceMapCache.has(id)) {
87 return sourceMapCache.get(id)

Callers

nothing calls this directly

Calls 4

normalizePathFunction · 0.85
resolveMethod · 0.65
getModuleByIdMethod · 0.45
getModulesByFileMethod · 0.45

Tested by

no test coverage detected