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
  f6f63945_bf89_bb25_c76e_6ddb3d4e5344["extractStaticImportMap()"]
  a6c81756_7ac7_5a3a_7275_d3632db70ea4["extract-static-plugins.ts"]
  f6f63945_bf89_bb25_c76e_6ddb3d4e5344 -->|defined in| a6c81756_7ac7_5a3a_7275_d3632db70ea4
  7251786a_fd41_beea_80b3_e558e273b171["findStaticPlugins()"]
  7251786a_fd41_beea_80b3_e558e273b171 -->|calls| f6f63945_bf89_bb25_c76e_6ddb3d4e5344
  style f6f63945_bf89_bb25_c76e_6ddb3d4e5344 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
}

Subdomains

Frequently Asked Questions

What does extractStaticImportMap() do?
extractStaticImportMap() is a function in the tailwindcss codebase, defined in packages/@tailwindcss-upgrade/src/utils/extract-static-plugins.ts.
Where is extractStaticImportMap() defined?
extractStaticImportMap() is defined in packages/@tailwindcss-upgrade/src/utils/extract-static-plugins.ts at line 326.
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