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
a1504f4c
Unverified
Commit
a1504f4c
authored
Jul 01, 2022
by
JJ Kasper
Committed by
GitHub
Jul 01, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure page.server.js matches correctly (#38236)
* Ensure app/page.server.js matches correctly * update check
parent
8a76a8f0
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
11 additions
and
3 deletions
+11
-3
base-server.ts
packages/next/server/base-server.ts
+1
-1
next-dev-server.ts
packages/next/server/dev/next-dev-server.ts
+1
-2
get-route-from-entrypoint.ts
packages/next/server/get-route-from-entrypoint.ts
+1
-0
page.server.js
test/e2e/app-dir/app-rendering/app/page.server.js
+3
-0
rendering.test.ts
test/e2e/app-dir/rendering.test.ts
+5
-0
No files found.
packages/next/server/base-server.ts
View file @
a1504f4c
...
@@ -1012,7 +1012,7 @@ export default abstract class Server<ServerOptions extends Options = Options> {
...
@@ -1012,7 +1012,7 @@ export default abstract class Server<ServerOptions extends Options = Options> {
const
appPathRoutes
:
Record
<
string
,
string
>
=
{}
const
appPathRoutes
:
Record
<
string
,
string
>
=
{}
Object
.
keys
(
this
.
appPathsManifest
||
{}).
forEach
((
entry
)
=>
{
Object
.
keys
(
this
.
appPathsManifest
||
{}).
forEach
((
entry
)
=>
{
appPathRoutes
[
normalizeAppPath
(
entry
)]
=
entry
appPathRoutes
[
normalizeAppPath
(
entry
)
||
'/'
]
=
entry
})
})
return
appPathRoutes
return
appPathRoutes
}
}
...
...
packages/next/server/dev/next-dev-server.ts
View file @
a1504f4c
...
@@ -337,9 +337,8 @@ export default class DevServer extends Server {
...
@@ -337,9 +337,8 @@ export default class DevServer extends Server {
})
})
if
(
isAppPath
)
{
if
(
isAppPath
)
{
// TODO: should only routes ending in /index.js be route-able?
const
originalPageName
=
pageName
const
originalPageName
=
pageName
pageName
=
normalizeAppPath
(
pageName
)
pageName
=
normalizeAppPath
(
pageName
)
||
'/'
appPaths
[
pageName
]
=
originalPageName
appPaths
[
pageName
]
=
originalPageName
if
(
routedPages
.
includes
(
pageName
))
{
if
(
routedPages
.
includes
(
pageName
))
{
...
...
packages/next/server/get-route-from-entrypoint.ts
View file @
a1504f4c
...
@@ -29,6 +29,7 @@ export default function getRouteFromEntrypoint(
...
@@ -29,6 +29,7 @@ export default function getRouteFromEntrypoint(
if
(
app
)
{
if
(
app
)
{
pagePath
=
matchBundle
(
APP_ROUTE_NAME_REGEX
,
entryFile
)
pagePath
=
matchBundle
(
APP_ROUTE_NAME_REGEX
,
entryFile
)
if
(
typeof
pagePath
===
'string'
&&
!
pagePath
)
pagePath
=
'/'
if
(
pagePath
)
return
pagePath
if
(
pagePath
)
return
pagePath
}
}
...
...
test/e2e/app-dir/app-rendering/app/page.server.js
0 → 100644
View file @
a1504f4c
export
default
function
Page
(
props
)
{
return
<
p
>
app
/
page
.
server
.
js
<
/p
>
}
test/e2e/app-dir/rendering.test.ts
View file @
a1504f4c
...
@@ -31,6 +31,11 @@ describe('views dir rendering', () => {
...
@@ -31,6 +31,11 @@ describe('views dir rendering', () => {
})
})
afterAll
(()
=>
next
.
destroy
())
afterAll
(()
=>
next
.
destroy
())
it
(
'should serve app/page.server.js at /'
,
async
()
=>
{
const
html
=
await
renderViaHTTP
(
next
.
url
,
'/'
)
expect
(
html
).
toContain
(
'app/page.server.js'
)
})
describe
(
'getServerSideProps only'
,
()
=>
{
describe
(
'getServerSideProps only'
,
()
=>
{
it
(
'should run getServerSideProps in layout and page'
,
async
()
=>
{
it
(
'should run getServerSideProps in layout and page'
,
async
()
=>
{
const
html
=
await
renderViaHTTP
(
const
html
=
await
renderViaHTTP
(
...
...
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