From f99f21c6ee1817d34efc3441ccb65f5a16da0a8b Mon Sep 17 00:00:00 2001 From: Max Coplan Date: Tue, 17 Nov 2020 10:24:28 -0500 Subject: [PATCH] fix(dev): allow performance marking in production close #11775 Similar to devtools, `Vue.config.devtools` is enabled by default for development and disabled by default for production. However, the developer can choose to override that behavior (for example, for debugging) by manually setting `Vue.config.devtools = true`. However, this same lenience is not afforded to `Vue.config.performance`. Even if explicitly enabling it, the developer's setting will be overridden by Vue in production. This commit brings `Vue.config.performance` in line with `Vue.config.devtools`, by disabling it by default in production, but gives the developer the ability to explicitly enable it; for example, for debugging performance issues. --- packages/weex-vue-framework/factory.js | 6 +++--- src/core/instance/init.js | 4 ++-- src/core/instance/lifecycle.js | 2 +- src/platforms/web/entry-runtime-with-compiler.js | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/weex-vue-framework/factory.js b/packages/weex-vue-framework/factory.js index 4cb547b5250..c32ecd69139 100644 --- a/packages/weex-vue-framework/factory.js +++ b/packages/weex-vue-framework/factory.js @@ -4236,7 +4236,7 @@ function mountComponent ( var updateComponent; /* istanbul ignore if */ - if (process.env.NODE_ENV !== 'production' && config.performance && mark) { + if (config.performance && mark) { updateComponent = function () { var name = vm._name; var id = vm._uid; @@ -5161,7 +5161,7 @@ function initMixin (Vue) { var startTag, endTag; /* istanbul ignore if */ - if (process.env.NODE_ENV !== 'production' && config.performance && mark) { + if (config.performance && mark) { startTag = "vue-perf-start:" + (vm._uid); endTag = "vue-perf-end:" + (vm._uid); mark(startTag); @@ -5200,7 +5200,7 @@ function initMixin (Vue) { callHook(vm, 'created'); /* istanbul ignore if */ - if (process.env.NODE_ENV !== 'production' && config.performance && mark) { + if (config.performance && mark) { vm._name = formatComponentName(vm, false); mark(endTag); measure(("vue " + (vm._name) + " init"), startTag, endTag); diff --git a/src/core/instance/init.js b/src/core/instance/init.js index 7c5ab2da963..808a8f3d9bb 100644 --- a/src/core/instance/init.js +++ b/src/core/instance/init.js @@ -20,7 +20,7 @@ export function initMixin (Vue: Class) { let startTag, endTag /* istanbul ignore if */ - if (process.env.NODE_ENV !== 'production' && config.performance && mark) { + if (config.performance && mark) { startTag = `vue-perf-start:${vm._uid}` endTag = `vue-perf-end:${vm._uid}` mark(startTag) @@ -59,7 +59,7 @@ export function initMixin (Vue: Class) { callHook(vm, 'created') /* istanbul ignore if */ - if (process.env.NODE_ENV !== 'production' && config.performance && mark) { + if (config.performance && mark) { vm._name = formatComponentName(vm, false) mark(endTag) measure(`vue ${vm._name} init`, startTag, endTag) diff --git a/src/core/instance/lifecycle.js b/src/core/instance/lifecycle.js index b7265df0aaf..77273c02bf9 100644 --- a/src/core/instance/lifecycle.js +++ b/src/core/instance/lifecycle.js @@ -168,7 +168,7 @@ export function mountComponent ( let updateComponent /* istanbul ignore if */ - if (process.env.NODE_ENV !== 'production' && config.performance && mark) { + if (config.performance && mark) { updateComponent = () => { const name = vm._name const id = vm._uid diff --git a/src/platforms/web/entry-runtime-with-compiler.js b/src/platforms/web/entry-runtime-with-compiler.js index 2bb46362bf9..06a6186cb08 100644 --- a/src/platforms/web/entry-runtime-with-compiler.js +++ b/src/platforms/web/entry-runtime-with-compiler.js @@ -58,7 +58,7 @@ Vue.prototype.$mount = function ( } if (template) { /* istanbul ignore if */ - if (process.env.NODE_ENV !== 'production' && config.performance && mark) { + if (config.performance && mark) { mark('compile') } @@ -73,7 +73,7 @@ Vue.prototype.$mount = function ( options.staticRenderFns = staticRenderFns /* istanbul ignore if */ - if (process.env.NODE_ENV !== 'production' && config.performance && mark) { + if (config.performance && mark) { mark('compile end') measure(`vue ${this._name} compile`, 'compile', 'compile end') }