link.ts — tailwindcss Source File
Architecture documentation for link.ts, a typescript file in the tailwindcss codebase. 14 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR 391ead49_f8b5_2b23_a9fe_31a150c72620["link.ts"] 28a2f72d_350c_6647_bf9d_77c69e637045["default-map.ts"] 391ead49_f8b5_2b23_a9fe_31a150c72620 --> 28a2f72d_350c_6647_bf9d_77c69e637045 cfb4af0e_7b2d_34a1_693a_90088443cfec["DefaultMap"] 391ead49_f8b5_2b23_a9fe_31a150c72620 --> cfb4af0e_7b2d_34a1_693a_90088443cfec bc267e18_3e03_cc17_3da0_cbc39f148f44["stylesheet.ts"] 391ead49_f8b5_2b23_a9fe_31a150c72620 --> bc267e18_3e03_cc17_3da0_cbc39f148f44 b9897393_3e36_7806_d172_b9debcd215f6["Stylesheet"] 391ead49_f8b5_2b23_a9fe_31a150c72620 --> b9897393_3e36_7806_d172_b9debcd215f6 2329d36e_5aa2_4fa5_cf9f_a9c6cc4e1277["renderer.ts"] 391ead49_f8b5_2b23_a9fe_31a150c72620 --> 2329d36e_5aa2_4fa5_cf9f_a9c6cc4e1277 6c5b3bb2_4069_e0af_8887_216e1c995446["error"] 391ead49_f8b5_2b23_a9fe_31a150c72620 --> 6c5b3bb2_4069_e0af_8887_216e1c995446 d3ccc5ce_e370_63df_a97d_a2f004fd83ca["highlight"] 391ead49_f8b5_2b23_a9fe_31a150c72620 --> d3ccc5ce_e370_63df_a97d_a2f004fd83ca 1c806fef_a933_285c_65d9_c10998b12c7d["relative"] 391ead49_f8b5_2b23_a9fe_31a150c72620 --> 1c806fef_a933_285c_65d9_c10998b12c7d a8400c40_f6b4_6c1d_1812_df53f33aaafc["success"] 391ead49_f8b5_2b23_a9fe_31a150c72620 --> a8400c40_f6b4_6c1d_1812_df53f33aaafc d58c78f4_5856_72aa_9dca_c418a7d7f31e["prepare-config.ts"] 391ead49_f8b5_2b23_a9fe_31a150c72620 --> d58c78f4_5856_72aa_9dca_c418a7d7f31e af4df363_0f48_b01c_23c9_2fbbbb45c164["detectConfigPath"] 391ead49_f8b5_2b23_a9fe_31a150c72620 --> af4df363_0f48_b01c_23c9_2fbbbb45c164 08129f89_e6ef_0092_629d_821c60228c89["node"] 391ead49_f8b5_2b23_a9fe_31a150c72620 --> 08129f89_e6ef_0092_629d_821c60228c89 89aef3dd_1eed_c141_d425_b8949215a653["node:path"] 391ead49_f8b5_2b23_a9fe_31a150c72620 --> 89aef3dd_1eed_c141_d425_b8949215a653 7c3c22f8_be1a_4490_9f3e_622280887fe1["postcss"] 391ead49_f8b5_2b23_a9fe_31a150c72620 --> 7c3c22f8_be1a_4490_9f3e_622280887fe1 style 391ead49_f8b5_2b23_a9fe_31a150c72620 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { normalizePath } from '@tailwindcss/node'
import path from 'node:path'
import postcss from 'postcss'
import { DefaultMap } from '../../../../tailwindcss/src/utils/default-map'
import { Stylesheet } from '../../stylesheet'
import { error, highlight, relative, success } from '../../utils/renderer'
import { detectConfigPath } from '../template/prepare-config'
export async function linkConfigs(
stylesheets: Stylesheet[],
{ configPath, base }: { configPath: string | null; base: string },
) {
let rootStylesheets = stylesheets.filter((sheet) => sheet.isTailwindRoot)
if (rootStylesheets.length === 0) {
throw new Error(
`Cannot find any CSS files that reference Tailwind CSS.\nBefore your project can be upgraded you need to create a CSS file that imports Tailwind CSS or uses ${highlight('@tailwind')}.`,
)
}
let withoutAtConfig = rootStylesheets.filter((sheet) => {
let hasConfig = false
sheet.root.walkAtRules('config', (node) => {
let configPath = path.resolve(path.dirname(sheet.file!), node.params.slice(1, -1))
sheet.linkedConfigPath = configPath
hasConfig = true
return false
})
return !hasConfig
})
// All stylesheets have a `@config` directives
if (withoutAtConfig.length === 0) return
// Find the config file path for each stylesheet
let configPathBySheet = new Map<Stylesheet, string>()
let sheetByConfigPath = new DefaultMap<string, Set<Stylesheet>>(() => new Set())
for (let sheet of withoutAtConfig) {
if (!sheet.file) continue
let localConfigPath = configPath as string
if (configPath === null) {
localConfigPath = await detectConfigPath(path.dirname(sheet.file), base)
} else if (!path.isAbsolute(localConfigPath)) {
localConfigPath = path.resolve(base, localConfigPath)
}
configPathBySheet.set(sheet, localConfigPath)
sheetByConfigPath.get(localConfigPath).add(sheet)
}
let problematicStylesheets = new Set<Stylesheet>()
for (let sheets of sheetByConfigPath.values()) {
if (sheets.size > 1) {
for (let sheet of sheets) {
problematicStylesheets.add(sheet)
}
}
}
// There are multiple "root" files without `@config` directives. Manual
// intervention is needed to link to the correct Tailwind config files.
// ... (63 more lines)
Domain
Subdomains
Functions
Dependencies
Imported By
Source
Frequently Asked Questions
What does link.ts do?
link.ts is a source file in the tailwindcss codebase, written in typescript. It belongs to the CommandLineInterface domain, Codemods subdomain.
What functions are defined in link.ts?
link.ts defines 1 function(s): linkConfigs.
What does link.ts depend on?
link.ts imports 14 module(s): DefaultMap, Stylesheet, default-map.ts, detectConfigPath, error, highlight, node, node:path, and 6 more.
What files import link.ts?
link.ts is imported by 1 file(s): index.ts.
Where is link.ts in the architecture?
link.ts is located at packages/@tailwindcss-upgrade/src/codemods/css/link.ts (domain: CommandLineInterface, subdomain: Codemods, directory: packages/@tailwindcss-upgrade/src/codemods/css).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free