-
Notifications
You must be signed in to change notification settings - Fork 29k
Skip emitting pages router entries when only app router present #82444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
huozhi
wants to merge
39
commits into
canary
Choose a base branch
from
huozhi/08-05-error_500_entry
base: canary
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
67051be
renaming
huozhi d0c0941
handle skip moving the pages when no custom pages present
huozhi 6eb4731
generate app router 500.html
huozhi 1886aa7
static gen and add test
huozhi 657db6d
reuse global-error
huozhi 98c6bbe
use app-error tos simplify page
huozhi 68bc2c4
filter out in the log
huozhi 5c1fba9
turbopack handling
huozhi 7975881
fix move page path
huozhi f3b1972
handle empty entry
huozhi 6c9e4de
fix empty entries
huozhi aa762f8
fix client entry
huozhi 96caaa9
fix existing test
huozhi a00aa67
fix export case
huozhi 16c580f
fix export case
huozhi 91b1a5b
fix rewrites-with-basepath.test.ts
huozhi d9a6745
fix build
huozhi a7a697b
condition
huozhi 1a86140
fix entries
huozhi c64dc6e
fix i18n and tests
huozhi 74db0c9
fix build error but export output still missing
huozhi 4e25698
update test
huozhi c8eb0c7
fix export and app only
huozhi 677eca2
fix tests
huozhi 8a2194d
tweak turbopack entry
huozhi 106e600
fix app paths in pages mapping
huozhi efd5943
fix entries
huozhi b4a395d
enhance entry cond and fix tests
huozhi 12863c8
reverts few changes and fix tests
huozhi bd70791
revert
huozhi 3af3e04
revert export cond
huozhi 55a35a3
fix app dir only flag
huozhi 280f932
remove bad _error pages from default export map
huozhi bbe8137
fix turbopack build global-error entry
huozhi a89725b
rm
huozhi 8912a29
fix 404 export
huozhi 8731ba4
skip rm not-found file
huozhi 9edcc8e
fix trailing slash false test
huozhi e920b68
revert orig check for i18n
huozhi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
static gen and add test
- Loading branch information
commit 1886aa7f568b958d08b2f992e23c3ea9f09bbd2b
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
'use client' | ||
|
||
const styles: Record<string, React.CSSProperties> = { | ||
error: { | ||
// https://github.com/sindresorhus/modern-normalize/blob/main/modern-normalize.css#L38-L52 | ||
fontFamily: | ||
'system-ui,"Segoe UI",Roboto,Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji"', | ||
height: '100vh', | ||
textAlign: 'center', | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
}, | ||
desc: { | ||
lineHeight: '48px', | ||
}, | ||
h1: { | ||
display: 'inline-block', | ||
margin: '0 20px 0 0', | ||
paddingRight: 23, | ||
fontSize: 24, | ||
fontWeight: 500, | ||
verticalAlign: 'top', | ||
}, | ||
h2: { | ||
fontSize: 14, | ||
fontWeight: 400, | ||
lineHeight: '28px', | ||
}, | ||
wrap: { | ||
display: 'inline-block', | ||
}, | ||
} | ||
|
||
function AppError() { | ||
// For static generation, error will be undefined | ||
// For runtime errors, error will contain the actual error | ||
const errorMessage = 'Internal Server Error.' | ||
const title = '500: Internal Server Error' | ||
|
||
return ( | ||
<html id="__next_error__"> | ||
<head> | ||
<title>{title}</title> | ||
</head> | ||
<body> | ||
<div style={styles.error}> | ||
<div style={styles.desc}> | ||
<style | ||
dangerouslySetInnerHTML={{ | ||
/* CSS minified from | ||
body { margin: 0; color: #000; background: #fff; } | ||
.next-error-h1 { | ||
border-right: 1px solid rgba(0, 0, 0, .3); | ||
} | ||
|
||
@media (prefers-color-scheme: dark) { | ||
body { color: #fff; background: #000; } | ||
.next-error-h1 { | ||
border-right: 1px solid rgba(255, 255, 255, .3); | ||
} | ||
} | ||
*/ | ||
__html: `body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}`, | ||
}} | ||
/> | ||
<h1 className="next-error-h1" style={styles.h1}> | ||
500 | ||
</h1> | ||
<div style={styles.wrap}> | ||
<h2 style={styles.h2}>{errorMessage}</h2> | ||
</div> | ||
</div> | ||
</div> | ||
</body> | ||
</html> | ||
) | ||
} | ||
|
||
export default AppError |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
test/production/500-page/app-router-only/app-router-only.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { nextTestSetup } from 'e2e-utils' | ||
import fsp from 'fs/promises' | ||
import path from 'path' | ||
|
||
describe('500-page app-router-only', () => { | ||
const { next, skipped } = nextTestSetup({ | ||
files: __dirname, | ||
skipDeployment: true, | ||
}) | ||
|
||
if (skipped) { | ||
return | ||
} | ||
|
||
it('should use app router to generate 500.html when no pages _error.tsx exists', async () => { | ||
const html = await fsp.readFile( | ||
path.join(next.testDir, '.next', 'server', 'pages', '500.html'), | ||
'utf8' | ||
) | ||
expect(html).toContain('app-router-global-error') | ||
}) | ||
}) |
11 changes: 11 additions & 0 deletions
11
test/production/500-page/app-router-only/app/global-error.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
'use client' | ||
|
||
export default function GlobalError() { | ||
return ( | ||
<html> | ||
<body> | ||
<h1>app-router-global-error</h1> | ||
</body> | ||
</html> | ||
) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export default function RootLayout({ | ||
children, | ||
}: { | ||
children: React.ReactNode | ||
}) { | ||
return ( | ||
<html lang="en"> | ||
<body>{children}</body> | ||
</html> | ||
) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function Page() { | ||
return <p>app page</p> | ||
} |
3 changes: 3 additions & 0 deletions
3
test/production/500-page/mixed-router-no-custom-pages-error/app/app-page/page.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function AppPage() { | ||
return <p>app page</p> | ||
} |
11 changes: 11 additions & 0 deletions
11
test/production/500-page/mixed-router-no-custom-pages-error/app/global-error.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
'use client' | ||
|
||
export default function GlobalError() { | ||
return ( | ||
<html> | ||
<body> | ||
<p>app-router-global-error</p> | ||
</body> | ||
</html> | ||
) | ||
} |
11 changes: 11 additions & 0 deletions
11
test/production/500-page/mixed-router-no-custom-pages-error/app/layout.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export default function RootLayout({ | ||
children, | ||
}: { | ||
children: React.ReactNode | ||
}) { | ||
return ( | ||
<html lang="en"> | ||
<body>{children}</body> | ||
</html> | ||
) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.