Valerioageno / ssr-rs

Server side rendering on rust servers using the v8 engine for parse and evaluate the javascript code.

Home Page:https://docs.rs/ssr_rs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RsPack Example?

brianjd opened this issue · comments

commented

Thanks for the project. Are you able to provide an example using Rspack? It is supposed to have equiv API to webpack, but I have been experimenting with various options, but can't seem to get the output configuration right for an IIFE variable entrypoint using the same output configuration from the webpack example configuration as a foundation. TBH the iife output flag didn't make any difference when using named variable output. Here is a sample of the rspack output (I simplified the render function to simply return a string without React rendering):

var SSR;!function(){var e={512:function(e,t,n){"use strict";n.r(t),n.d(t,{Index:function(){return r}});var r=function(e){return'<!doctype html>\n  <html>\n    <head>\n      <title>React SSR</title>\n      <link rel="stylesheet" href="./styles/ssr.css">\n      <\/script>\n    </head>\n    <body>\n    <h1>React SSR</h1>\n    </body>\n  </html>'}}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},SSR=n("512")}();

With all of my experiments, I received "failed to call function". Any pointers will be appreciated.

Hey @brianjd, thanks for the interest on the crate.

I've never used rspack before but I'll take a look. I'll be back to you soon

commented

Thanks @Valerioageno for looking into it, but I was able to resolve it myself. After looking again today with fresh eyes, I realized the wrong assumption I was making with RsPack was that the iife flag defaulted to false. Everything else fell into place after that.

In the while I created the example in the examples/ folder. Thanks for the heads up.