react-loadable
Advanced tools
Comparing version 5.2.4 to 5.3.0
@@ -17,3 +17,8 @@ 'use strict'; | ||
var name = typeof module.libIdent === 'function' ? module.libIdent({ context: context }) : null; | ||
manifest[module.rawRequest] = { id: id, name: name, file: file }; | ||
if (!manifest[module.rawRequest]) { | ||
manifest[module.rawRequest] = []; | ||
} | ||
manifest[module.rawRequest].push({ id: id, name: name, file: file }); | ||
}); | ||
@@ -58,5 +63,5 @@ }); | ||
function getBundles(manifest, moduleIds) { | ||
return moduleIds.map(function (moduleId) { | ||
return manifest[moduleId]; | ||
}); | ||
return moduleIds.reduce(function (bundles, moduleId) { | ||
return bundles.concat(manifest[moduleId]); | ||
}, []); | ||
} | ||
@@ -63,0 +68,0 @@ |
{ | ||
"name": "react-loadable", | ||
"version": "5.2.4", | ||
"version": "5.3.0", | ||
"description": "A higher order component for loading components with promises", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -1112,1 +1112,35 @@ ![React Loadable](http://thejameskyle.com/img/react-loadable-header.png) | ||
``` | ||
### How do I handle other styles `.css` or sourcemaps `.map` with server-side rendering? | ||
When you call [`getBundles`](#getbundles), it may return file types other than | ||
JavaScript depending on your Webpack configuration. | ||
To handle this, you should manually filter down to the file extensions that | ||
you care about: | ||
```js | ||
let bundles = getBundles(stats, modules); | ||
let styles = bundles.filter(bundle => bundle.endsWith('.css')); | ||
let scripts = bundles.filter(bundle => bundle.endsWith('.js')); | ||
res.send(` | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
... | ||
${styles.map(style => { | ||
return `<link href="/dist/${style.file}" rel="stylesheet"/>` | ||
}).join('\n')} | ||
</head> | ||
<body> | ||
<div id="app">${html}</div> | ||
<script src="/dist/main.js"></script> | ||
${scripts.map(script => { | ||
return `<script src="/dist/${script.file}"></script>` | ||
}).join('\n')} | ||
</body> | ||
</html> | ||
`); | ||
``` |
43854
363
1146