]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
wip: default mode for compat build
authorEvan You <yyx990803@gmail.com>
Sat, 17 Apr 2021 20:05:27 +0000 (16:05 -0400)
committerEvan You <yyx990803@gmail.com>
Sat, 17 Apr 2021 20:05:27 +0000 (16:05 -0400)
packages/runtime-core/src/compat/compatConfig.ts
packages/vue-compat/src/index.ts
packages/vue/src/index.ts

index 807bfc12f413a97bddc176b25118e9b3b5a63395..290aa711b54033bfa3d8a21a3b9078b278d65672 100644 (file)
@@ -456,7 +456,9 @@ export type CompatConfig = Partial<
   MODE?: 2 | 3
 }
 
-export const globalCompatConfig: CompatConfig = {}
+export const globalCompatConfig: CompatConfig = {
+  MODE: 2
+}
 
 export function configureCompat(config: CompatConfig) {
   if (__DEV__) {
index abd669d0cc3942b252961aec54d0d2072e3a65d6..845736352ff3048b2d6a4e6907b2e5bdc6b5039f 100644 (file)
@@ -55,22 +55,17 @@ function compileToFunction(
     extend(
       {
         hoistStatic: true,
-        onError(err) {
-          if (__DEV__) {
-            onError(err)
-          } else {
-            /* istanbul ignore next */
-            throw err
-          }
-        },
-        onWarn: __DEV__ ? onError : NOOP
+        onError: __DEV__ ? onError : undefined,
+        onWarn: __DEV__ ? e => onError(e, true) : NOOP
       } as CompilerOptions,
       options
     )
   )
 
-  function onError(err: CompilerError) {
-    const message = `Template compilation error: ${err.message}`
+  function onError(err: CompilerError, asWarning = false) {
+    const message = asWarning
+      ? err.message
+      : `Template compilation error: ${err.message}`
     const codeFrame =
       err.loc &&
       generateCodeFrame(
index ced879a928ae1008a0f1857c867c5e5cc9126628..60ea75fd4db5de345082beaa0c6116ef5060f77f 100644 (file)
@@ -49,22 +49,17 @@ function compileToFunction(
     extend(
       {
         hoistStatic: true,
-        onError(err) {
-          if (__DEV__) {
-            onError(err)
-          } else {
-            /* istanbul ignore next */
-            throw err
-          }
-        },
-        onWarn: __DEV__ ? onError : NOOP
+        onError: __DEV__ ? onError : undefined,
+        onWarn: __DEV__ ? e => onError(e, true) : NOOP
       } as CompilerOptions,
       options
     )
   )
 
-  function onError(err: CompilerError) {
-    const message = `Template compilation error: ${err.message}`
+  function onError(err: CompilerError, asWarning = false) {
+    const message = asWarning
+      ? err.message
+      : `Template compilation error: ${err.message}`
     const codeFrame =
       err.loc &&
       generateCodeFrame(