mirror of
https://gitee.com/vuejs/vue.git
synced 2024-12-02 20:17:52 +08:00
better bundle renderer error handling
This commit is contained in:
parent
5854f0f781
commit
9344bd7a52
@ -8,12 +8,16 @@ export function createBundleRendererCreator (createRenderer) {
|
||||
renderToString: (context, cb) => {
|
||||
runInVm(code, context).then(app => {
|
||||
renderer.renderToString(app, cb)
|
||||
})
|
||||
}).catch(cb)
|
||||
},
|
||||
renderToStream: (context) => {
|
||||
const res = new PassThrough()
|
||||
runInVm(code, context).then(app => {
|
||||
renderer.renderToStream(app).pipe(res)
|
||||
}).catch(err => {
|
||||
process.nextTick(() => {
|
||||
res.emit('error', err)
|
||||
})
|
||||
})
|
||||
return res
|
||||
}
|
||||
|
@ -30,8 +30,6 @@ export default function runInVm (code, _context) {
|
||||
const res = Object.prototype.hasOwnProperty.call(m.exports, 'default')
|
||||
? m.exports.default
|
||||
: m
|
||||
if (typeof res.then !== 'function') {
|
||||
throw new Error('SSR bundle should export a Promise.')
|
||||
}
|
||||
return res
|
||||
// ensure returning a Promise
|
||||
return Promise.resolve(res)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user