substituteAtImports() — tailwindcss Function Reference
Architecture documentation for the substituteAtImports() function in at-import.ts from the tailwindcss codebase.
Entity Profile
Dependency Diagram
graph TD 761efede_46a5_5722_0699_0e1b0947c406["substituteAtImports()"] 26086ff1_0d4f_fdb2_3fc4_d0c999f90a8c["parseCss()"] 26086ff1_0d4f_fdb2_3fc4_d0c999f90a8c -->|calls| 761efede_46a5_5722_0699_0e1b0947c406 e9d556bc_f22d_356c_1bd2_27442c34b5c7["walk()"] 761efede_46a5_5722_0699_0e1b0947c406 -->|calls| e9d556bc_f22d_356c_1bd2_27442c34b5c7 d4cb5436_afc5_b498_b798_03165e495710["parseImportParams()"] 761efede_46a5_5722_0699_0e1b0947c406 -->|calls| d4cb5436_afc5_b498_b798_03165e495710 5da7c62d_f734_2cbc_b10f_03c31a70d4f9["context()"] 761efede_46a5_5722_0699_0e1b0947c406 -->|calls| 5da7c62d_f734_2cbc_b10f_03c31a70d4f9 8b7b19eb_b2e9_7522_24fe_7d4dcb7d22a4["buildImportNodes()"] 761efede_46a5_5722_0699_0e1b0947c406 -->|calls| 8b7b19eb_b2e9_7522_24fe_7d4dcb7d22a4 257c4715_dc91_0c7f_fce8_433a757d9ce6["parse()"] 761efede_46a5_5722_0699_0e1b0947c406 -->|calls| 257c4715_dc91_0c7f_fce8_433a757d9ce6 style 761efede_46a5_5722_0699_0e1b0947c406 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
Called By
Source
Frequently Asked Questions
What does substituteAtImports() do?
substituteAtImports() is a function in the tailwindcss codebase.
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