Home / File/ index.ts — tailwindcss Source File

index.ts — tailwindcss Source File

Architecture documentation for index.ts, a typescript file in the tailwindcss codebase. 14 imports, 1 dependents.

File typescript PostCSSPlugin AST 14 imports 1 dependents 2 functions

Entity Profile

Dependency Diagram

graph LR
  2bc39c56_196b_12bc_1a08_0896427ab477["index.ts"]
  b9cbffa4_c352_cf3c_268f_cbb174fb3a47["ast.ts"]
  2bc39c56_196b_12bc_1a08_0896427ab477 --> b9cbffa4_c352_cf3c_268f_cbb174fb3a47
  9b49f3c6_0c8d_5c62_965c_30a1db6499f8["toCss"]
  2bc39c56_196b_12bc_1a08_0896427ab477 --> 9b49f3c6_0c8d_5c62_965c_30a1db6499f8
  9106ed35_a5a8_5f41_7f5e_a6fe5287f68d["ast.ts"]
  2bc39c56_196b_12bc_1a08_0896427ab477 --> 9106ed35_a5a8_5f41_7f5e_a6fe5287f68d
  dea2012d_fe14_a673_2ce4_701a84a75cdb["cssAstToPostCssAst"]
  2bc39c56_196b_12bc_1a08_0896427ab477 --> dea2012d_fe14_a673_2ce4_701a84a75cdb
  63cea7e8_6a82_90d2_b2b0_c166362f218b["postCssAstToCssAst"]
  2bc39c56_196b_12bc_1a08_0896427ab477 --> 63cea7e8_6a82_90d2_b2b0_c166362f218b
  739a225a_d3d9_2f2f_c552_0cee87ad8d15["index.ts"]
  2bc39c56_196b_12bc_1a08_0896427ab477 --> 739a225a_d3d9_2f2f_c552_0cee87ad8d15
  e1212b8d_4bcf_d4e1_be45_2cb2423dc171["fixRelativePathsPlugin"]
  2bc39c56_196b_12bc_1a08_0896427ab477 --> e1212b8d_4bcf_d4e1_be45_2cb2423dc171
  78973828_b359_766f_59ac_7447f930192e["quick-lru"]
  2bc39c56_196b_12bc_1a08_0896427ab477 --> 78973828_b359_766f_59ac_7447f930192e
  08129f89_e6ef_0092_629d_821c60228c89["node"]
  2bc39c56_196b_12bc_1a08_0896427ab477 --> 08129f89_e6ef_0092_629d_821c60228c89
  dbd6cafa_0f98_d90d_0f9e_9485619e679e["require-cache"]
  2bc39c56_196b_12bc_1a08_0896427ab477 --> dbd6cafa_0f98_d90d_0f9e_9485619e679e
  5a22a82e_ea42_a956_7900_a189873ab04d["oxide"]
  2bc39c56_196b_12bc_1a08_0896427ab477 --> 5a22a82e_ea42_a956_7900_a189873ab04d
  9c72d32d_a535_69d4_565b_b620ce2eaae1["node:fs"]
  2bc39c56_196b_12bc_1a08_0896427ab477 --> 9c72d32d_a535_69d4_565b_b620ce2eaae1
  89aef3dd_1eed_c141_d425_b8949215a653["node:path"]
  2bc39c56_196b_12bc_1a08_0896427ab477 --> 89aef3dd_1eed_c141_d425_b8949215a653
  7c3c22f8_be1a_4490_9f3e_622280887fe1["postcss"]
  2bc39c56_196b_12bc_1a08_0896427ab477 --> 7c3c22f8_be1a_4490_9f3e_622280887fe1
  style 2bc39c56_196b_12bc_1a08_0896427ab477 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import QuickLRU from '@alloc/quick-lru'
import {
  compileAst,
  env,
  Features,
  Instrumentation,
  optimize as optimizeCss,
  Polyfills,
} from '@tailwindcss/node'
import { clearRequireCache } from '@tailwindcss/node/require-cache'
import { Scanner } from '@tailwindcss/oxide'
import fs from 'node:fs'
import path, { relative } from 'node:path'
import type { AcceptedPlugin, PluginCreator, Postcss, Root } from 'postcss'
import { toCss, type AstNode } from '../../tailwindcss/src/ast'
import { cssAstToPostCssAst, postCssAstToCssAst } from './ast'
import fixRelativePathsPlugin from './postcss-fix-relative-paths'

const DEBUG = env.DEBUG

interface CacheEntry {
  mtimes: Map<string, number>
  compiler: null | ReturnType<typeof compileAst>
  scanner: null | Scanner
  tailwindCssAst: AstNode[]
  cachedPostCssAst: Root
  optimizedPostCssAst: Root
  fullRebuildPaths: string[]
}
const cache = new QuickLRU<string, CacheEntry>({ maxSize: 50 })

function getContextFromCache(postcss: Postcss, inputFile: string, opts: PluginOptions): CacheEntry {
  let key = `${inputFile}:${opts.base ?? ''}:${JSON.stringify(opts.optimize)}`
  if (cache.has(key)) return cache.get(key)!
  let entry = {
    mtimes: new Map<string, number>(),
    compiler: null,
    scanner: null,

    tailwindCssAst: [],
    cachedPostCssAst: postcss.root(),
    optimizedPostCssAst: postcss.root(),

    fullRebuildPaths: [] as string[],
  }
  cache.set(key, entry)
  return entry
}

export type PluginOptions = {
  /**
   * The base directory to scan for class candidates.
   *
   * Defaults to the current working directory.
   */
  base?: string

  /**
   * Optimize and minify the output CSS.
   */
// ... (306 more lines)

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does index.ts do?
index.ts is a source file in the tailwindcss codebase, written in typescript. It belongs to the PostCSSPlugin domain, AST subdomain.
What functions are defined in index.ts?
index.ts defines 2 function(s): getContextFromCache, tailwindcss.
What does index.ts depend on?
index.ts imports 14 module(s): ast.ts, ast.ts, cssAstToPostCssAst, fixRelativePathsPlugin, index.ts, node, node:fs, node:path, and 6 more.
What files import index.ts?
index.ts is imported by 1 file(s): index.test.ts.
Where is index.ts in the architecture?
index.ts is located at packages/@tailwindcss-postcss/src/index.ts (domain: PostCSSPlugin, subdomain: AST, directory: packages/@tailwindcss-postcss/src).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free