[READ-ONLY] Mirror of https://github.com/vitest-dev/vitest. Next generation testing framework powered by Vite. vitest.dev
test testing-tools vite
12

Configure Feed

Select the types of activity you want to include in your feed.

chore: update sources type for vite 5 (#4069)

Co-authored-by: Vladimir <sleuths.slews0s@icloud.com>

authored by

Bjorn Lu
Vladimir
and committed by
GitHub
(Sep 7, 2023, 9:18 AM +0300) 8b46ee8b 410bc454

+16 -14
+16 -14
packages/vite-node/src/source-map.ts
··· 25 25 if (!map || code.includes(VITE_NODE_SOURCEMAPPING_SOURCE)) 26 26 return result 27 27 28 - map.sources = map.sources?.map((source) => { 29 - if (!source) 28 + if ('sources' in map) { 29 + map.sources = map.sources?.map((source) => { 30 + if (!source) 31 + return source 32 + // sometimes files here are absolute, 33 + // but they are considered absolute to the server url, not the file system 34 + // this is a bug in Vite 35 + // all files should be either absolute to the file system or relative to the source map file 36 + if (isAbsolute(source)) { 37 + const actualPath = (!source.startsWith(withTrailingSlash(options.root)) && source.startsWith('/')) 38 + ? resolve(options.root, source.slice(1)) 39 + : source 40 + return relative(dirname(options.filepath), actualPath) 41 + } 30 42 return source 31 - // sometimes files here are absolute, 32 - // but they are considered absolute to the server url, not the file system 33 - // this is a bug in Vite 34 - // all files should be either absolute to the file system or relative to the source map file 35 - if (isAbsolute(source)) { 36 - const actualPath = (!source.startsWith(withTrailingSlash(options.root)) && source.startsWith('/')) 37 - ? resolve(options.root, source.slice(1)) 38 - : source 39 - return relative(dirname(options.filepath), actualPath) 40 - } 41 - return source 42 - }) 43 + }) 44 + } 43 45 44 46 // to reduce the payload size, we only inline vite node source map, because it's also the only one we use 45 47 const OTHER_SOURCE_MAP_REGEXP = new RegExp(`//# ${SOURCEMAPPING_URL}=data:application/json[^,]+base64,([A-Za-z0-9+/=]+)$`, 'gm')