Home / Function/ createCompilerCreator() — vue Function Reference

createCompilerCreator() — vue Function Reference

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

Function typescript VueCore VDom calls 2 called by 1

Entity Profile

Dependency Diagram

graph TD
  97855b39_317e_b246_a520_910b41a8b140["createCompilerCreator()"]
  ff1da07c_8f38_b75f_ad5a_42883a44a3df["create-compiler.ts"]
  97855b39_317e_b246_a520_910b41a8b140 -->|defined in| ff1da07c_8f38_b75f_ad5a_42883a44a3df
  6c590cdd_9255_3485_21a0_c8a067eb1658["createCompiler()"]
  6c590cdd_9255_3485_21a0_c8a067eb1658 -->|calls| 97855b39_317e_b246_a520_910b41a8b140
  e66ee5bd_47db_4014_39bb_43bc88cdcf05["detectErrors()"]
  97855b39_317e_b246_a520_910b41a8b140 -->|calls| e66ee5bd_47db_4014_39bb_43bc88cdcf05
  de1bc371_80db_723d_3fc8_276c93f033c1["createCompileToFunctionFn()"]
  97855b39_317e_b246_a520_910b41a8b140 -->|calls| de1bc371_80db_723d_3fc8_276c93f033c1
  style 97855b39_317e_b246_a520_910b41a8b140 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)
    }
  }
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does createCompilerCreator() do?
createCompilerCreator() is a function in the vue codebase, defined in src/compiler/create-compiler.ts.
Where is createCompilerCreator() defined?
createCompilerCreator() is defined in src/compiler/create-compiler.ts at line 6.
What does createCompilerCreator() call?
createCompilerCreator() calls 2 function(s): createCompileToFunctionFn, detectErrors.
What calls createCompilerCreator()?
createCompilerCreator() is called by 1 function(s): createCompiler.

Analyze Your Own Codebase

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

Try Supermodel Free