Home / Function/ loadModule() — tailwindcss Function Reference

loadModule() — tailwindcss Function Reference

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

Function typescript NodeServer Resolver calls 3 called by 4

Entity Profile

Dependency Diagram

graph TD
  2a6a0b85_eed3_a09b_8c8d_c2a585078dac["loadModule()"]
  86cbca6b_bfa0_804c_ee2e_2cc7a7aef7fe["compile.ts"]
  2a6a0b85_eed3_a09b_8c8d_c2a585078dac -->|defined in| 86cbca6b_bfa0_804c_ee2e_2cc7a7aef7fe
  4ceb6126_e004_1a29_2b41_a2a30ed1e0a3["createCompileOptions()"]
  4ceb6126_e004_1a29_2b41_a2a30ed1e0a3 -->|calls| 2a6a0b85_eed3_a09b_8c8d_c2a585078dac
  10dd1778_d5d6_7419_caca_5dd21395aaa0["__unstable__loadDesignSystem()"]
  10dd1778_d5d6_7419_caca_5dd21395aaa0 -->|calls| 2a6a0b85_eed3_a09b_8c8d_c2a585078dac
  617e9831_5cd2_4ca6_2c65_f89e3720cfd8["migrateJsConfig()"]
  617e9831_5cd2_4ca6_2c65_f89e3720cfd8 -->|calls| 2a6a0b85_eed3_a09b_8c8d_c2a585078dac
  2e186872_4660_9caa_6330_7fce815c6ad0["createResolvedUserConfig()"]
  2e186872_4660_9caa_6330_7fce815c6ad0 -->|calls| 2a6a0b85_eed3_a09b_8c8d_c2a585078dac
  6ef9a64f_c1a9_a4de_6f42_1025fb0ff566["resolveJsId()"]
  2a6a0b85_eed3_a09b_8c8d_c2a585078dac -->|calls| 6ef9a64f_c1a9_a4de_6f42_1025fb0ff566
  eab5f798_3965_32b1_00c7_67b7a72eab0c["importModule()"]
  2a6a0b85_eed3_a09b_8c8d_c2a585078dac -->|calls| eab5f798_3965_32b1_00c7_67b7a72eab0c
  9cfd6a48_f7c8_231f_3ab5_bd787226724b["getModuleDependencies()"]
  2a6a0b85_eed3_a09b_8c8d_c2a585078dac -->|calls| 9cfd6a48_f7c8_231f_3ab5_bd787226724b
  style 2a6a0b85_eed3_a09b_8c8d_c2a585078dac 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, defined in packages/@tailwindcss-node/src/compile.ts.
Where is loadModule() defined?
loadModule() is defined in packages/@tailwindcss-node/src/compile.ts at line 118.
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