-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Prefetch SSG Data #10127
Merged
Merged
Prefetch SSG Data #10127
Changes from 46 commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
190a914
Prefetch SSG Data
Timer d22efaa
Update packages/next/client/page-loader.js
Timer 630f516
Merge branch 'canary' into enhancement/prefetch-ssg-data
Timer 8c1fcef
Merge branch 'canary' into enhancement/prefetch-ssg-data
Timer eee688c
Revert router.ts
Timer 555b097
Revert link.tsx
Timer 1490cd2
undo change
Timer 5ddf762
Merge branch 'enhancement/prefetch-ssg-data' of github.com:Timer/next…
Timer 98852c4
mimmic existing
Timer ed7bfc1
simplify
Timer 098391f
Prefetch href and asPath
Timer 2643285
fix load
Timer 6a25c93
dedupe prefetchAs
Timer 825ee1a
Inject script tag on hover
Timer 928717c
Merge branch 'canary' into enhancement/prefetch-ssg-data
Timer ce085a5
comment prefetchAs
Timer 74ff44c
minify code
Timer b4585d9
introduce lazy files
Timer 80621c6
Merge branch 'canary' into enhancement/prefetch-ssg-data
Timer 612dfb6
Add some breathing room
Timer ec5ce44
correct default type
Timer 0595464
Prefetch non-dynamic data
Timer 6e623d8
Prefetch dynamic route data
Timer 00109cb
Fix size test
Timer c39219d
Humanize code
Timer ff7486c
Merge branch 'canary' into enhancement/prefetch-ssg-data
Timer e27d49d
add tests
Timer 3915ace
Merge branch 'canary' into enhancement/prefetch-ssg-data
Timer 24ae003
Merge branch 'canary' into enhancement/prefetch-ssg-data
Timer 103a2ca
Merge branch 'canary' into enhancement/prefetch-ssg-data
Timer c9e6123
Merge branch 'canary' into enhancement/prefetch-ssg-data
Timer b082c6d
Merge branch 'canary' into enhancement/prefetch-ssg-data
Timer 2293750
Merge branch 'canary' into enhancement/prefetch-ssg-data
Timer e4a12ab
Merge branch 'canary' into enhancement/prefetch-ssg-data
Timer 363928b
Disable code
Timer 1c15762
Only generate modern version in modern mode
Timer 0a23d7c
Merge branch 'canary' into enhancement/prefetch-ssg-data
Timer c0772ce
Merge branch 'canary' into enhancement/prefetch-ssg-data
Timer fffeb50
Merge branch 'canary' into enhancement/prefetch-ssg-data
Timer 17fb3e4
Extract function helper
Timer e799bf3
add comments
Timer 3b55b4f
Merge branch 'canary' into enhancement/prefetch-ssg-data
Timer 2ba0b8a
Merge branch 'canary' into enhancement/prefetch-ssg-data
Timer 936bb98
Merge branch 'canary' into enhancement/prefetch-ssg-data
Timer 939e8be
Merge branch 'canary' into enhancement/prefetch-ssg-data
Timer bd3f208
Merge branch 'canary' into enhancement/prefetch-ssg-data
Timer c85a3d9
Filter out dynamic route to simplify manifest size
Timer 6ead1b4
add test
Timer 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
There are no files selected for viewing
This file contains 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 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 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 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 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,5 @@ | ||
module.exports = { | ||
generateBuildId() { | ||
return 'test-build' | ||
}, | ||
} |
This file contains 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,5 @@ | ||
export function getStaticProps() { | ||
return { props: { message: 'hello world' } } | ||
} | ||
|
||
export default ({ message }) => <p id="content">{message}</p> |
12 changes: 12 additions & 0 deletions
12
test/integration/preload-viewport/pages/ssg/catch-all/[...slug].js
This file contains 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,12 @@ | ||
export function getStaticProps({ params }) { | ||
return { props: { message: `hello ${params.slug.join(' ')}` } } | ||
} | ||
|
||
export function getStaticPaths() { | ||
return { | ||
paths: ['/ssg/catch-all/one', '/ssg/catch-all/one/two'], | ||
fallback: true, | ||
} | ||
} | ||
|
||
export default ({ message }) => <p id="content">{message || 'loading'}</p> |
12 changes: 12 additions & 0 deletions
12
test/integration/preload-viewport/pages/ssg/dynamic-nested/[slug1]/[slug2].js
This file contains 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,12 @@ | ||
export function getStaticProps({ params }) { | ||
return { props: { message: `hello ${params.slug1} ${params.slug2}` } } | ||
} | ||
|
||
export function getStaticPaths() { | ||
return { | ||
paths: ['/ssg/dynamic-nested/one/two'], | ||
fallback: true, | ||
} | ||
} | ||
|
||
export default ({ message }) => <p id="content">{message || 'loading'}</p> |
9 changes: 9 additions & 0 deletions
9
test/integration/preload-viewport/pages/ssg/dynamic/[slug].js
This file contains 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,9 @@ | ||
export function getStaticProps({ params }) { | ||
return { props: { message: `hello ${params.slug}` } } | ||
} | ||
|
||
export function getStaticPaths() { | ||
return { paths: ['/ssg/dynamic/one'], fallback: true } | ||
} | ||
|
||
export default ({ message }) => <p id="content">{message || 'loading'}</p> |
65 changes: 65 additions & 0 deletions
65
test/integration/preload-viewport/pages/ssg/fixture/index.js
This file contains 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,65 @@ | ||
import Link from 'next/link' | ||
|
||
export default () => ( | ||
<main> | ||
<h1>SSG Data Prefetch Fixtures</h1> | ||
<p> | ||
<Link href="/ssg/basic"> | ||
<a>Non-dynamic route</a> | ||
</Link> | ||
: this is a normal Next.js page that does not use dynamic routing. | ||
</p> | ||
<p> | ||
<Link href="/ssg/dynamic/[slug]" as="/ssg/dynamic/one"> | ||
<a>Dynamic Route (one level) — Prerendered</a> | ||
</Link> | ||
: this is a Dynamic Page with a single dynamic segment that{' '} | ||
<strong>was returned</strong> from <code>getStaticPaths</code>.<br /> | ||
<Link href="/ssg/dynamic/[slug]" as="/ssg/dynamic/two"> | ||
<a>Dynamic Route (one level) — Not Prerendered</a> | ||
</Link> | ||
: this is a Dynamic Page with a single dynamic segment that{' '} | ||
<strong>was not returned</strong> from <code>getStaticPaths</code>. | ||
</p> | ||
<p> | ||
<Link | ||
href="/ssg/dynamic-nested/[slug1]/[slug2]" | ||
as="/ssg/dynamic-nested/one/two" | ||
> | ||
<a>Multi Dynamic Route (two levels) — Prerendered</a> | ||
</Link> | ||
: this is a Dynamic Page with two dynamic segments that{' '} | ||
<strong>were returned</strong> from <code>getStaticPaths</code>.<br /> | ||
<Link | ||
href="/ssg/dynamic-nested/[slug1]/[slug2]" | ||
as="/ssg/dynamic-nested/foo/bar" | ||
> | ||
<a>Multi Dynamic Route (two levels) — Not Prerendered</a> | ||
</Link> | ||
: this is a Dynamic Page with two dynamic segments that{' '} | ||
<strong>were not returned</strong> from <code>getStaticPaths</code>. | ||
</p> | ||
<p> | ||
<Link href="/ssg/catch-all/[...slug]" as="/ssg/catch-all/one"> | ||
<a>Catch-All Route (one level) — Prerendered</a> | ||
</Link> | ||
: this is a Catch-All Page with one segment that{' '} | ||
<strong>was returned</strong> from <code>getStaticPaths</code>.<br /> | ||
<Link href="/ssg/catch-all/[...slug]" as="/ssg/catch-all/foo"> | ||
<a>Catch-All Route (one level) — Not Prerendered</a> | ||
</Link> | ||
: this is a Catch-All Page with one segment that{' '} | ||
<strong>was not returned</strong> from <code>getStaticPaths</code>.<br /> | ||
<Link href="/ssg/catch-all/[...slug]" as="/ssg/catch-all/one/two"> | ||
<a>Catch-All Route (two levels) — Prerendered</a> | ||
</Link> | ||
: this is a Catch-All Page with two segments that{' '} | ||
<strong>were returned</strong> from <code>getStaticPaths</code>.<br /> | ||
<Link href="/ssg/catch-all/[...slug]" as="/ssg/catch-all/foo/bar"> | ||
<a>Catch-All Route (two levels) — Not Prerendered</a> | ||
</Link> | ||
: this is a Catch-All Page with two segments that{' '} | ||
<strong>were not returned</strong> from <code>getStaticPaths</code>. | ||
</p> | ||
</main> | ||
) |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't this be part of the buildManifest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I intentionally separated them so we didn’t unnecessarily increase the size of either file (since the build manifest blocks navigation).
Also, their generation is different. The build manifest can be computed at build time but the SSG manifest must be post build after we require all the pages in
jest-worker
.