1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Fix __route error when importing a page inside a page (#3644)

* Check if Component is defined

* Add comment

* Fix linting
This commit is contained in:
Tim Neutkens 2018-01-31 18:20:27 +01:00 committed by Arunoda Susiripala
parent 7b2cd84fee
commit 4db7e8fe9e

View file

@ -5,8 +5,11 @@ module.exports = function (content, sourceMap) {
const route = getRoute(this)
// Webpack has a built in system to prevent default from colliding, giving it a random letter per export.
// We can safely check if Component is undefined since all other pages imported into the entrypoint don't have __webpack_exports__.default
this.callback(null, `${content}
(function (Component, route) {
if(!Component) return
if (!module.hot) return
module.hot.accept()
Component.__route = route