mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
This PR improves the debug logs for the `@tailwindcss/postcss` integration. It uses custom instrumentation to provide a nested but detailed overview of where time is spent during the build process. The updated logs look like this: ``` [0.15ms] [@tailwindcss/postcss] src/app/geistsans_9fc57718.module.css [0.14ms] ↳ Quick bail check [0.02ms] [@tailwindcss/postcss] src/app/geistsans_9fc57718.module.css [0.01ms] ↳ Quick bail check [0.03ms] [@tailwindcss/postcss] src/app/geistmono_b9f59162.module.css [0.02ms] ↳ Quick bail check [0.12ms] [@tailwindcss/postcss] src/app/geistmono_b9f59162.module.css [0.11ms] ↳ Quick bail check [42.09ms] [@tailwindcss/postcss] src/app/globals.css [ 0.01ms] ↳ Quick bail check [12.12ms] ↳ Setup compiler [ 0.11ms] ↳ PostCSS AST -> Tailwind CSS AST [11.99ms] ↳ Create compiler [ 0.07ms] ↳ Register full rebuild paths [ 0.06ms] ↳ Setup scanner [ 7.51ms] ↳ Scan for candidates [ 5.86ms] ↳ Register dependency messages [ 5.88ms] ↳ Build utilities [ 8.34ms] ↳ Optimization [ 0.23ms] ↳ AST -> CSS [ 4.20ms] ↳ Lightning CSS [ 3.89ms] ↳ CSS -> PostCSS AST [ 1.97ms] ↳ Update PostCSS AST ```
62 lines
1.1 KiB
TypeScript
62 lines
1.1 KiB
TypeScript
import { stripVTControlCharacters } from 'util'
|
||
import { expect, it } from 'vitest'
|
||
import { Instrumentation } from './instrumentation'
|
||
|
||
it('should add instrumentation', () => {
|
||
let I = new Instrumentation()
|
||
|
||
I.start('Foo')
|
||
let x = 1
|
||
for (let i = 0; i < 100; i++) {
|
||
I.start('Bar')
|
||
x **= 2
|
||
I.end('Bar')
|
||
}
|
||
I.end('Foo')
|
||
|
||
I.hit('Potato')
|
||
I.hit('Potato')
|
||
I.hit('Potato')
|
||
I.hit('Potato')
|
||
|
||
expect.assertions(1)
|
||
|
||
I.report((output) => {
|
||
expect(stripVTControlCharacters(output).replace(/\[.*\]/g, '[0.xxms]')).toMatchInlineSnapshot(`
|
||
"
|
||
Hits:
|
||
Potato × 4
|
||
|
||
Timers:
|
||
[0.xxms] Foo
|
||
[0.xxms] ↳ Bar × 100
|
||
"
|
||
`)
|
||
})
|
||
})
|
||
|
||
it('should auto end pending timers when reporting', () => {
|
||
let I = new Instrumentation()
|
||
|
||
I.start('Foo')
|
||
let x = 1
|
||
for (let i = 0; i < 100; i++) {
|
||
I.start('Bar')
|
||
x **= 2
|
||
I.end('Bar')
|
||
}
|
||
I.start('Baz')
|
||
|
||
expect.assertions(1)
|
||
|
||
I.report((output) => {
|
||
expect(stripVTControlCharacters(output).replace(/\[.*\]/g, '[0.xxms]')).toMatchInlineSnapshot(`
|
||
"
|
||
[0.xxms] Foo
|
||
[0.xxms] ↳ Bar × 100
|
||
[0.xxms] ↳ Baz
|
||
"
|
||
`)
|
||
})
|
||
})
|