Skip to content

Commit

Permalink
Require files directly instead of resolving them (#3683)
Browse files Browse the repository at this point in the history
  • Loading branch information
timneutkens authored and arunoda committed Feb 5, 2018
1 parent ed12293 commit fa03f0b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
16 changes: 11 additions & 5 deletions server/render.js
Expand Up @@ -4,7 +4,6 @@ import { renderToString, renderToStaticMarkup } from 'react-dom/server'
import send from 'send'
import generateETag from 'etag'
import fresh from 'fresh'
import requireModule from './require'
import getConfig from './config'
import { Router } from '../lib/router'
import { loadGetInitialProps, isResSent } from '../lib/utils'
Expand Down Expand Up @@ -55,10 +54,17 @@ async function doRender (req, res, pathname, query, {
const pagePath = join(dir, dist, 'dist', 'bundles', 'pages', page)
const documentPath = join(dir, dist, 'dist', 'bundles', 'pages', '_document')

let [Component, Document] = await Promise.all([
requireModule(pagePath),
requireModule(documentPath)
])
let Component
let Document
try {
Component = require(pagePath)
Document = require(documentPath)
} catch (err) {
const err = new Error(`Cannot find module`)
err.code = 'ENOENT'
throw err
}

Component = Component.default || Component
Document = Document.default || Document
const asPath = req.url
Expand Down
6 changes: 0 additions & 6 deletions server/require.js

This file was deleted.

0 comments on commit fa03f0b

Please sign in to comment.