Home / Function/ preprocess() — vue Function Reference

preprocess() — vue Function Reference

Architecture documentation for the preprocess() function in compileTemplate.ts from the vue codebase.

Entity Profile

Dependency Diagram

graph TD
  bf6db310_cb6d_af32_e89f_f1edbe278348["preprocess()"]
  e30b3e14_d8fc_b1f3_10ef_3add53029405["compileTemplate()"]
  e30b3e14_d8fc_b1f3_10ef_3add53029405 -->|calls| bf6db310_cb6d_af32_e89f_f1edbe278348
  style bf6db310_cb6d_af32_e89f_f1edbe278348 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/compiler-sfc/src/compileTemplate.ts lines 66–95

function preprocess(
  options: SFCTemplateCompileOptions,
  preprocessor: any
): string {
  const { source, filename, preprocessOptions } = options

  const finalPreprocessOptions = Object.assign(
    {
      filename
    },
    preprocessOptions
  )

  // Consolidate exposes a callback based API, but the callback is in fact
  // called synchronously for most templating engines. In our case, we have to
  // expose a synchronous API so that it is usable in Jest transforms (which
  // have to be sync because they are applied via Node.js require hooks)
  let res: any, err
  preprocessor.render(
    source,
    finalPreprocessOptions,
    (_err: Error | null, _res: string) => {
      if (_err) err = _err
      res = _res
    }
  )

  if (err) throw err
  return res
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does preprocess() do?
preprocess() is a function in the vue codebase.
What calls preprocess()?
preprocess() is called by 1 function(s): compileTemplate.

Analyze Your Own Codebase

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

Try Supermodel Free