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
  aee9f739_9a7b_d15f_6c82_a35dce42a8e6["loadModule()"]
  2cba246e_336d_6f47_8fa4_83f35f72c847["createCompileOptions()"]
  2cba246e_336d_6f47_8fa4_83f35f72c847 -->|calls| aee9f739_9a7b_d15f_6c82_a35dce42a8e6
  ec24f183_c831_b663_6c85_1d33238066d6["__unstable__loadDesignSystem()"]
  ec24f183_c831_b663_6c85_1d33238066d6 -->|calls| aee9f739_9a7b_d15f_6c82_a35dce42a8e6
  dc1d7e71_14d1_dd51_5d14_8265f9e59cce["migrateJsConfig()"]
  dc1d7e71_14d1_dd51_5d14_8265f9e59cce -->|calls| aee9f739_9a7b_d15f_6c82_a35dce42a8e6
  5fced395_cdfc_4802_a67e_74f87df5bfef["createResolvedUserConfig()"]
  5fced395_cdfc_4802_a67e_74f87df5bfef -->|calls| aee9f739_9a7b_d15f_6c82_a35dce42a8e6
  64e5fc01_a05b_5dea_d1e3_6e5de70174ff["resolveJsId()"]
  aee9f739_9a7b_d15f_6c82_a35dce42a8e6 -->|calls| 64e5fc01_a05b_5dea_d1e3_6e5de70174ff
  ed3d3d26_38f7_571e_0391_5348f28193a1["importModule()"]
  aee9f739_9a7b_d15f_6c82_a35dce42a8e6 -->|calls| ed3d3d26_38f7_571e_0391_5348f28193a1
  5df74edb_ca62_37b7_19bd_9e5c4216afe5["getModuleDependencies()"]
  aee9f739_9a7b_d15f_6c82_a35dce42a8e6 -->|calls| 5df74edb_ca62_37b7_19bd_9e5c4216afe5
  style aee9f739_9a7b_d15f_6c82_a35dce42a8e6 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,
  }
}

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