diff --git a/packages/avet-build/lib/createCompiler.js b/packages/avet-build/lib/createCompiler.js index e8a0564..28c21e0 100644 --- a/packages/avet-build/lib/createCompiler.js +++ b/packages/avet-build/lib/createCompiler.js @@ -19,7 +19,6 @@ const { } = require('./utils'); const relativeResolve = require('./root-module-relative-path')(require); -const absoluteResolve = require('./absolute-path')(require); module.exports = async function createCompiler( dir, @@ -48,14 +47,14 @@ module.exports = async function createCompiler( const defaultEntries = dev ? [ - require.resolve('avet-client/src/webpack-hot-middleware-client'), - require.resolve('avet-client/src/on-demand-entries-client'), + require.resolve('avet-client/lib/webpack-hot-middleware-client'), + require.resolve('avet-client/lib/on-demand-entries-client'), ] : []; const mainJS = dev - ? require.resolve('avet-client/src/avet-dev') - : require.resolve('avet-client/src/avet'); + ? require.resolve('avet-client/lib/avet-dev') + : require.resolve('avet-client/lib/avet'); let totalPages; diff --git a/packages/avet-utils/lib/component.js b/packages/avet-utils/lib/component.js index f9bcfa6..8883d32 100644 --- a/packages/avet-utils/lib/component.js +++ b/packages/avet-utils/lib/component.js @@ -2,17 +2,24 @@ function getDisplayName(Component) { return Component.displayName || Component.name || 'UnKnown'; } -async function loadGetInitialProps(Component, ctx) { - if (!Component.getInitialProps) return {}; +function loadGetInitialProps(Component, ctx) { + return new Promise(function(resolve, reject) { + if (!Component.getInitialProps) return resolve({}); - const props = await Component.getInitialProps(ctx); - if (!props && (!ctx.res || !ctx.res.finished)) { - const compName = getDisplayName(Component); - const message = `"${compName}.getInitialProps()" should resolve to an object. But found "${props}" instead.`; - throw new Error(message); - } + Component.getInitialProps(ctx).then(function(props) { + if (!props && (!ctx.res || !ctx.res.finished)) { + const compName = getDisplayName(Component); + const message = `"${ + compName + }.getInitialProps()" should resolve to an object. But found "${ + props + }" instead.`; + return reject(message); + } - return props; + return resolve(props); + }) + }) } module.exports = {