Skip to content
This repository has been archived by the owner on Nov 28, 2022. It is now read-only.

SSR-ready bundle for the RDMD engine. #767

Merged
merged 8 commits into from
Jun 25, 2020
Merged

Conversation

rafegoldberg
Copy link
Contributor

@rafegoldberg rafegoldberg commented Jun 5, 2020

🧰 Changes

The Issue

We introduced some stop-gap SSR improvements yesterday that caused breakage on a small portion of pages using certain HTML entity characters. The issue stemmed from a sub-dependency of Unified which was referencing the browser's document global even when it was running on the server side.

The Fix

This PR adds a secondary SSR-specific webpack config with a target of "node", which builds a new dist/main.ssr.js bundle (per this suggestion):

const serverConfig = merge(browserConfig, {
target: 'node',
output: {
filename: '[name].node.js',
},
});
module.exports = [browserConfig, serverConfig];

If we pull in this new SSR bundle, we can safely use the RDMD engine to server-side render our docs without worry as to this class of reference errors around undefined browser globals!

🚧 To Do

  • Use the more conventional .node.js extension for the server-side bundle.
  • Add/update the main and browser package fields.

🧪 Testing

Since we rolled back the SSR work last night we can't actually see this breakage in production, but you can see that the previously broken pages are now working in this PR app.

To verify that the SSR is working for yourself, try reloading with Javascript disabled. You should see the doc's content when using this staging app, but not on production.

add a duplicate webpack config with the target set to "node" to build the rdmd engine for server-side rendering.
@rafegoldberg rafegoldberg added type:enhancement A potential new feature to be added, or an improvement we could make Markdown labels Jun 5, 2020
@rafegoldberg rafegoldberg requested a review from erunion June 24, 2020 03:45
@rafegoldberg rafegoldberg merged commit 4422341 into master Jun 25, 2020
@rafegoldberg rafegoldberg deleted the rdmd/feat/ssr-build branch June 25, 2020 18:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type:enhancement A potential new feature to be added, or an improvement we could make
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants