parseSourceMap() — tailwindcss Function Reference
Architecture documentation for the parseSourceMap() function in utils.ts from the tailwindcss codebase.
Entity Profile
Dependency Diagram
graph TD 062dc08d_4708_183b_67ab_c1a5231c576a["parseSourceMap()"] 9ffd1dda_9675_c514_373d_0f4ab4648249["utils.ts"] 062dc08d_4708_183b_67ab_c1a5231c576a -->|defined in| 9ffd1dda_9675_c514_373d_0f4ab4648249 0204f9b9_80aa_c3e8_eb61_22170d608d65["createLineTable()"] 062dc08d_4708_183b_67ab_c1a5231c576a -->|calls| 0204f9b9_80aa_c3e8_eb61_22170d608d65 style 062dc08d_4708_183b_67ab_c1a5231c576a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
integrations/utils.ts lines 652–695
function parseSourceMap(opts: string | SourceMapOptions): SourceMap {
if (typeof opts === 'string') {
let lines = opts.trimEnd().split('\n')
let comment = lines.at(-1) ?? ''
let map = String(comment).match(SOURCE_MAP_COMMENT)?.[1] ?? null
if (!map) throw new Error('No source map comment found')
return parseSourceMap({
map,
content: lines.slice(0, -1).join('\n'),
encoding: 'base64',
})
}
let rawMap: RawSourceMap
let content = opts.content
if (typeof opts.map === 'object') {
rawMap = opts.map as RawSourceMap
} else {
rawMap = JSON.parse(Buffer.from(opts.map, opts.encoding ?? 'utf-8').toString())
}
let map = new SourceMapConsumer(rawMap)
let generatedTable = createLineTable(content)
return {
at(line: number, column: number) {
let pos = map.originalPositionFor({ line, column })
let source = pos.source ? map.sourceContentFor(pos.source) : null
let originalTable = createLineTable(source ?? '')
let originalOffset = originalTable.findOffset(pos)
let generatedOffset = generatedTable.findOffset({ line, column })
return {
source: pos.source,
original: source
? source.slice(originalOffset, originalOffset + 10).trim() + '...'
: '(none)',
generated: content.slice(generatedOffset, generatedOffset + 10).trim() + '...',
}
},
}
}
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does parseSourceMap() do?
parseSourceMap() is a function in the tailwindcss codebase, defined in integrations/utils.ts.
Where is parseSourceMap() defined?
parseSourceMap() is defined in integrations/utils.ts at line 652.
What does parseSourceMap() call?
parseSourceMap() calls 1 function(s): createLineTable.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free