]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
perf: do not enable hmr in non-browser envs
authorEvan You <yyx990803@gmail.com>
Tue, 6 Oct 2020 15:35:51 +0000 (11:35 -0400)
committerEvan You <yyx990803@gmail.com>
Tue, 6 Oct 2020 15:51:55 +0000 (11:51 -0400)
packages/runtime-core/src/hmr.ts
packages/runtime-core/src/renderer.ts

index df557313565589c4ac80fdc53fe1a43cc56f7fda..faf4cb24e72f74b955b1a6f4cd6a2dd388a79861 100644 (file)
@@ -25,7 +25,7 @@ export interface HMRRuntime {
 // it easier to be used in toolings like vue-loader
 // Note: for a component to be eligible for HMR it also needs the __hmrId option
 // to be set so that its instances can be registered / removed.
-if (__DEV__) {
+if (__DEV__ && (__BROWSER__ || __TEST__)) {
   const globalObject: any =
     typeof global !== 'undefined'
       ? global
index 217e9a4c2099189fe9628897a10e0f2103a7f678..37f5a2ed7d3616d0817367a0d969d1a922ccb5c5 100644 (file)
@@ -885,7 +885,7 @@ function baseCreateRenderer(
       invokeDirectiveHook(n2, n1, parentComponent, 'beforeUpdate')
     }
 
-    if (__DEV__ && isHmrUpdating) {
+    if (__DEV__ && (__BROWSER__ || __TEST__) && isHmrUpdating) {
       // HMR updated, force full diff
       patchFlag = 0
       optimized = false
@@ -986,7 +986,12 @@ function baseCreateRenderer(
         parentSuspense,
         areChildrenSVG
       )
-      if (__DEV__ && parentComponent && parentComponent.type.__hmrId) {
+      if (
+        __DEV__ &&
+        (__BROWSER__ || __TEST__) &&
+        parentComponent &&
+        parentComponent.type.__hmrId
+      ) {
         traverseStaticChildren(n1, n2)
       }
     } else if (!optimized) {
@@ -1238,7 +1243,7 @@ function baseCreateRenderer(
       parentSuspense
     ))
 
-    if (__DEV__ && instance.type.__hmrId) {
+    if (__DEV__ && (__BROWSER__ || __TEST__) && instance.type.__hmrId) {
       registerHMR(instance)
     }
 
@@ -2109,7 +2114,7 @@ function baseCreateRenderer(
     parentSuspense: SuspenseBoundary | null,
     doRemove?: boolean
   ) => {
-    if (__DEV__ && instance.type.__hmrId) {
+    if (__DEV__ && (__BROWSER__ || __TEST__) && instance.type.__hmrId) {
       unregisterHMR(instance)
     }