normalizeResolvedIdToUrl() — vite Function Reference
Architecture documentation for the normalizeResolvedIdToUrl() function in importAnalysis.ts from the vite codebase.
Entity Profile
Dependency Diagram
graph TD 1e925d7e_c386_076f_28e6_2f4d5f82fbdd["normalizeResolvedIdToUrl()"] 5a7b98e4_4eb1_dfca_508b_2d43e2a077e6["importAnalysis.ts"] 1e925d7e_c386_076f_28e6_2f4d5f82fbdd -->|defined in| 5a7b98e4_4eb1_dfca_508b_2d43e2a077e6 a1fc1de5_905b_efe7_d960_3597604fbdfe["importAnalysisPlugin()"] a1fc1de5_905b_efe7_d960_3597604fbdfe -->|calls| 1e925d7e_c386_076f_28e6_2f4d5f82fbdd 1a3bec7b_1a11_316f_5831_a0535b829bbf["withTrailingSlash()"] 1e925d7e_c386_076f_28e6_2f4d5f82fbdd -->|calls| 1a3bec7b_1a11_316f_5831_a0535b829bbf 10b9dea8_362c_1af2_93be_afa4dd9aed9e["cleanUrl()"] 1e925d7e_c386_076f_28e6_2f4d5f82fbdd -->|calls| 10b9dea8_362c_1af2_93be_afa4dd9aed9e 0c17692e_44e4_448d_4a57_1d0018af1182["wrapId()"] 1e925d7e_c386_076f_28e6_2f4d5f82fbdd -->|calls| 0c17692e_44e4_448d_4a57_1d0018af1182 style 1e925d7e_c386_076f_28e6_2f4d5f82fbdd fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/vite/src/node/plugins/importAnalysis.ts lines 107–144
function normalizeResolvedIdToUrl(
environment: DevEnvironment,
url: string,
resolved: PartialResolvedId,
): string {
const root = environment.config.root
const depsOptimizer = environment.depsOptimizer
// normalize all imports into resolved URLs
// e.g. `import 'foo'` -> `import '/@fs/.../node_modules/foo/index.js'`
if (resolved.id.startsWith(withTrailingSlash(root))) {
// in root: infer short absolute path from root
url = resolved.id.slice(root.length)
} else if (
depsOptimizer?.isOptimizedDepFile(resolved.id) ||
// vite-plugin-react isn't following the leading \0 virtual module convention.
// This is a temporary hack to avoid expensive fs checks for React apps.
// We'll remove this as soon we're able to fix the react plugins.
(resolved.id !== '/@react-refresh' &&
path.isAbsolute(resolved.id) &&
fs.existsSync(cleanUrl(resolved.id)))
) {
// an optimized deps may not yet exists in the filesystem, or
// a regular file exists but is out of root: rewrite to absolute /@fs/ paths
url = path.posix.join(FS_PREFIX, resolved.id)
} else {
url = resolved.id
}
// if the resolved id is not a valid browser import specifier,
// prefix it to make it valid. We will strip this before feeding it
// back into the transform pipeline
if (url[0] !== '.' && url[0] !== '/') {
url = wrapId(resolved.id)
}
return url
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does normalizeResolvedIdToUrl() do?
normalizeResolvedIdToUrl() is a function in the vite codebase, defined in packages/vite/src/node/plugins/importAnalysis.ts.
Where is normalizeResolvedIdToUrl() defined?
normalizeResolvedIdToUrl() is defined in packages/vite/src/node/plugins/importAnalysis.ts at line 107.
What does normalizeResolvedIdToUrl() call?
normalizeResolvedIdToUrl() calls 3 function(s): cleanUrl, withTrailingSlash, wrapId.
What calls normalizeResolvedIdToUrl()?
normalizeResolvedIdToUrl() is called by 1 function(s): importAnalysisPlugin.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free