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

Function applySourcemapIgnoreList

packages/vite/src/node/server/sourcemap.ts:161–200  ·  view source on GitHub ↗
(
  map: ExistingRawSourceMap,
  sourcemapPath: string,
  sourcemapIgnoreList: (sourcePath: string, sourcemapPath: string) => boolean,
  logger?: Logger,
)

Source from the content-addressed store, hash-verified

159}
160
161export function applySourcemapIgnoreList(
162 map: ExistingRawSourceMap,
163 sourcemapPath: string,
164 sourcemapIgnoreList: (sourcePath: string, sourcemapPath: string) => boolean,
165 logger?: Logger,
166): void {
167 let { x_google_ignoreList } = map
168 if (x_google_ignoreList === undefined) {
169 x_google_ignoreList = []
170 }
171 if (map.sources) {
172 for (
173 let sourcesIndex = 0;
174 sourcesIndex < map.sources.length;
175 ++sourcesIndex
176 ) {
177 const sourcePath = map.sources[sourcesIndex]
178 if (!sourcePath) continue
179
180 const ignoreList = sourcemapIgnoreList(
181 path.isAbsolute(sourcePath)
182 ? sourcePath
183 : path.resolve(path.dirname(sourcemapPath), sourcePath),
184 sourcemapPath,
185 )
186 if (logger && typeof ignoreList !== 'boolean') {
187 logger.warn('sourcemapIgnoreList function must return a boolean.')
188 }
189
190 if (ignoreList && !x_google_ignoreList.includes(sourcesIndex)) {
191 x_google_ignoreList.push(sourcesIndex)
192 }
193 }
194
195 if (x_google_ignoreList.length > 0) {
196 if (!map.x_google_ignoreList)
197 map.x_google_ignoreList = x_google_ignoreList
198 }
199 }
200}
201
202export function extractSourcemapFromFile(
203 code: string,

Callers 2

loadAndTransformFunction · 0.90
transformMiddlewareFunction · 0.90

Calls 2

resolveMethod · 0.65
warnMethod · 0.65

Tested by

no test coverage detected