Uploaded image for project: 'Magnolia Frontend Helpers'
  1. Magnolia Frontend Helpers
  2. MGNLFE-23

Enable Server-Side Rendering

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Critical Critical
    • 1.0.1
    • None
    • None
    • None
    • 6.2.1 Ramp-up 22
    • 2

      Libraries cause errors and failed builds when doing SSR because "window" object is not available when rendering in Node on the server, rather than in the browser. SSR is important for SPA projects and is used on most Magnolia SPA enterprise projects that I am aware of.

      Window object can still be used but it must be wrapped in a check if the object is available, or a special library to handle the problem can be used, such as "global" on npm.

       

      ReferenceError: window is not defined
          at Object.<anonymous>
      

      This seems to be primarily related to the webpack build - as the built libraries include 'window'.

       

      A few resources on the topic:

      https://webpack.js.org/configuration/output/

      https://sitecore.stackexchange.com/questions/16437/ssr-issue-window-not-defined

      https://stackoverflow.com/questions/38951721/react-js-server-side-issue-window-not-found

       

       

        Acceptance criteria

              lam.nguyen Lam Nguyen Bao
              czimmermann Christopher Zimmermann
              Votes:
              7 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved:

                  Task DoD

                    Estimated:
                    Original Estimate - Not Specified
                    Not Specified
                    Remaining:
                    Time Spent - 3.5d Remaining Estimate - 40d 6.5h
                    40d 6.5h
                    Logged:
                    Time Spent - 3.5d Remaining Estimate - 40d 6.5h
                    3.5d