resolveSubpathImports() — vite Function Reference
Architecture documentation for the resolveSubpathImports() function in resolve.ts from the vite codebase.
Entity Profile
Dependency Diagram
graph TD 3565bb57_e3d1_ed21_b20a_81fa198f92df["resolveSubpathImports()"] dcff87b0_a8ea_57a2_3b29_a7b8f19986f3["resolve.ts"] 3565bb57_e3d1_ed21_b20a_81fa198f92df -->|defined in| dcff87b0_a8ea_57a2_3b29_a7b8f19986f3 0ac6860f_bc2f_9818_86d4_22179cc9c8ba["oxcResolvePlugin()"] 0ac6860f_bc2f_9818_86d4_22179cc9c8ba -->|calls| 3565bb57_e3d1_ed21_b20a_81fa198f92df 31b651d6_9d57_14b0_2e8c_d85642bc19f4["findNearestPackageData()"] 3565bb57_e3d1_ed21_b20a_81fa198f92df -->|calls| 31b651d6_9d57_14b0_2e8c_d85642bc19f4 09d0a948_4a89_8bbc_50ce_129fc70dbd66["splitFileAndPostfix()"] 3565bb57_e3d1_ed21_b20a_81fa198f92df -->|calls| 09d0a948_4a89_8bbc_50ce_129fc70dbd66 c10abc49_1d0c_ffeb_c31f_9afc51ce808b["resolveExportsOrImports()"] 3565bb57_e3d1_ed21_b20a_81fa198f92df -->|calls| c10abc49_1d0c_ffeb_c31f_9afc51ce808b style 3565bb57_e3d1_ed21_b20a_81fa198f92df fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/vite/src/node/plugins/resolve.ts lines 491–520
function resolveSubpathImports(
id: string,
importer: string | undefined,
options: InternalResolveOptions,
) {
if (!importer || !id.startsWith(subpathImportsPrefix)) return
const basedir = path.dirname(importer)
const pkgData = findNearestPackageData(basedir, options.packageCache)
if (!pkgData) return
let { file: idWithoutPostfix, postfix } = splitFileAndPostfix(id.slice(1))
idWithoutPostfix = '#' + idWithoutPostfix
let importsPath = resolveExportsOrImports(
pkgData.data,
idWithoutPostfix,
options,
'imports',
)
if (importsPath?.[0] === '.') {
importsPath = path.relative(basedir, path.join(pkgData.dir, importsPath))
if (!relativePrefixRE.test(importsPath)) {
importsPath = `./${importsPath}`
}
}
return importsPath + postfix
}
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does resolveSubpathImports() do?
resolveSubpathImports() is a function in the vite codebase, defined in packages/vite/src/node/plugins/resolve.ts.
Where is resolveSubpathImports() defined?
resolveSubpathImports() is defined in packages/vite/src/node/plugins/resolve.ts at line 491.
What does resolveSubpathImports() call?
resolveSubpathImports() calls 3 function(s): findNearestPackageData, resolveExportsOrImports, splitFileAndPostfix.
What calls resolveSubpathImports()?
resolveSubpathImports() is called by 1 function(s): oxcResolvePlugin.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free