]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix: allow hmr in all builds
authorEvan You <yyx990803@gmail.com>
Fri, 27 Nov 2020 15:34:45 +0000 (10:34 -0500)
committerEvan You <yyx990803@gmail.com>
Fri, 27 Nov 2020 15:36:09 +0000 (10:36 -0500)
close #2571

packages/runtime-core/src/component.ts
packages/runtime-core/src/customFormatter.ts
packages/runtime-core/src/hmr.ts
packages/runtime-core/src/renderer.ts

index 99b261a68aecf9d85ccc0bd5c5f201adf7d91d2a..43f700cc2d3ba92127fc1a8ca4cc9dd9722e50e0 100644 (file)
@@ -614,7 +614,7 @@ export function handleSetupResult(
 ) {
   if (isFunction(setupResult)) {
     // setup returned an inline render function
-    if (!__BROWSER__ && (instance.type as ComponentOptions).__ssrInlineRender) {
+    if (__NODE_JS__ && (instance.type as ComponentOptions).__ssrInlineRender) {
       // when the function's name is `ssrRender` (compiled by SFC inline mode),
       // set it as ssrRender instead.
       instance.ssrRender = setupResult
index 706cef6909e06f366ad92d2c4ee80070474298c9..e628f75bad4d37b62ed0b97f2663b2f9b94e2320 100644 (file)
@@ -4,7 +4,8 @@ import { ComponentInternalInstance, ComponentOptions } from './component'
 import { ComponentPublicInstance } from './componentPublicInstance'
 
 export function initCustomFormatter() {
-  if (!__DEV__ || !__BROWSER__) {
+  /* eslint-disable no-restricted-globals */
+  if (!__DEV__ || typeof window === 'undefined') {
     return
   }
 
@@ -189,7 +190,6 @@ export function initCustomFormatter() {
     return `Ref`
   }
 
-  /* eslint-disable no-restricted-globals */
   if ((window as any).devtoolsFormatters) {
     ;(window as any).devtoolsFormatters.push(formatter)
   } else {
index 7f28b2c7aff82012096e590090d65ba864f85712..e90538647f285c11c5abf7f576f5f94d85744ed2 100644 (file)
@@ -26,7 +26,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__ && (__BROWSER__ || __TEST__)) {
+if (__DEV__) {
   const globalObject: any =
     typeof global !== 'undefined'
       ? global
index 9c3b6eefe5a76b8a6f612c304e2da67faaa51a83..7960a2ec0f43f2dc3f058d14641199db0e723cb1 100644 (file)
@@ -889,7 +889,7 @@ function baseCreateRenderer(
       invokeDirectiveHook(n2, n1, parentComponent, 'beforeUpdate')
     }
 
-    if (__DEV__ && (__BROWSER__ || __TEST__) && isHmrUpdating) {
+    if (__DEV__ && isHmrUpdating) {
       // HMR updated, force full diff
       patchFlag = 0
       optimized = false
@@ -990,12 +990,7 @@ function baseCreateRenderer(
         parentSuspense,
         areChildrenSVG
       )
-      if (
-        __DEV__ &&
-        (__BROWSER__ || __TEST__) &&
-        parentComponent &&
-        parentComponent.type.__hmrId
-      ) {
+      if (__DEV__ && parentComponent && parentComponent.type.__hmrId) {
         traverseStaticChildren(n1, n2)
       }
     } else if (!optimized) {
@@ -1248,7 +1243,7 @@ function baseCreateRenderer(
       parentSuspense
     ))
 
-    if (__DEV__ && (__BROWSER__ || __TEST__) && instance.type.__hmrId) {
+    if (__DEV__ && instance.type.__hmrId) {
       registerHMR(instance)
     }
 
@@ -2122,7 +2117,7 @@ function baseCreateRenderer(
     parentSuspense: SuspenseBoundary | null,
     doRemove?: boolean
   ) => {
-    if (__DEV__ && (__BROWSER__ || __TEST__) && instance.type.__hmrId) {
+    if (__DEV__ && instance.type.__hmrId) {
       unregisterHMR(instance)
     }