Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
);
// get all bundles that are necessary for the current route
// `stats` is the asset-manifest of application that contains list of all bundles and chunks
// `modules` is list of current route's modules that detected by react loadable
const modulesToBeLoaded = [...Array.from(modules)];
const bundles = getBundles(stats, modulesToBeLoaded);
const indexFile = path.resolve("./dist/index.html");
fs.readFile(indexFile, "utf8", (err, indexData) => {
if (err) {
console.error("Something went wrong:", err);
return res.status(500).send("Oops, better luck next time!");
}
if (context.status === 404) {
res.status(404);
}
if (context.url) {
return res.redirect(301, context.url);
}
let styles = "";
server.get('*', (req, res) => {
const modules = new Set();
const html = renderToString(
modules.add(moduleName)}>
);
const bundles = getBundles(manifest, [...manifest.entrypoints, ...Array.from(modules)]);
const styles = bundles.css || [];
const scripts = bundles.js || [];
res.send(`
<title>React Loadable SSR Add-on Example</title>
${styles.map(style => {
return ``;
}).join('\n')}