Quellcode durchsuchen

wip: default mode for compat build

Evan You vor 5 Jahren
Ursprung
Commit
810fe4d583

+ 3 - 1
packages/runtime-core/src/compat/compatConfig.ts

@@ -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__) {

+ 6 - 11
packages/vue-compat/src/index.ts

@@ -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(

+ 6 - 11
packages/vue/src/index.ts

@@ -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(