ast.bench.ts — tailwindcss Source File
Architecture documentation for ast.bench.ts, a typescript file in the tailwindcss codebase. 5 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 95c02696_6e3d_8e6c_d8d8_6a9e696207b0["ast.bench.ts"] 42640952_ea63_55f1_1ff1_00816e2980ae["ast.ts"] 95c02696_6e3d_8e6c_d8d8_6a9e696207b0 --> 42640952_ea63_55f1_1ff1_00816e2980ae 88bcab2f_f837_9e57_5b6a_fda72a4c3315["cloneAstNode"] 95c02696_6e3d_8e6c_d8d8_6a9e696207b0 --> 88bcab2f_f837_9e57_5b6a_fda72a4c3315 2da63033_d079_7b37_5cfb_3877674a70b9["toCss"] 95c02696_6e3d_8e6c_d8d8_6a9e696207b0 --> 2da63033_d079_7b37_5cfb_3877674a70b9 54851997_7544_bab2_96ab_548e5f5df205["css-parser.ts"] 95c02696_6e3d_8e6c_d8d8_6a9e696207b0 --> 54851997_7544_bab2_96ab_548e5f5df205 696bd648_5f24_1b59_8e8b_7a97a692869e["vitest"] 95c02696_6e3d_8e6c_d8d8_6a9e696207b0 --> 696bd648_5f24_1b59_8e8b_7a97a692869e style 95c02696_6e3d_8e6c_d8d8_6a9e696207b0 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { bench, describe } from 'vitest'
import { cloneAstNode, toCss, type AstNode } from './ast'
import * as CSS from './css-parser'
const css = String.raw
const input = css`
@theme {
--color-primary: #333;
}
@tailwind utilities;
.foo {
color: red;
/* comment */
&:hover {
color: blue;
@apply font-bold;
}
}
`
const ast = CSS.parse(input)
describe('AST to CSS', () => {
bench('toCss', () => {
toCss(ast)
})
bench('toCss with source maps', () => {
toCss(ast, true)
})
})
describe('Cloning AST nodes', () => {
bench('cloneAstNode()', () => {
ast.map(cloneAstNode)
})
bench('cloneAstNode (with spread)', () => {
ast.map(cloneAstNodeSpread)
})
bench('structuredClone()', () => {
structuredClone(ast)
})
})
function cloneAstNodeSpread<T extends AstNode>(node: T): T {
switch (node.kind) {
case 'rule':
case 'at-rule':
case 'at-root':
return { ...node, nodes: node.nodes.map(cloneAstNodeSpread) }
case 'context':
return { ...node, context: { ...node.context }, nodes: node.nodes.map(cloneAstNodeSpread) }
case 'declaration':
case 'comment':
return { ...node }
default:
node satisfies never
throw new Error(`Unknown node kind: ${(node as any).kind}`)
}
}
Domain
Subdomains
Functions
Dependencies
Source
Frequently Asked Questions
What does ast.bench.ts do?
ast.bench.ts is a source file in the tailwindcss codebase, written in typescript. It belongs to the OxideEngine domain, Extractor subdomain.
What functions are defined in ast.bench.ts?
ast.bench.ts defines 1 function(s): cloneAstNodeSpread.
What does ast.bench.ts depend on?
ast.bench.ts imports 5 module(s): ast.ts, cloneAstNode, css-parser.ts, toCss, vitest.
Where is ast.bench.ts in the architecture?
ast.bench.ts is located at packages/tailwindcss/src/ast.bench.ts (domain: OxideEngine, subdomain: Extractor, directory: packages/tailwindcss/src).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free