source-map.test.ts — tailwindcss Source File
Architecture documentation for source-map.test.ts, a typescript file in the tailwindcss codebase. 13 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 685d98f0_f223_dedf_cfba_bbdb2dc11d1d["source-map.test.ts"] fda9325c_b5ff_9f58_5fbb_98511cb0b478["plugin.ts"] 685d98f0_f223_dedf_cfba_bbdb2dc11d1d --> fda9325c_b5ff_9f58_5fbb_98511cb0b478 34e5c339_8af8_7d45_d2bf_6dcdb0abb21d["createPlugin"] 685d98f0_f223_dedf_cfba_bbdb2dc11d1d --> 34e5c339_8af8_7d45_d2bf_6dcdb0abb21d c056448b_f7a2_9149_54e8_f0f8470fe3aa["default-map.ts"] 685d98f0_f223_dedf_cfba_bbdb2dc11d1d --> c056448b_f7a2_9149_54e8_f0f8470fe3aa bf2992f6_4a37_8536_70f8_94b13631027d["DefaultMap"] 685d98f0_f223_dedf_cfba_bbdb2dc11d1d --> bf2992f6_4a37_8536_70f8_94b13631027d 94f6a4ae_3b1f_8e71_a096_1f7d17efc49a["source-map.ts"] 685d98f0_f223_dedf_cfba_bbdb2dc11d1d --> 94f6a4ae_3b1f_8e71_a096_1f7d17efc49a facdb12f_af00_955b_ad76_f74421b66d0d["remapping"] 685d98f0_f223_dedf_cfba_bbdb2dc11d1d --> facdb12f_af00_955b_ad76_f74421b66d0d 211db6bb_9759_d0cf_acda_36d7f5733ce2["dedent"] 685d98f0_f223_dedf_cfba_bbdb2dc11d1d --> 211db6bb_9759_d0cf_acda_36d7f5733ce2 4e9749c1_3be5_4190_0982_9e2be7f35db0["magic-string"] 685d98f0_f223_dedf_cfba_bbdb2dc11d1d --> 4e9749c1_3be5_4190_0982_9e2be7f35db0 8118fcf2_a51d_d1a1_93d3_c71d3a646692["promises"] 685d98f0_f223_dedf_cfba_bbdb2dc11d1d --> 8118fcf2_a51d_d1a1_93d3_c71d3a646692 2a7660a5_3e09_bd74_37f0_e4e54bc64ce5["node:path"] 685d98f0_f223_dedf_cfba_bbdb2dc11d1d --> 2a7660a5_3e09_bd74_37f0_e4e54bc64ce5 82ad9cd3_d590_5d6c_5489_cb5e47cde1b7["source-map-js"] 685d98f0_f223_dedf_cfba_bbdb2dc11d1d --> 82ad9cd3_d590_5d6c_5489_cb5e47cde1b7 696bd648_5f24_1b59_8e8b_7a97a692869e["vitest"] 685d98f0_f223_dedf_cfba_bbdb2dc11d1d --> 696bd648_5f24_1b59_8e8b_7a97a692869e defe3085_cb6b_a1e5_b72d_c90fcb3dd3f2[".."] 685d98f0_f223_dedf_cfba_bbdb2dc11d1d --> defe3085_cb6b_a1e5_b72d_c90fcb3dd3f2 style 685d98f0_f223_dedf_cfba_bbdb2dc11d1d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import remapping from '@jridgewell/remapping'
import dedent from 'dedent'
import MagicString from 'magic-string'
import * as fs from 'node:fs/promises'
import * as path from 'node:path'
import { SourceMapConsumer, SourceMapGenerator, type RawSourceMap } from 'source-map-js'
import { test } from 'vitest'
import { compile } from '..'
import createPlugin from '../plugin'
import { DefaultMap } from '../utils/default-map'
import type { DecodedSource, DecodedSourceMap } from './source-map'
const css = dedent
interface RunOptions {
input: string
candidates?: string[]
options?: Parameters<typeof compile>[1]
}
async function run({ input, candidates, options }: RunOptions) {
let source = new MagicString(input)
let root = path.resolve(__dirname, '../..')
let compiler = await compile(source.toString(), {
from: 'input.css',
async loadStylesheet(id, base) {
let resolvedPath = path.resolve(root, id === 'tailwindcss' ? 'index.css' : id)
return {
path: path.relative(root, resolvedPath),
base,
content: await fs.readFile(resolvedPath, 'utf-8'),
}
},
...options,
})
let css = compiler.build(candidates ?? [])
let decoded = compiler.buildSourceMap()
let rawMap = toRawSourceMap(decoded)
let combined = remapping(rawMap, () => null)
let map = JSON.parse(rawMap.toString()) as RawSourceMap
let sources = combined.sources
let annotations = formattedMappings(map)
return { css, map, sources, annotations }
}
function toRawSourceMap(map: DecodedSourceMap): string {
let generator = new SourceMapGenerator()
let id = 1
let sourceTable = new DefaultMap<
DecodedSource | null,
{
url: string
content: string
}
>((src) => {
// ... (416 more lines)
Domain
Subdomains
Types
Dependencies
- ..
- DefaultMap
- createPlugin
- dedent
- default-map.ts
- magic-string
- node:path
- plugin.ts
- promises
- remapping
- source-map-js
- source-map.ts
- vitest
Source
Frequently Asked Questions
What does source-map.test.ts do?
source-map.test.ts is a source file in the tailwindcss codebase, written in typescript. It belongs to the OxideEngine domain, Scanner subdomain.
What functions are defined in source-map.test.ts?
source-map.test.ts defines 4 function(s): formatRange, formattedMappings, run, toRawSourceMap.
What does source-map.test.ts depend on?
source-map.test.ts imports 13 module(s): .., DefaultMap, createPlugin, dedent, default-map.ts, magic-string, node:path, plugin.ts, and 5 more.
Where is source-map.test.ts in the architecture?
source-map.test.ts is located at packages/tailwindcss/src/source-maps/source-map.test.ts (domain: OxideEngine, subdomain: Scanner, directory: packages/tailwindcss/src/source-maps).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free