substituteAtImports() — tailwindcss Function Reference
Architecture documentation for the substituteAtImports() function in at-import.ts from the tailwindcss codebase.
Entity Profile
Dependency Diagram
graph TD 5713e78d_1b82_b74a_13d9_da852136ec3c["substituteAtImports()"] bb501946_7944_1015_b5ff_34d10aace799["at-import.ts"] 5713e78d_1b82_b74a_13d9_da852136ec3c -->|defined in| bb501946_7944_1015_b5ff_34d10aace799 3970218d_3d6c_e455_87cc_45b4a094f0e9["parseCss()"] 3970218d_3d6c_e455_87cc_45b4a094f0e9 -->|calls| 5713e78d_1b82_b74a_13d9_da852136ec3c ed78da58_8727_ad98_120c_61f35cea357a["walk()"] 5713e78d_1b82_b74a_13d9_da852136ec3c -->|calls| ed78da58_8727_ad98_120c_61f35cea357a 080c2c82_1391_bd9d_3ee3_8b010c0f87ce["parseImportParams()"] 5713e78d_1b82_b74a_13d9_da852136ec3c -->|calls| 080c2c82_1391_bd9d_3ee3_8b010c0f87ce 2cb0bb18_cebb_3874_811d_77095e27cf0d["context()"] 5713e78d_1b82_b74a_13d9_da852136ec3c -->|calls| 2cb0bb18_cebb_3874_811d_77095e27cf0d 3b1218f7_c1d9_a3cd_c354_928a2203089f["buildImportNodes()"] 5713e78d_1b82_b74a_13d9_da852136ec3c -->|calls| 3b1218f7_c1d9_a3cd_c354_928a2203089f b8a15b09_3dfb_7181_b1f8_368422e178e4["parse()"] 5713e78d_1b82_b74a_13d9_da852136ec3c -->|calls| b8a15b09_3dfb_7181_b1f8_368422e178e4 style 5713e78d_1b82_b74a_13d9_da852136ec3c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/tailwindcss/src/at-import.ts lines 16–81
export async function substituteAtImports(
ast: AstNode[],
base: string,
loadStylesheet: LoadStylesheet,
recurseCount = 0,
track = false,
) {
let features = Features.None
let promises: Promise<void>[] = []
walk(ast, (node) => {
if (node.kind === 'at-rule' && (node.name === '@import' || node.name === '@reference')) {
let parsed = parseImportParams(ValueParser.parse(node.params))
if (parsed === null) return
if (node.name === '@reference') {
parsed.media = 'reference'
}
features |= Features.AtImport
let { uri, layer, media, supports } = parsed
// Skip importing data or remote URIs
if (uri.startsWith('data:')) return
if (uri.startsWith('http://') || uri.startsWith('https://')) return
let contextNode = context({}, [])
promises.push(
(async () => {
// Since we do not have fully resolved paths in core, we can't
// reliably detect circular imports. Instead, we try to limit the
// recursion depth to a number that is too large to be reached in
// practice.
if (recurseCount > 100) {
throw new Error(
`Exceeded maximum recursion depth while resolving \`${uri}\` in \`${base}\`)`,
)
}
let loaded = await loadStylesheet(uri, base)
let ast = CSS.parse(loaded.content, { from: track ? loaded.path : undefined })
await substituteAtImports(ast, loaded.base, loadStylesheet, recurseCount + 1, track)
contextNode.nodes = buildImportNodes(
node,
[context({ base: loaded.base }, ast)],
layer,
media,
supports,
)
})(),
)
// The resolved Stylesheets already have their transitive @imports
// resolved, so we can skip walking them.
return WalkAction.ReplaceSkip(contextNode)
}
})
if (promises.length > 0) {
await Promise.all(promises)
}
return features
}
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does substituteAtImports() do?
substituteAtImports() is a function in the tailwindcss codebase, defined in packages/tailwindcss/src/at-import.ts.
Where is substituteAtImports() defined?
substituteAtImports() is defined in packages/tailwindcss/src/at-import.ts at line 16.
What does substituteAtImports() call?
substituteAtImports() calls 5 function(s): buildImportNodes, context, parse, parseImportParams, walk.
What calls substituteAtImports()?
substituteAtImports() is called by 1 function(s): parseCss.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free