mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Use Object.assign instead of object spread for serverless loader (#6056)
Fixes https://github.com/zeit/now-builders/issues/168 For some reason with a certain mix of deps `...` is not supported in webpack's parsing. By default it is supported as all our tests passed before and we have deployed Next.js apps on v2 already.
This commit is contained in:
parent
9ab8714f38
commit
da3c3aded1
|
@ -51,27 +51,24 @@ const nextServerlessLoader: loader.Loader = function () {
|
|||
const parsedUrl = parse(req.url, true)
|
||||
try {
|
||||
${page === '/_error' ? `res.statusCode = 404` : ''}
|
||||
const result = await renderToHTML(req, res, "${page}", parsedUrl.query, {
|
||||
...options,
|
||||
const result = await renderToHTML(req, res, "${page}", parsedUrl.query, Object.assign({}, options, {
|
||||
Component
|
||||
})
|
||||
}))
|
||||
return result
|
||||
} catch (err) {
|
||||
if (err.code === 'ENOENT') {
|
||||
res.statusCode = 404
|
||||
const result = await renderToHTML(req, res, "/_error", parsedUrl.query, {
|
||||
...options,
|
||||
const result = await renderToHTML(req, res, "/_error", parsedUrl.query, Object.assign({}, options, {
|
||||
Component: Error
|
||||
})
|
||||
}))
|
||||
return result
|
||||
} else {
|
||||
console.error(err)
|
||||
res.statusCode = 500
|
||||
const result = await renderToHTML(req, res, "/_error", parsedUrl.query, {
|
||||
...options,
|
||||
const result = await renderToHTML(req, res, "/_error", parsedUrl.query, Object.assign({}, options, {
|
||||
Component: Error,
|
||||
err
|
||||
})
|
||||
}))
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue