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 NodeBridge Compiler calls 3 called by 4

Entity Profile

Dependency Diagram

graph TD
  0dec976b_4cf5_63bb_0d29_f560fe197a3b["loadModule()"]
  69d3ce9e_56db_8f40_5261_64f91b0dee31["compile.ts"]
  0dec976b_4cf5_63bb_0d29_f560fe197a3b -->|defined in| 69d3ce9e_56db_8f40_5261_64f91b0dee31
  39d7b158_3ac5_7dc8_f294_3849e86a7bc5["createCompileOptions()"]
  39d7b158_3ac5_7dc8_f294_3849e86a7bc5 -->|calls| 0dec976b_4cf5_63bb_0d29_f560fe197a3b
  b7e9a1ed_cc0d_c436_1155_d872ad96268f["__unstable__loadDesignSystem()"]
  b7e9a1ed_cc0d_c436_1155_d872ad96268f -->|calls| 0dec976b_4cf5_63bb_0d29_f560fe197a3b
  1ef01211_e07d_fbec_dcb1_d3c7a3bfe061["migrateJsConfig()"]
  1ef01211_e07d_fbec_dcb1_d3c7a3bfe061 -->|calls| 0dec976b_4cf5_63bb_0d29_f560fe197a3b
  bd738f4b_3ec1_39d7_f3c7_ac0467a3d83e["createResolvedUserConfig()"]
  bd738f4b_3ec1_39d7_f3c7_ac0467a3d83e -->|calls| 0dec976b_4cf5_63bb_0d29_f560fe197a3b
  31302629_9db0_16bf_f7be_890002bd699b["resolveJsId()"]
  0dec976b_4cf5_63bb_0d29_f560fe197a3b -->|calls| 31302629_9db0_16bf_f7be_890002bd699b
  fb79ab4b_9aaf_ab21_26c8_3fdf36149adf["importModule()"]
  0dec976b_4cf5_63bb_0d29_f560fe197a3b -->|calls| fb79ab4b_9aaf_ab21_26c8_3fdf36149adf
  39d805f8_9f8f_733c_5705_af4f5e4be064["getModuleDependencies()"]
  0dec976b_4cf5_63bb_0d29_f560fe197a3b -->|calls| 39d805f8_9f8f_733c_5705_af4f5e4be064
  style 0dec976b_4cf5_63bb_0d29_f560fe197a3b 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