fix(runtime-core): unwatch should be callable during SSR#11925
fix(runtime-core): unwatch should be callable during SSR#11925yyx990803 merged 2 commits intovuejs:mainfrom
Conversation
Size ReportBundles
Usages
|
@vue/compiler-core
@vue/compiler-dom
@vue/compiler-ssr
@vue/compiler-sfc
@vue/reactivity
@vue/runtime-core
@vue/runtime-dom
@vue/shared
@vue/server-renderer
@vue/compat
vue
commit: |
packages/global.d.ts
Outdated
| declare var __ESM_BROWSER__: boolean | ||
| declare var __CJS__: boolean | ||
| declare var __SSR__: boolean | ||
| declare var __VUE_SSR_SETTERS__: Array<(v: boolean) => void> |
There was a problem hiding this comment.
This was added to address TypeScript type check errors in the test file.
There was a problem hiding this comment.
Let me know if it's undesirable to declare __VUE_SSR_SETTERS__. Maybe that exposes this type and it's not intended to be public. If so, is there a better way to type that interface in the unit test?
There was a problem hiding this comment.
Maybe we can export setInSSRSetupState and import it into apiWatch.spec.ts using a relative path.
core/packages/runtime-core/src/component.ts
Line 715 in 4019369
| __VUE_SSR_SETTERS__.forEach((setInSSRSetupState: SetBoolean) => { | ||
| setInSSRSetupState(ssr) | ||
| }) | ||
| } |
There was a problem hiding this comment.
This exists to hit the SSR code path that has the regression.
| watchStopHandle.stop = NOOP | ||
| watchStopHandle.resume = NOOP | ||
| watchStopHandle.pause = NOOP | ||
| return watchStopHandle |
There was a problem hiding this comment.
I considered doing this:
return Object.assign(() => {}, {
stop: NOOP,
resume: NOOP,
pause: NOOP,
})But decided against it to avoid the temporary allocation of the object literal.
|
The better way to test the SSR code path is to actually render the component with |
Fixes the unwatch is not a function TypeError reported in #11924.
fix #11924