Home / Function/ createCompilerCreator() — vue Function Reference

createCompilerCreator() — vue Function Reference

Architecture documentation for the createCompilerCreator() function in create-compiler.ts from the vue codebase.

Entity Profile

Dependency Diagram

graph TD
  da6f913d_df09_ab43_1296_7f19325c6a21["createCompilerCreator()"]
  6fdcd133_a6e0_85e7_3ef7_7feb272a29b3["createCompiler()"]
  6fdcd133_a6e0_85e7_3ef7_7feb272a29b3 -->|calls| da6f913d_df09_ab43_1296_7f19325c6a21
  5e33e1e0_159e_45ee_a1cd_33a5b88f58de["createCompiler()"]
  5e33e1e0_159e_45ee_a1cd_33a5b88f58de -->|calls| da6f913d_df09_ab43_1296_7f19325c6a21
  133969d0_a7bd_f1c5_46a3_9fb8fd249583["extend()"]
  da6f913d_df09_ab43_1296_7f19325c6a21 -->|calls| 133969d0_a7bd_f1c5_46a3_9fb8fd249583
  b8d0ad80_7068_9cdf_d436_0495b6140d72["detectErrors()"]
  da6f913d_df09_ab43_1296_7f19325c6a21 -->|calls| b8d0ad80_7068_9cdf_d436_0495b6140d72
  c16a3cd4_68e6_1d49_ea28_e5acec70d6e2["createCompileToFunctionFn()"]
  da6f913d_df09_ab43_1296_7f19325c6a21 -->|calls| c16a3cd4_68e6_1d49_ea28_e5acec70d6e2
  style da6f913d_df09_ab43_1296_7f19325c6a21 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

src/compiler/create-compiler.ts lines 6–83

export function createCompilerCreator(baseCompile: Function): Function {
  return function createCompiler(baseOptions: CompilerOptions) {
    function compile(
      template: string,
      options?: CompilerOptions
    ): CompiledResult {
      const finalOptions = Object.create(baseOptions)
      const errors: WarningMessage[] = []
      const tips: WarningMessage[] = []

      let warn = (
        msg: WarningMessage,
        range: { start: number; end: number },
        tip: string
      ) => {
        ;(tip ? tips : errors).push(msg)
      }

      if (options) {
        if (__DEV__ && options.outputSourceRange) {
          // $flow-disable-line
          const leadingSpaceLength = template.match(/^\s*/)![0].length

          warn = (
            msg: WarningMessage | string,
            range: { start: number; end: number },
            tip: string
          ) => {
            const data: WarningMessage = typeof msg === 'string' ? { msg } : msg
            if (range) {
              if (range.start != null) {
                data.start = range.start + leadingSpaceLength
              }
              if (range.end != null) {
                data.end = range.end + leadingSpaceLength
              }
            }
            ;(tip ? tips : errors).push(data)
          }
        }
        // merge custom modules
        if (options.modules) {
          finalOptions.modules = (baseOptions.modules || []).concat(
            options.modules
          )
        }
        // merge custom directives
        if (options.directives) {
          finalOptions.directives = extend(
            Object.create(baseOptions.directives || null),
            options.directives
          )
        }
        // copy other options
        for (const key in options) {
          if (key !== 'modules' && key !== 'directives') {
            finalOptions[key] = options[key as keyof CompilerOptions]
          }
        }
      }

      finalOptions.warn = warn

      const compiled = baseCompile(template.trim(), finalOptions)
      if (__DEV__) {
        detectErrors(compiled.ast, warn)
      }
      compiled.errors = errors
      compiled.tips = tips
      return compiled
    }

    return {
      compile,
      compileToFunctions: createCompileToFunctionFn(compile)
    }
  }
}

Subdomains

Frequently Asked Questions

What does createCompilerCreator() do?
createCompilerCreator() is a function in the vue codebase.
What does createCompilerCreator() call?
createCompilerCreator() calls 3 function(s): createCompileToFunctionFn, detectErrors, extend.
What calls createCompilerCreator()?
createCompilerCreator() is called by 2 function(s): createCompiler, createCompiler.

Analyze Your Own Codebase

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

Try Supermodel Free