Home / Function/ _createSourceFile() — ui Function Reference

_createSourceFile() — ui Function Reference

Architecture documentation for the _createSourceFile() function in update-tailwind-config.ts from the ui codebase.

Entity Profile

Dependency Diagram

graph TD
  54febefd_ee20_a17f_1f9e_12babcc8092a["_createSourceFile()"]
  ef3e192c_eced_bc46_1021_689faf6b7065["update-tailwind-config.ts"]
  54febefd_ee20_a17f_1f9e_12babcc8092a -->|defined in| ef3e192c_eced_bc46_1021_689faf6b7065
  bcd6344c_3146_377d_9fd0_f68ae594bdfb["transformTailwindConfig()"]
  bcd6344c_3146_377d_9fd0_f68ae594bdfb -->|calls| 54febefd_ee20_a17f_1f9e_12babcc8092a
  c5708093_d860_eaff_f0d3_0bcb8e1daa1e["parseObjectLiteral()"]
  c5708093_d860_eaff_f0d3_0bcb8e1daa1e -->|calls| 54febefd_ee20_a17f_1f9e_12babcc8092a
  style 54febefd_ee20_a17f_1f9e_12babcc8092a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/shadcn/src/utils/updaters/update-tailwind-config.ts lines 267–284

export async function _createSourceFile(input: string, config: Config | null) {
  const dir = await fs.mkdtemp(path.join(tmpdir(), "shadcn-"))
  const resolvedPath =
    config?.resolvedPaths?.tailwindConfig || "tailwind.config.ts"
  const tempFile = path.join(dir, `shadcn-${path.basename(resolvedPath)}`)

  const project = new Project({
    compilerOptions: {},
  })
  const sourceFile = project.createSourceFile(tempFile, input, {
    // Note: .js and .mjs can still be valid for TS projects.
    // We can't infer TypeScript from config.tsx.
    scriptKind:
      path.extname(resolvedPath) === ".ts" ? ScriptKind.TS : ScriptKind.JS,
  })

  return sourceFile
}

Subdomains

Frequently Asked Questions

What does _createSourceFile() do?
_createSourceFile() is a function in the ui codebase, defined in packages/shadcn/src/utils/updaters/update-tailwind-config.ts.
Where is _createSourceFile() defined?
_createSourceFile() is defined in packages/shadcn/src/utils/updaters/update-tailwind-config.ts at line 267.
What calls _createSourceFile()?
_createSourceFile() is called by 2 function(s): parseObjectLiteral, transformTailwindConfig.

Analyze Your Own Codebase

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

Try Supermodel Free