Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/sxzz/rolldown-plugin-dts. A Rolldown plugin to generate and bundle dts files.
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637import path from 'node:path'import type { ExistingRawSourceMap, RolldownOutput } from 'rolldown'
/** * Resolve a path inside `tests/fixtures` */export function fixture(...paths: string[]): string { return path.resolve(import.meta.dirname, 'fixtures', ...paths)}
/** * Find and parse a source map from the output chunks */export function findSourceMapChunk( chunks: RolldownOutput['output'], fileName: string,): ExistingRawSourceMap { const chunk = chunks.find((chunk) => chunk.fileName === fileName)
if (!chunk) { throw new Error( `Unable to find file ${fileName} from the following chunks: ${chunks.map((chunk) => chunk.fileName).join(', ')}`, ) }
if (chunk.type !== 'asset') { throw new Error('Sourcemap chunk is not an asset') }
if (typeof chunk.source !== 'string') { throw new TypeError('Sourcemap chunk source is not a string') }
const map = JSON.parse(chunk.source) as ExistingRawSourceMap return map}