Home / Function/ _getCombinedSourcemap() — vite Function Reference

_getCombinedSourcemap() — vite Function Reference

Architecture documentation for the _getCombinedSourcemap() function in pluginContainer.ts from the vite codebase.

Entity Profile

Dependency Diagram

graph TD
  3c78163f_527c_d054_7003_68d51942d57a["_getCombinedSourcemap()"]
  bbea215d_7020_772f_d578_a87b3eba030c["TransformPluginContext"]
  3c78163f_527c_d054_7003_68d51942d57a -->|defined in| bbea215d_7020_772f_d578_a87b3eba030c
  dcf6f9d5_316b_0287_6984_8729d3e6c0aa["transform()"]
  dcf6f9d5_316b_0287_6984_8729d3e6c0aa -->|calls| 3c78163f_527c_d054_7003_68d51942d57a
  9282ac90_d29c_cf0b_bdf8_00ac31e9ba20["_formatLog()"]
  9282ac90_d29c_cf0b_bdf8_00ac31e9ba20 -->|calls| 3c78163f_527c_d054_7003_68d51942d57a
  7f968f26_079b_e4e6_bf70_99a14c481596["getCombinedSourcemap()"]
  7f968f26_079b_e4e6_bf70_99a14c481596 -->|calls| 3c78163f_527c_d054_7003_68d51942d57a
  2ed2578e_588a_efd0_df6b_829e1a96adf2["parse()"]
  3c78163f_527c_d054_7003_68d51942d57a -->|calls| 2ed2578e_588a_efd0_df6b_829e1a96adf2
  cb1210e8_03e9_2eec_ef04_aa15d44d4c08["combineSourcemaps()"]
  3c78163f_527c_d054_7003_68d51942d57a -->|calls| cb1210e8_03e9_2eec_ef04_aa15d44d4c08
  10b9dea8_362c_1af2_93be_afa4dd9aed9e["cleanUrl()"]
  3c78163f_527c_d054_7003_68d51942d57a -->|calls| 10b9dea8_362c_1af2_93be_afa4dd9aed9e
  style 3c78163f_527c_d054_7003_68d51942d57a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/vite/src/node/server/pluginContainer.ts lines 1092–1154

  _getCombinedSourcemap(): SourceMap | { mappings: '' } | null {
    if (
      debugSourcemapCombine &&
      debugSourcemapCombineFilter &&
      this.filename.includes(debugSourcemapCombineFilter)
    ) {
      debugSourcemapCombine('----------', this.filename)
      debugSourcemapCombine(this.combinedMap)
      debugSourcemapCombine(this.sourcemapChain)
      debugSourcemapCombine('----------')
    }

    let combinedMap = this.combinedMap
    // { mappings: '' }
    if (
      combinedMap &&
      !('version' in combinedMap) &&
      combinedMap.mappings === ''
    ) {
      this.sourcemapChain.length = 0
      return combinedMap
    }

    for (let m of this.sourcemapChain) {
      if (typeof m === 'string') m = JSON.parse(m)
      if (!('version' in (m as SourceMap))) {
        // { mappings: '' }
        if ((m as SourceMap).mappings === '') {
          combinedMap = { mappings: '' }
          break
        }
        // empty, nullified source map
        combinedMap = null
        break
      }
      if (!combinedMap) {
        const sm = m as SourceMap
        // sourcemap should not include `sources: [null]` (because `sources` should be string) nor
        // `sources: ['']` (because `''` means the path of sourcemap)
        // but MagicString generates this when `filename` option is not set.
        // Rollup supports these and therefore we support this as well
        if (sm.sources.length === 1 && !sm.sources[0]) {
          combinedMap = {
            ...sm,
            sources: [this.filename],
            sourcesContent: [this.originalCode],
          }
        } else {
          combinedMap = sm
        }
      } else {
        combinedMap = combineSourcemaps(cleanUrl(this.filename), [
          m as RawSourceMap,
          combinedMap as RawSourceMap,
        ]) as SourceMap
      }
    }
    if (combinedMap !== this.combinedMap) {
      this.combinedMap = combinedMap
      this.sourcemapChain.length = 0
    }
    return this.combinedMap
  }

Domain

Subdomains

Frequently Asked Questions

What does _getCombinedSourcemap() do?
_getCombinedSourcemap() is a function in the vite codebase, defined in packages/vite/src/node/server/pluginContainer.ts.
Where is _getCombinedSourcemap() defined?
_getCombinedSourcemap() is defined in packages/vite/src/node/server/pluginContainer.ts at line 1092.
What does _getCombinedSourcemap() call?
_getCombinedSourcemap() calls 3 function(s): cleanUrl, combineSourcemaps, parse.
What calls _getCombinedSourcemap()?
_getCombinedSourcemap() is called by 3 function(s): _formatLog, getCombinedSourcemap, transform.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free