findStaticPlugins() — tailwindcss Function Reference
Architecture documentation for the findStaticPlugins() function in extract-static-plugins.ts from the tailwindcss codebase.
Entity Profile
Dependency Diagram
graph TD 7251786a_fd41_beea_80b3_e558e273b171["findStaticPlugins()"] a6c81756_7ac7_5a3a_7275_d3632db70ea4["extract-static-plugins.ts"] 7251786a_fd41_beea_80b3_e558e273b171 -->|defined in| a6c81756_7ac7_5a3a_7275_d3632db70ea4 1ef01211_e07d_fbec_dcb1_d3c7a3bfe061["migrateJsConfig()"] 1ef01211_e07d_fbec_dcb1_d3c7a3bfe061 -->|calls| 7251786a_fd41_beea_80b3_e558e273b171 7a3f2d88_6f0c_1a25_f3a3_982e5c35e67a["canMigrateConfig()"] 7a3f2d88_6f0c_1a25_f3a3_982e5c35e67a -->|calls| 7251786a_fd41_beea_80b3_e558e273b171 f6f63945_bf89_bb25_c76e_6ddb3d4e5344["extractStaticImportMap()"] 7251786a_fd41_beea_80b3_e558e273b171 -->|calls| f6f63945_bf89_bb25_c76e_6ddb3d4e5344 ebe93479_82fa_7ad0_27a0_0015b31a0c46["extractValue()"] 7251786a_fd41_beea_80b3_e558e273b171 -->|calls| ebe93479_82fa_7ad0_27a0_0015b31a0c46 style 7251786a_fd41_beea_80b3_e558e273b171 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/@tailwindcss-upgrade/src/utils/extract-static-plugins.ts lines 138–279
export function findStaticPlugins(source: string): [string, null | StaticPluginOptions][] | null {
try {
let tree = parser.parse(source)
let root = tree.rootNode
let imports = extractStaticImportMap(source)
let captures = PLUGINS_QUERY.matches(root)
let plugins: [string, null | StaticPluginOptions][] = []
for (let match of captures) {
for (let capture of match.captures) {
if (capture.name !== 'imports') continue
for (let pluginDefinition of capture.node.children) {
if (
pluginDefinition.type === '[' ||
pluginDefinition.type === ']' ||
pluginDefinition.type === ','
)
continue
switch (pluginDefinition.type) {
case 'identifier':
let source = imports[pluginDefinition.text]
if (!source || source.export !== null) {
return null
}
plugins.push([source.module, null])
break
case 'string':
plugins.push([pluginDefinition.children[1].text, null])
break
case 'call_expression':
let matches = PLUGIN_CALL_OPTIONS_QUERY.matches(pluginDefinition)
if (matches.length === 0) return null
let moduleName: string | null = null
let moduleIdentifier: string | null = null
let options: StaticPluginOptions | null = null
let lastProperty: string | null = null
let captures = matches.flatMap((m) => m.captures)
for (let i = 0; i < captures.length; i++) {
let capture = captures[i]
switch (capture.name) {
case 'module_identifier': {
moduleIdentifier = capture.node.text
break
}
case 'module_string': {
moduleName = capture.node.text
break
}
case 'property': {
if (lastProperty !== null) return null
lastProperty = capture.node.text
break
}
case 'str_value':
case 'num_value':
case 'null_value':
case 'true_value':
case 'false_value': {
if (lastProperty === null) return null
options ??= {}
options[lastProperty] = extractValue(capture)
lastProperty = null
break
}
case 'array_value': {
if (lastProperty === null) return null
options ??= {}
// Loop over all captures after this one that are on the
// same property (it will be one match for any array
// element)
let array: Array<string | number | boolean | null> = []
let lastConsumedIndex = i
arrayLoop: for (let j = i + 1; j < captures.length; j++) {
let innerCapture = captures[j]
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does findStaticPlugins() do?
findStaticPlugins() is a function in the tailwindcss codebase, defined in packages/@tailwindcss-upgrade/src/utils/extract-static-plugins.ts.
Where is findStaticPlugins() defined?
findStaticPlugins() is defined in packages/@tailwindcss-upgrade/src/utils/extract-static-plugins.ts at line 138.
What does findStaticPlugins() call?
findStaticPlugins() calls 2 function(s): extractStaticImportMap, extractValue.
What calls findStaticPlugins()?
findStaticPlugins() is called by 2 function(s): canMigrateConfig, migrateJsConfig.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free