diff --git a/lib/app/index.js b/lib/app/index.js index d3c2db8b9d..ca90697ac0 100644 --- a/lib/app/index.js +++ b/lib/app/index.js @@ -32,9 +32,7 @@ const defaultTransition = <%= .replace('afterLeave(', 'function(').replace('leaveCancelled(', 'function(') %> -export { NuxtError } - -export function createApp (ssrContext) { +function createApp (ssrContext) { <% if (store) { %> const store = createStore() <% } %> @@ -119,3 +117,5 @@ export function createApp (ssrContext) { return { app, router<%= (store ? ', store' : '') %> } } + +export { createApp, NuxtError } diff --git a/lib/generate.js b/lib/generate.js index b6f2827f7f..f0e656dec2 100644 --- a/lib/generate.js +++ b/lib/generate.js @@ -101,18 +101,17 @@ export default function () { try { var { html, error } = yield self.renderRoute(route, { _generate: true }) if(error) { - errors.push({type : "handled", route, error}) + errors.push({ type : 'handled', route, error }) } - } catch(err) { - errors.push({type : "unhandled", route, error : err}) + } catch (err) { + errors.push({ type : 'unhandled', route, error: err }) return - } try { var minifiedHtml = minify(html, self.options.generate.minify) } catch(err) { let minifyErr = new Error(`HTML minification failed. Make sure the route generates valid HTML. Failed HTML:\n ${html}`) - errors.push({type : "unhandled", route, error : minifyErr}) + errors.push({ type : 'unhandled', route, error: minifyErr }) return } var path = join(route, sep, 'index.html') // /about -> /about/index.html @@ -136,15 +135,14 @@ export default function () { const duration = Math.round((Date.now() - s) / 100) / 10 debug(`HTML Files generated in ${duration}s`) - if(errors.length) { - console.error("==== Error report ==== \n" + errors.map( ({type, route, error}) => { - if(type == "unhandled") { - return `Route: '${route}'\n${error.stack}` - } else { - return `Route: '${route}' returned an error via context.error: \n` + - JSON.stringify(error) - } - }).join("\n\n")) + if (errors.length) { + console.error('==== Error report ==== \n' + errors.map( ({type, route, error}) => { + if(type === 'unhandled') { + return `Route: '${route}'\n${error.stack}` + } else { + return `Route: '${route}' thrown an error: \n` + JSON.stringify(error) + } + }).join('\n\n')) } return this })