Home / Function/ loadModule() — tailwindcss Function Reference

loadModule() — tailwindcss Function Reference

Architecture documentation for the loadModule() function in compile.ts from the tailwindcss codebase.

Entity Profile

Dependency Diagram

graph TD
  b620f573_84b9_a33a_291f_6bb912350445["loadModule()"]
  52f67804_5329_acb6_2ee6_ce1634fdb996["createCompileOptions()"]
  52f67804_5329_acb6_2ee6_ce1634fdb996 -->|calls| b620f573_84b9_a33a_291f_6bb912350445
  884346d7_e979_a8f8_f76d_59714fcaf2e0["__unstable__loadDesignSystem()"]
  884346d7_e979_a8f8_f76d_59714fcaf2e0 -->|calls| b620f573_84b9_a33a_291f_6bb912350445
  8d0812d4_61e4_e939_916d_a33e94faf43f["migrateJsConfig()"]
  8d0812d4_61e4_e939_916d_a33e94faf43f -->|calls| b620f573_84b9_a33a_291f_6bb912350445
  c223b5bc_475d_c40f_0314_bed60d87e0a0["createResolvedUserConfig()"]
  c223b5bc_475d_c40f_0314_bed60d87e0a0 -->|calls| b620f573_84b9_a33a_291f_6bb912350445
  d07b54e4_7bfc_07d8_4597_dc363e283fab["resolveJsId()"]
  b620f573_84b9_a33a_291f_6bb912350445 -->|calls| d07b54e4_7bfc_07d8_4597_dc363e283fab
  38349b09_4bed_0163_0474_1d6bbc3d4090["importModule()"]
  b620f573_84b9_a33a_291f_6bb912350445 -->|calls| 38349b09_4bed_0163_0474_1d6bbc3d4090
  e35c65f4_7d0a_1c14_2967_e3c608b092bd["getModuleDependencies()"]
  b620f573_84b9_a33a_291f_6bb912350445 -->|calls| e35c65f4_7d0a_1c14_2967_e3c608b092bd
  style b620f573_84b9_a33a_291f_6bb912350445 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/@tailwindcss-node/src/compile.ts lines 118–156

export async function loadModule(
  id: string,
  base: string,
  onDependency: (path: string) => void,
  customJsResolver?: Resolver,
) {
  if (id[0] !== '.') {
    let resolvedPath = await resolveJsId(id, base, customJsResolver)
    if (!resolvedPath) {
      throw new Error(`Could not resolve '${id}' from '${base}'`)
    }

    let module = await importModule(pathToFileURL(resolvedPath).href)
    return {
      path: resolvedPath,
      base: path.dirname(resolvedPath),
      module: module.default ?? module,
    }
  }

  let resolvedPath = await resolveJsId(id, base, customJsResolver)
  if (!resolvedPath) {
    throw new Error(`Could not resolve '${id}' from '${base}'`)
  }

  let [module, moduleDependencies] = await Promise.all([
    importModule(pathToFileURL(resolvedPath).href + '?id=' + Date.now()),
    getModuleDependencies(resolvedPath),
  ])

  for (let file of moduleDependencies) {
    onDependency(file)
  }
  return {
    path: resolvedPath,
    base: path.dirname(resolvedPath),
    module: module.default ?? module,
  }
}

Domain

Subdomains

Frequently Asked Questions

What does loadModule() do?
loadModule() is a function in the tailwindcss codebase.
What does loadModule() call?
loadModule() calls 3 function(s): getModuleDependencies, importModule, resolveJsId.
What calls loadModule()?
loadModule() is called by 4 function(s): __unstable__loadDesignSystem, createCompileOptions, createResolvedUserConfig, migrateJsConfig.

Analyze Your Own Codebase

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

Try Supermodel Free