Home / Function/ inlineSourceMap() — vite Function Reference

inlineSourceMap() — vite Function Reference

Architecture documentation for the inlineSourceMap() function in fetchModule.ts from the vite codebase.

Entity Profile

Dependency Diagram

graph TD
  37c7e77b_d40c_df6e_62db_77d0ac97c34a["inlineSourceMap()"]
  4b293f94_dc8f_b625_ac09_35b43008310b["fetchModule.ts"]
  37c7e77b_d40c_df6e_62db_77d0ac97c34a -->|defined in| 4b293f94_dc8f_b625_ac09_35b43008310b
  18626e4c_2392_d64e_6551_5d524a5d0253["fetchModule()"]
  18626e4c_2392_d64e_6551_5d524a5d0253 -->|calls| 37c7e77b_d40c_df6e_62db_77d0ac97c34a
  0857a370_8db0_3f2b_ac58_b48c57bd6a12["genSourceMapUrl()"]
  37c7e77b_d40c_df6e_62db_77d0ac97c34a -->|calls| 0857a370_8db0_3f2b_ac58_b48c57bd6a12
  style 37c7e77b_d40c_df6e_62db_77d0ac97c34a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/vite/src/node/ssr/fetchModule.ts lines 123–153

function inlineSourceMap(
  mod: EnvironmentModuleNode,
  result: TransformResult,
  startOffset: number | undefined,
) {
  const map = result.map
  let code = result.code

  if (
    !map ||
    !('version' in map) ||
    code.includes(MODULE_RUNNER_SOURCEMAPPING_SOURCE)
  )
    return result

  // to reduce the payload size, we only inline vite node source map, because it's also the only one we use
  OTHER_SOURCE_MAP_REGEXP.lastIndex = 0
  if (OTHER_SOURCE_MAP_REGEXP.test(code))
    code = code.replace(OTHER_SOURCE_MAP_REGEXP, '')

  const sourceMap = startOffset
    ? Object.assign({}, map, {
        mappings: ';'.repeat(startOffset) + map.mappings,
      })
    : map
  result.code = `${code.trimEnd()}\n//# sourceURL=${
    mod.id
  }\n${MODULE_RUNNER_SOURCEMAPPING_SOURCE}\n//# ${SOURCEMAPPING_URL}=${genSourceMapUrl(sourceMap)}\n`

  return result
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does inlineSourceMap() do?
inlineSourceMap() is a function in the vite codebase, defined in packages/vite/src/node/ssr/fetchModule.ts.
Where is inlineSourceMap() defined?
inlineSourceMap() is defined in packages/vite/src/node/ssr/fetchModule.ts at line 123.
What does inlineSourceMap() call?
inlineSourceMap() calls 1 function(s): genSourceMapUrl.
What calls inlineSourceMap()?
inlineSourceMap() is called by 1 function(s): fetchModule.

Analyze Your Own Codebase

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

Try Supermodel Free