Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
fa03f0b9
Commit
fa03f0b9
authored
Feb 05, 2018
by
Tim Neutkens
Committed by
Arunoda Susiripala
Feb 05, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Require files directly instead of resolving them (#3683)
parent
ed122934
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
11 deletions
+11
-11
render.js
server/render.js
+11
-5
require.js
server/require.js
+0
-6
No files found.
server/render.js
View file @
fa03f0b9
...
...
@@ -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'
...
...
@@ -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
...
...
server/require.js
deleted
100644 → 0
View file @
ed122934
import
resolve
from
'./resolve'
export
default
async
function
requireModule
(
path
)
{
const
f
=
await
resolve
(
path
)
return
require
(
f
)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment