combineSourcemaps() — vite Function Reference
Architecture documentation for the combineSourcemaps() function in utils.ts from the vite codebase.
Entity Profile
Dependency Diagram
graph TD cb1210e8_03e9_2eec_ef04_aa15d44d4c08["combineSourcemaps()"] 031bc221_67a8_c579_f2bf_bb30a08beeb2["utils.ts"] cb1210e8_03e9_2eec_ef04_aa15d44d4c08 -->|defined in| 031bc221_67a8_c579_f2bf_bb30a08beeb2 ade0e43e_6c50_1bd7_8322_ba7f0b5f15a8["combineSourcemapsIfExists()"] ade0e43e_6c50_1bd7_8322_ba7f0b5f15a8 -->|calls| cb1210e8_03e9_2eec_ef04_aa15d44d4c08 bf4a41be_9dbf_35be_2072_4283cd478ae7["transformWithEsbuild()"] bf4a41be_9dbf_35be_2072_4283cd478ae7 -->|calls| cb1210e8_03e9_2eec_ef04_aa15d44d4c08 6d315957_5b5c_845c_10c4_b8cb46bc58eb["buildImportAnalysisPlugin()"] 6d315957_5b5c_845c_10c4_b8cb46bc58eb -->|calls| cb1210e8_03e9_2eec_ef04_aa15d44d4c08 047aa0d5_25bc_9eb0_8c41_99a2be202642["transformWithOxc()"] 047aa0d5_25bc_9eb0_8c41_99a2be202642 -->|calls| cb1210e8_03e9_2eec_ef04_aa15d44d4c08 3c78163f_527c_d054_7003_68d51942d57a["_getCombinedSourcemap()"] 3c78163f_527c_d054_7003_68d51942d57a -->|calls| cb1210e8_03e9_2eec_ef04_aa15d44d4c08 027164d9_0d90_6487_4866_e21cb9d3e6c1["ssrTransformScript()"] 027164d9_0d90_6487_4866_e21cb9d3e6c1 -->|calls| cb1210e8_03e9_2eec_ef04_aa15d44d4c08 b301fa12_baef_9bba_0243_802d85a06f05["escapeToLinuxLikePath()"] cb1210e8_03e9_2eec_ef04_aa15d44d4c08 -->|calls| b301fa12_baef_9bba_0243_802d85a06f05 166d10bf_0762_f6c7_74f0_a38688033eeb["unescapeToLinuxLikePath()"] cb1210e8_03e9_2eec_ef04_aa15d44d4c08 -->|calls| 166d10bf_0762_f6c7_74f0_a38688033eeb style cb1210e8_03e9_2eec_ef04_aa15d44d4c08 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/vite/src/node/utils.ts lines 856–910
export function combineSourcemaps(
filename: string,
sourcemapList: Array<DecodedSourceMap | RawSourceMap>,
): RawSourceMap {
if (
sourcemapList.length === 0 ||
sourcemapList.every((m) => m.sources.length === 0)
) {
return { ...nullSourceMap }
}
// hack for parse broken with normalized absolute paths on windows (C:/path/to/something).
// escape them to linux like paths
// also avoid mutation here to prevent breaking plugin's using cache to generate sourcemaps like vue (see #7442)
sourcemapList = sourcemapList.map((sourcemap) => {
const newSourcemaps = { ...sourcemap }
newSourcemaps.sources = sourcemap.sources.map((source) =>
source ? escapeToLinuxLikePath(source) : null,
)
if (sourcemap.sourceRoot) {
newSourcemaps.sourceRoot = escapeToLinuxLikePath(sourcemap.sourceRoot)
}
return newSourcemaps
})
const escapedFilename = escapeToLinuxLikePath(filename)
// We don't declare type here so we can convert/fake/map as RawSourceMap
let map //: SourceMap
let mapIndex = 1
const useArrayInterface =
sourcemapList.slice(0, -1).find((m) => m.sources.length !== 1) === undefined
if (useArrayInterface) {
map = remapping(sourcemapList, () => null)
} else {
map = remapping(sourcemapList[0], function loader(sourcefile) {
// this line assumes that the length of the sourcemapList is 2
if (sourcefile === escapedFilename && sourcemapList[mapIndex]) {
return sourcemapList[mapIndex++]
} else {
return null
}
})
}
if (!map.file) {
delete map.file
}
// unescape the previous hack
map.sources = map.sources.map((source) =>
source ? unescapeToLinuxLikePath(source) : source,
)
map.file = filename
return map as RawSourceMap
}
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does combineSourcemaps() do?
combineSourcemaps() is a function in the vite codebase, defined in packages/vite/src/node/utils.ts.
Where is combineSourcemaps() defined?
combineSourcemaps() is defined in packages/vite/src/node/utils.ts at line 856.
What does combineSourcemaps() call?
combineSourcemaps() calls 2 function(s): escapeToLinuxLikePath, unescapeToLinuxLikePath.
What calls combineSourcemaps()?
combineSourcemaps() is called by 6 function(s): _getCombinedSourcemap, buildImportAnalysisPlugin, combineSourcemapsIfExists, ssrTransformScript, transformWithEsbuild, transformWithOxc.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free