create-react-app-ssr
Advanced tools
Comparing version 0.0.1 to 0.0.2
module.exports = { | ||
createSsrRouter: require('./lib/create-ssr-router').createSsrRouter, | ||
createSSRRouter: require('./lib/create-ssr-router').createSSRRouter, | ||
} |
@@ -13,3 +13,3 @@ 'use strict'; | ||
var createSsrRouter = function createSsrRouter(settings) { | ||
var createSSRRouter = function createSSRRouter(settings) { | ||
var router = express.Router(); | ||
@@ -39,3 +39,3 @@ | ||
module.exports = { | ||
createSsrRouter: createSsrRouter | ||
createSSRRouter: createSSRRouter | ||
}; |
@@ -63,3 +63,3 @@ 'use strict'; | ||
console.log('DISABLE JE', ssrDisableJs); | ||
console.log('DISABLE JS', ssrDisableJs); | ||
// avoid to send out the redux state if client js is disabled | ||
@@ -89,3 +89,4 @@ if (ssrDisableJs !== 'yes') { | ||
* Settings: | ||
* - ssrBuild (string) - client app build folder | ||
* - ssrRoot (string) - client app source folder absolute path | ||
* - ssrBuild (string) - client app build folder absolute path | ||
* - ssrPort: (string) - ssr server port for default api calls | ||
@@ -114,3 +115,3 @@ * - ssrTimeout: (int) - rendering timeout in milliseconds | ||
if (staticRender) { | ||
_context.next = 12; | ||
_context.next = 16; | ||
break; | ||
@@ -131,9 +132,26 @@ } | ||
case 7: | ||
_context.next = 12; | ||
if (!(typeof staticRender !== 'function')) { | ||
_context.next = 9; | ||
break; | ||
} | ||
throw new Error('ssr static render does not appear to be a function'); | ||
case 9: | ||
if (!(staticRender.ssrVersion !== '0.0.2')) { | ||
_context.next = 11; | ||
break; | ||
} | ||
throw new Error('ssr static render version signature does not appear to match'); | ||
case 11: | ||
_context.next = 16; | ||
break; | ||
case 9: | ||
_context.prev = 9; | ||
case 13: | ||
_context.prev = 13; | ||
_context.t0 = _context['catch'](3); | ||
// fallback on a default static render that will visualize the error | ||
staticRender = function staticRender() { | ||
@@ -147,8 +165,8 @@ return { | ||
case 12: | ||
case 16: | ||
filePath = path.resolve(path.join(settings.ssrBuild, 'index.html')); | ||
_context.next = 15; | ||
_context.next = 19; | ||
return readFile(filePath); | ||
case 15: | ||
case 19: | ||
htmlTemplate = _context.sent; | ||
@@ -161,3 +179,3 @@ initialState = { | ||
}; | ||
_context.next = 19; | ||
_context.next = 23; | ||
return staticRender(req.url, initialState, { | ||
@@ -168,3 +186,3 @@ timeout: settings.ssrTimeout, | ||
case 19: | ||
case 23: | ||
prerender = _context.sent; | ||
@@ -177,3 +195,3 @@ helmet = Helmet.renderStatic(); | ||
if (!(prerender.context.action === 'REPLACE')) { | ||
_context.next = 24; | ||
_context.next = 28; | ||
break; | ||
@@ -185,3 +203,3 @@ } | ||
case 24: | ||
case 28: | ||
@@ -194,7 +212,7 @@ res.send(prepHTML(htmlTemplate, (0, _extends3.default)({}, settings, { | ||
}))); | ||
_context.next = 30; | ||
_context.next = 34; | ||
break; | ||
case 27: | ||
_context.prev = 27; | ||
case 31: | ||
_context.prev = 31; | ||
_context.t1 = _context['catch'](0); | ||
@@ -204,3 +222,3 @@ | ||
case 30: | ||
case 34: | ||
case 'end': | ||
@@ -210,3 +228,3 @@ return _context.stop(); | ||
} | ||
}, _callee, undefined, [[0, 27], [3, 9]]); | ||
}, _callee, undefined, [[0, 31], [3, 13]]); | ||
})); | ||
@@ -213,0 +231,0 @@ |
@@ -17,3 +17,3 @@ 'use strict'; | ||
* Settings | ||
* - ssrBuild (string) - client app build folder | ||
* - ssrBuild (string) - client app build absolute path | ||
*/ | ||
@@ -20,0 +20,0 @@ var serveAppStatic = function serveAppStatic(settings) { |
@@ -7,3 +7,3 @@ 'use strict'; | ||
* Settings | ||
* - ssrBuild (string) - client app build folder | ||
* - ssrBuild (string) - client app build absolute path | ||
*/ | ||
@@ -10,0 +10,0 @@ var serveBuild = function serveBuild(settings) { |
{ | ||
"name": "create-react-app-ssr", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Server Side Rendering for Create React App (with redux, router, code splitting, ...)", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -10,3 +10,3 @@ const express = require('express') | ||
const createSsrRouter = (settings) => { | ||
const createSSRRouter = (settings) => { | ||
const router = express.Router() | ||
@@ -32,3 +32,3 @@ | ||
module.exports = { | ||
createSsrRouter, | ||
createSSRRouter, | ||
} |
@@ -42,3 +42,3 @@ const path = require('path') | ||
console.log('DISABLE JE', ssrDisableJs) | ||
console.log('DISABLE JS', ssrDisableJs) | ||
// avoid to send out the redux state if client js is disabled | ||
@@ -68,3 +68,4 @@ if (ssrDisableJs !== 'yes') { | ||
* Settings: | ||
* - ssrBuild (string) - client app build folder | ||
* - ssrRoot (string) - client app source folder absolute path | ||
* - ssrBuild (string) - client app build folder absolute path | ||
* - ssrPort: (string) - ssr server port for default api calls | ||
@@ -88,3 +89,10 @@ * - ssrTimeout: (int) - rendering timeout in milliseconds | ||
} | ||
if (typeof staticRender !== 'function') { | ||
throw new Error('ssr static render does not appear to be a function') | ||
} | ||
if (staticRender.ssrVersion !== '0.0.2') { | ||
throw new Error('ssr static render version signature does not appear to match') | ||
} | ||
} catch (err) { | ||
// fallback on a default static render that will visualize the error | ||
staticRender = (() => ({ | ||
@@ -91,0 +99,0 @@ html: err.message, |
@@ -5,3 +5,3 @@ const path = require('path') | ||
* Settings | ||
* - ssrBuild (string) - client app build folder | ||
* - ssrBuild (string) - client app build absolute path | ||
*/ | ||
@@ -8,0 +8,0 @@ const serveAppStatic = (settings) => async (req, res, next) => { |
@@ -6,3 +6,3 @@ | ||
* Settings | ||
* - ssrBuild (string) - client app build folder | ||
* - ssrBuild (string) - client app build absolute path | ||
*/ | ||
@@ -9,0 +9,0 @@ const serveBuild = (settings) => express.static(settings.ssrBuild) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
81626
427