-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
feat(server-renderer): support for non-Node.js Environments #3460
feat(server-renderer): support for non-Node.js Environments #3460
Conversation
Here are the steps to test this proposed change
This builds (using the current source with this PR merged) the vue packages, including the newly created
This repo has one extra folder:
The end result, in the
Then there are two non node SSR versions, compiled as some other target so it can be used with
|
TestingThe requirements to test these two php-v8 SSR versions are:
Here is the result of both tests
And
With the only difference between the two versions being the use of the newly created |
Testing without phpEven without Here is the diff between dist/phpv8/current/index.js and dist/phpv8/proposed/index.js: it is essentially only the removal of 7104,7107c7104,7107
< /***/ "../packages/server-renderer/dist/server-renderer.cjs.js":
< /*!***************************************************************!*\
< !*** ../packages/server-renderer/dist/server-renderer.cjs.js ***!
< \***************************************************************/
---
> /***/ "../packages/server-renderer/dist/server-renderer.basic-cjs.js":
> /*!*********************************************************************!*\
> !*** ../packages/server-renderer/dist/server-renderer.basic-cjs.js ***!
> \*********************************************************************/
7118d7117
< var stream = __webpack_require__(/*! stream */ "stream");
7895,7951d7893
< const { isVNode: isVNode$1 } = vue.ssrUtils;
< async function unrollBuffer$1(buffer, stream) {
< if (buffer.hasAsync) {
< for (let i = 0; i < buffer.length; i++) {
< let item = buffer[i];
< if (shared.isPromise(item)) {
< item = await item;
< }
< if (shared.isString(item)) {
< stream.push(item);
< }
< else {
< await unrollBuffer$1(item, stream);
< }
< }
< }
< else {
< // sync buffer can be more efficiently unrolled without unnecessary await
< // ticks
< unrollBufferSync$1(buffer, stream);
< }
< }
< function unrollBufferSync$1(buffer, stream) {
< for (let i = 0; i < buffer.length; i++) {
< let item = buffer[i];
< if (shared.isString(item)) {
< stream.push(item);
< }
< else {
< // since this is a sync buffer, child buffers are never promises
< unrollBufferSync$1(item, stream);
< }
< }
< }
< function renderToStream(input, context = {}) {
< if (isVNode$1(input)) {
< // raw vnode, wrap with app (for context)
< return renderToStream(vue.createApp({ render: () => input }), context);
< }
< // rendering an app
< const vnode = vue.createVNode(input._component, input._props);
< vnode.appContext = input._context;
< // provide the ssr context to the tree
< input.provide(vue.ssrContextKey, context);
< const stream$1 = new stream.Readable();
< Promise.resolve(renderComponentVNode(vnode))
< .then(buffer => unrollBuffer$1(buffer, stream$1))
< .then(() => {
< stream$1.push(null);
< })
< .catch(error => {
< stream$1.destroy(error);
< });
< return stream$1;
< }
<
< exports.renderToStream = renderToStream;
7991,8006d7932
< /***/ "../packages/server-renderer/index.js":
< /*!********************************************!*\
< !*** ../packages/server-renderer/index.js ***!
< \********************************************/
< /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
<
< "use strict";
<
<
< if (false) {} else {
< module.exports = __webpack_require__(/*! ./dist/server-renderer.cjs.js */ "../packages/server-renderer/dist/server-renderer.cjs.js")
< }
<
<
< /***/ }),
<
19018,19028d18943
< /***/ }),
<
< /***/ "stream":
< /*!*************************!*\
< !*** external "stream" ***!
< \*************************/
< /***/ ((module) => {
<
< "use strict";
< module.exports = require("stream");;
<
19115c19030
< const renderer = __webpack_require__(/*! @vue/server-renderer */ "../packages/server-renderer/index.js")
---
> const renderer = __webpack_require__(/*! @vue/server-renderer */ "../packages/server-renderer/dist/server-renderer.basic-cjs.js") |
After 0867222, |
Thanks! |
Previous version of this package (
vue-server-renderer
) had support for non-Nodejs (see https://ssr.vuejs.org/guide/non-node.html).It continued working on vue-next but regressed when this PR was merged: #1197 because
stream
is node only.This PR proposes to create, like existed on
vue@2
, a "basic" version ofserver-renderer
without node only requirements.Please appreciate and review.
This PR likely fixes #3111 root cause
Also fixes #3467