vue
vue copied to clipboard
Optimized async functional components fail to server-side render on initial render
Version
2.7.14
Reproduction link
Steps to reproduce
Run main.js
in the reproduction link
What is expected?
Each render in that reproduction would work
What is actually happening?
The first render of OptimizedAsyncFunctionalComponent
fails, but subsequent ones succeed.
It appears that vue-server-renderer
calls installSSRHelpers
which adds _ssrNode
and other SSR optimization helpers to Vue.prototype
and Vue.FunctionalRenderContext.prototype
. However, when rendering an async functional component, the built version of vue-server-renderer
has its own definition of FunctionalRenderContext
(appears to be bundled at build time along with things like createFunctionalComponent
instead of importing from vue itself at runtime) which does not have the SSR helpers on it.
Setting optimizeSSR: false
in vue-loader
options seems to work as a bandaid solution since the optimization helpers are not used, but this seems like a bad idea for performance.
EDIT: also, changing it to a regular component (not functional) also works as a workaround