From 810fe4d583aac646bba63c4181826f1629f6df70 Mon Sep 17 00:00:00 2001 From: Evan You Date: Sat, 17 Apr 2021 16:05:27 -0400 Subject: [PATCH] wip: default mode for compat build --- .../runtime-core/src/compat/compatConfig.ts | 4 +++- packages/vue-compat/src/index.ts | 17 ++++++----------- packages/vue/src/index.ts | 17 ++++++----------- 3 files changed, 15 insertions(+), 23 deletions(-) diff --git a/packages/runtime-core/src/compat/compatConfig.ts b/packages/runtime-core/src/compat/compatConfig.ts index 807bfc12..290aa711 100644 --- a/packages/runtime-core/src/compat/compatConfig.ts +++ b/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__) { diff --git a/packages/vue-compat/src/index.ts b/packages/vue-compat/src/index.ts index abd669d0..84573635 100644 --- a/packages/vue-compat/src/index.ts +++ b/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( diff --git a/packages/vue/src/index.ts b/packages/vue/src/index.ts index ced879a9..60ea75fd 100644 --- a/packages/vue/src/index.ts +++ b/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(