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
  04307c3f_aa3a_2ee6_85e3_aebc122881e3["createCompilerCreator()"]
  0eb11b52_7b12_f1cc_ae13_a11bead27b1a["createCompiler()"]
  0eb11b52_7b12_f1cc_ae13_a11bead27b1a -->|calls| 04307c3f_aa3a_2ee6_85e3_aebc122881e3
  4a6c1fba_4814_b3d9_ff02_8fe63201f887["createCompiler()"]
  4a6c1fba_4814_b3d9_ff02_8fe63201f887 -->|calls| 04307c3f_aa3a_2ee6_85e3_aebc122881e3
  7a0093e3_a58a_af71_971f_488b65897e74["extend()"]
  04307c3f_aa3a_2ee6_85e3_aebc122881e3 -->|calls| 7a0093e3_a58a_af71_971f_488b65897e74
  b0242a69_428b_2b21_4cf2_53cd84f58d01["detectErrors()"]
  04307c3f_aa3a_2ee6_85e3_aebc122881e3 -->|calls| b0242a69_428b_2b21_4cf2_53cd84f58d01
  f2d18c28_9782_02d0_c983_083b86068c69["createCompileToFunctionFn()"]
  04307c3f_aa3a_2ee6_85e3_aebc122881e3 -->|calls| f2d18c28_9782_02d0_c983_083b86068c69
  style 04307c3f_aa3a_2ee6_85e3_aebc122881e3 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