]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
feat: log on the fly template compilation error
authorEvan You <yyx990803@gmail.com>
Fri, 11 Oct 2019 15:16:20 +0000 (11:16 -0400)
committerEvan You <yyx990803@gmail.com>
Fri, 11 Oct 2019 15:16:20 +0000 (11:16 -0400)
packages/runtime-core/src/component.ts
packages/vue/src/index.ts

index 10e0a7ef696ed727384e196274b38e8327f37f23..77ed68ab52d02010c54d41eaedaff73c7709b3af 100644 (file)
@@ -319,7 +319,12 @@ function finishComponentSetup(
     if (Component.template && !Component.render) {
       if (compile) {
         Component.render = compile(Component.template, {
-          onError(err) {}
+          onError(err) {
+            if (__DEV__) {
+              // TODO use err.loc to provide codeframe like Vue 2
+              warn(`Template compilation error: ${err.message}`)
+            }
+          }
         })
       } else if (__DEV__) {
         warn(
index 3ad4bca05cb6bbca906947af6f1d49b25ed6aac0..6e44e7a59b910e48d4c1cdbf74474ef9175ca3ad 100644 (file)
@@ -1,8 +1,8 @@
 // This package is the "full-build" that includes both the runtime
 // and the compiler, and supports on-the-fly compilation of the template option.
 import { compile, CompilerOptions } from '@vue/compiler-dom'
-import * as runtimeDom from '@vue/runtime-dom'
 import { registerRuntimeCompiler, RenderFunction } from '@vue/runtime-dom'
+import * as runtimeDom from '@vue/runtime-dom'
 
 function compileToFunction(
   template: string,
@@ -12,6 +12,7 @@ function compileToFunction(
     hoistStatic: true,
     ...options
   })
+
   return new Function('Vue', code)(runtimeDom) as RenderFunction
 }