MCPcopy
hub / github.com/vitejs/vite / combineSourcemapsIfExists

Function combineSourcemapsIfExists

packages/vite/src/node/plugins/css.ts:1896–1913  ·  view source on GitHub ↗
(
  filename: string,
  map1: ExistingRawSourceMap | { mappings: '' } | undefined,
  map2: ExistingRawSourceMap | { mappings: '' } | undefined,
)

Source from the content-addressed store, hash-verified

1894}
1895
1896function combineSourcemapsIfExists(
1897 filename: string,
1898 map1: ExistingRawSourceMap | { mappings: '' } | undefined,
1899 map2: ExistingRawSourceMap | { mappings: '' } | undefined,
1900): ExistingRawSourceMap | { mappings: '' } | undefined {
1901 if (!map1 || !map2) {
1902 return map1
1903 }
1904 if (map1.mappings === '' || map2.mappings === '') {
1905 return { mappings: '' }
1906 }
1907 return combineSourcemaps(filename, [
1908 // type of version property of ExistingRawSourceMap is number
1909 // but it is always 3
1910 map1 as RawSourceMap,
1911 map2 as RawSourceMap,
1912 ]) as ExistingRawSourceMap
1913}
1914
1915const viteHashUpdateMarker = '/*$vite$:1*/'
1916const viteHashUpdateMarkerRE = /\/\*\$vite\$:\d+\*\//

Callers 2

compileCSSPreprocessorsFunction · 0.85
compileCSSFunction · 0.85

Calls 1

combineSourcemapsFunction · 0.90

Tested by

no test coverage detected