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 79d116f6_7ff2_5367_4672_ab907f2a77dc["findStaticPlugins()"] 84232925_f388_3f84_db95_7d674fc02190["extract-static-plugins.ts"] 79d116f6_7ff2_5367_4672_ab907f2a77dc -->|defined in| 84232925_f388_3f84_db95_7d674fc02190 617e9831_5cd2_4ca6_2c65_f89e3720cfd8["migrateJsConfig()"] 617e9831_5cd2_4ca6_2c65_f89e3720cfd8 -->|calls| 79d116f6_7ff2_5367_4672_ab907f2a77dc 15b378ea_3aa4_54e9_344a_eae392b6770c["canMigrateConfig()"] 15b378ea_3aa4_54e9_344a_eae392b6770c -->|calls| 79d116f6_7ff2_5367_4672_ab907f2a77dc e6e4385a_77c6_31bc_12e8_868b6fa1939b["extractStaticImportMap()"] 79d116f6_7ff2_5367_4672_ab907f2a77dc -->|calls| e6e4385a_77c6_31bc_12e8_868b6fa1939b b589df59_9794_ee71_1a27_cef8a143cd7b["extractValue()"] 79d116f6_7ff2_5367_4672_ab907f2a77dc -->|calls| b589df59_9794_ee71_1a27_cef8a143cd7b style 79d116f6_7ff2_5367_4672_ab907f2a77dc 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