MCPcopy
hub / github.com/tailwindlabs/tailwindcss / run

Function run

packages/tailwindcss/src/source-maps/source-map.test.ts:21–49  ·  view source on GitHub ↗
({ input, candidates, options }: RunOptions)

Source from the content-addressed store, hash-verified

19}
20
21async function run({ input, candidates, options }: RunOptions) {
22 let source = new MagicString(input)
23 let root = path.resolve(__dirname, '../..')
24
25 let compiler = await compile(source.toString(), {
26 from: 'input.css',
27 async loadStylesheet(id, base) {
28 let resolvedPath = path.resolve(root, id === 'tailwindcss' ? 'index.css' : id)
29
30 return {
31 path: path.relative(root, resolvedPath),
32 base,
33 content: await fs.readFile(resolvedPath, 'utf-8'),
34 }
35 },
36 ...options,
37 })
38
39 let css = compiler.build(candidates ?? [])
40 let decoded = compiler.buildSourceMap()
41 let rawMap = toRawSourceMap(decoded)
42 let combined = remapping(rawMap, () => null)
43 let map = JSON.parse(rawMap.toString()) as RawSourceMap
44
45 let sources = combined.sources
46 let annotations = visualizeSourceMap(map, css)
47
48 return { css, map, sources, annotations }
49}
50
51function toRawSourceMap(map: DecodedSourceMap): string {
52 let generator = new SourceMapGenerator()

Callers 1

source-map.test.tsFile · 0.70

Calls 4

visualizeSourceMapFunction · 0.90
toRawSourceMapFunction · 0.85
resolveMethod · 0.80
compileFunction · 0.50

Tested by

no test coverage detected