Home / Function/ extractStaticImportMap() — tailwindcss Function Reference

extractStaticImportMap() — tailwindcss Function Reference

Architecture documentation for the extractStaticImportMap() function in extract-static-plugins.ts from the tailwindcss codebase.

Entity Profile

Dependency Diagram

graph TD
  2b431003_a49e_6971_10da_2cfab5fd0a7f["extractStaticImportMap()"]
  7269613d_689c_049b_c5a1_169a57d36e90["findStaticPlugins()"]
  7269613d_689c_049b_c5a1_169a57d36e90 -->|calls| 2b431003_a49e_6971_10da_2cfab5fd0a7f
  style 2b431003_a49e_6971_10da_2cfab5fd0a7f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/@tailwindcss-upgrade/src/utils/extract-static-plugins.ts lines 326–370

export function extractStaticImportMap(source: string) {
  let tree = parser.parse(source)
  let root = tree.rootNode

  let captures = IMPORT_QUERY.matches(root)

  let imports: Record<string, { module: string; export: string | null }> = {}
  for (let match of captures) {
    let toImport: { name: string; export: null | string }[] = []
    let from = ''
    for (let i = 0; i < match.captures.length; i++) {
      let capture = match.captures[i]

      switch (capture.name) {
        case 'default':
          toImport.push({ name: capture.node.text, export: null })
          break
        case 'imported-name':
          toImport.push({ name: capture.node.text, export: capture.node.text })
          break
        case 'imported-from':
          from = capture.node.text
          break
        case 'imported-namespace':
          toImport.push({ name: capture.node.text, export: '*' })
          break
        case 'imported-alias':
          if (toImport.length < 1) {
            throw new Error('Unexpected alias: ' + JSON.stringify(captures, null, 2))
          }
          let prevImport = toImport[toImport.length - 1]
          let name = prevImport.name
          prevImport.export = name
          prevImport.name = capture.node.text
          break
      }
    }

    for (let { name, export: exportSource } of toImport) {
      imports[name] = { module: from, export: exportSource }
    }
  }

  return imports
}

Domain

Subdomains

Frequently Asked Questions

What does extractStaticImportMap() do?
extractStaticImportMap() is a function in the tailwindcss codebase.
What calls extractStaticImportMap()?
extractStaticImportMap() is called by 1 function(s): findStaticPlugins.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free