-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(runtime-core): unwatch should be callable during SSR #11925
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
@@ -9,6 +9,7 @@ declare var __ESM_BUNDLER__: boolean | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was added to address TypeScript type check errors in the test file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
let setInSSRSetupState: (state: boolean) => void |
__VUE_SSR_SETTERS__.forEach((setInSSRSetupState: SetBoolean) => { | ||
setInSSRSetupState(ssr) | ||
}) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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