( mod: EnvironmentModuleNode, result: TransformResult, startOffset: number | undefined, )
| 121 | ) |
| 122 | |
| 123 | function inlineSourceMap( |
| 124 | mod: EnvironmentModuleNode, |
| 125 | result: TransformResult, |
| 126 | startOffset: number | undefined, |
| 127 | ) { |
| 128 | const map = result.map |
| 129 | let code = result.code |
| 130 | |
| 131 | if ( |
| 132 | !map || |
| 133 | !('version' in map) || |
| 134 | code.includes(MODULE_RUNNER_SOURCEMAPPING_SOURCE) |
| 135 | ) |
| 136 | return result |
| 137 | |
| 138 | // to reduce the payload size, we only inline vite node source map, because it's also the only one we use |
| 139 | OTHER_SOURCE_MAP_REGEXP.lastIndex = 0 |
| 140 | if (OTHER_SOURCE_MAP_REGEXP.test(code)) |
| 141 | code = code.replace(OTHER_SOURCE_MAP_REGEXP, '') |
| 142 | |
| 143 | const sourceMap = startOffset |
| 144 | ? Object.assign({}, map, { |
| 145 | mappings: ';'.repeat(startOffset) + map.mappings, |
| 146 | }) |
| 147 | : map |
| 148 | result.code = `${code.trimEnd()}\n//# sourceURL=${ |
| 149 | mod.id |
| 150 | }\n${MODULE_RUNNER_SOURCEMAPPING_SOURCE}\n//# ${SOURCEMAPPING_URL}=${genSourceMapUrl(sourceMap)}\n` |
| 151 | |
| 152 | return result |
| 153 | } |
no test coverage detected