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

Function normalizeModuleId

packages/vite/src/module-runner/evaluatedModules.ts:147–158  ·  view source on GitHub ↗
(file: string)

Source from the content-addressed store, hash-verified

145// /@fs/C:/root/id.js => C:/root/id.js
146// file:///C:/root/id.js -> C:/root/id.js
147export function normalizeModuleId(file: string): string {
148 if (prefixedBuiltins.has(file)) return file
149
150 // unix style, but Windows path still starts with the drive letter to check the root
151 const unixFile = slash(file)
152 .replace(/^\/@fs\//, isWindows ? '' : '/')
153 .replace(/^node:/, '')
154 .replace(/^\/+/, '/')
155
156 // if it's not in the root, keep it as a path, not a URL
157 return unixFile.replace(/^file:\/+/, isWindows ? '' : '/')
158}

Callers 1

ensureModuleMethod · 0.85

Calls 2

slashFunction · 0.90
hasMethod · 0.80

Tested by

no test coverage detected