Broken SSR bundle for worker environments
Version
3.1.5
Reproduction link
https://github.com/frandiox/vite-vue-bundle-issue
Steps to reproduce
yarn && yarn build && yarn test
What is expected?
It should create a functional SSR bundle.
What is actually happening?
The created SSR bundle is missing ssrUtils
so the app crashes since it tries to read a property of null
. It is likely related to this line: https://github.com/vuejs/vue-next/blob/3a75d5d6942a1743789192dca9161f7c30a71e58/packages/runtime-core/src/index.ts#L316
SSR bundle is useful for environments such as workers, where there is no import
or require
at run time.
The bundle is generated correctly using Webpack or ESBuild but I could not make it work with Vite.
A related problem is that Vue imports Node's stream
at the top of the bundle (it is used when calling renderToStream
), which crashes the worker. It is currently necessary mocking the stream
module in the bundler.