You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The first call to format() with experimentalTailwindcss enabled takes 3+ seconds on macOS and even longer on Windows (causing CI timeout at 10 seconds).
Investigated prettier-plugin-tailwindcss source code. The slow initialization happens in getTailwindConfig():
1. Prettier config resolution (config.ts:37)
let[configDir,configPath]=awaitresolvePrettierConfigPath(options.filepath)// Internally calls prettier.resolveConfigFile() which walks up directory tree
2. Tailwind module resolution (config.ts:44)
let[mod,pkgDir]=awaitresolveTailwindPath(options,inputDir)// Dynamically imports the entire tailwindcss package
3. Design system initialization (v4.ts:71)
letdesign=awaitmod.__unstable__loadDesignSystem(css,{ ... })// Creates jiti instance, reads CSS, initializes the design system
The Issue in oxfmt
In apps/oxfmt/src-js/libs/prettier.ts:
exportasyncfunctionsortTailwindClasses({ filepath, classes, options ={}}){consttailwindPlugin=awaitloadTailwindPlugin();// ✓ cached// ...consttailwindContext=awaittailwindPlugin.getTailwindConfig(configOptions);// Expensive on first call!// ...}
While prettier-plugin-tailwindcss has internal caching (pathToApiMap with 10s TTL), the first call still runs all expensive setup:
Prettier config resolution: ~200-500ms (Windows)
Tailwind dynamic import: ~200-500ms
Design system init: ~500-1000ms
Total: ~1-2s (macOS), 10s+ (Windows CI)
Proposed Solutions
Option 1: Warmup during initialization
Pre-call getTailwindConfig with a dummy filepath during module load to warm the cache before any real formatting happens.
Option 2: Cache the Tailwind context in oxfmt
Store the result of getTailwindConfig and reuse it across calls (with same options).
Option 3: Skip unnecessary work for oxfmt's use case
Since oxfmt doesn't support custom Tailwind configs, we could:
Skip resolvePrettierConfigPath() entirely
Use the bundled tailwindcss-v4 directly without resolution
Observed Timings
macOS (arm64): ~3.1 seconds for first test
Windows (CI): >10 seconds (test timeout)
Affected Test
apps/oxfmt/test/tailwindcss/tailwindcss.test.ts - first test times out on Windows CI
I think this one should still open because #18339 only increased the test timeout to avoid test failures. The root causes are listed in the PR description.
Activity
Boshen commentedon Jan 16, 2026
Additional Root Cause Analysis from
prettier-plugin-tailwindcssAfter investigating the source code at https://github.com/tailwindlabs/prettier-plugin-tailwindcss, here are the deeper root causes:
1. Top-Level Await Blocking Initialization (Main Culprit)
In
src/index.ts:20:This eagerly loads all plugins at module initialization time. The
loadPlugins()function:await loadIfExistsESM()which tries to dynamically import plugins that may not existStatus: PR #420 addresses this by implementing lazy loading.
2. Per-File Config Caching Instead of Per-Directory
The cache key in
config.tsisfilePath, meaning:Status: PR #432 fixes this with directory-based caching (24% improvement on large codebases).
3. Jiti Instance Created Without Caching (v4)
In
src/versions/v4.ts:51-54:4. Expiring Caches with 10-Second TTL
All caches use
expiringMap(10_000)(10 seconds), which is problematic for longer formatting sessions.Upstream Status
feat/public-apibranch)fix(oxfmt): increase Tailwind CSS test timeout for Windows CI
fix(oxfmt): increase Tailwind CSS test timeout for Windows CI (#18339)
Dunqing commentedon Jan 21, 2026
I think this one should still open because #18339 only increased the test timeout to avoid test failures. The root causes are listed in the PR description.
feat(oxfmt): better Tailwind CSS intergration (#19000)