fix(ssr): avoid hard-coded ssr checks in cjs builds

This commit is contained in:
Evan You
2020-01-29 09:49:17 -05:00
parent 6b1ce00621
commit bc07e95ca8
8 changed files with 31 additions and 19 deletions

View File

@@ -21,7 +21,8 @@ import {
currentInstance,
ComponentInternalInstance,
currentSuspense,
Data
Data,
isInSSRComponentSetup
} from './component'
import {
ErrorCodes,
@@ -86,8 +87,8 @@ export function watch<T = any>(
cbOrOptions?: WatchCallback<T> | WatchOptions,
options?: WatchOptions
): StopHandle {
if (__SSR__ && !(options && options.flush === 'sync')) {
// during SSR, non-sync watchers never fire.
if (isInSSRComponentSetup && !(options && options.flush === 'sync')) {
// component watchers during SSR are no-op
return NOOP
} else if (isFunction(cbOrOptions)) {
// effect callback as 2nd argument - this is a source watcher