Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Prefetch SSG Data * Update packages/next/client/page-loader.js Co-Authored-By: JJ Kasper <jj@jjsweb.site> * Revert router.ts * Revert link.tsx * undo change * mimmic existing * simplify * Prefetch href and asPath * fix load * dedupe prefetchAs * Inject script tag on hover * comment prefetchAs * minify code * introduce lazy files * Add some breathing room * correct default type * Prefetch non-dynamic data * Prefetch dynamic route data * Fix size test * Humanize code * add tests * Disable code * Only generate modern version in modern mode * Extract function helper * add comments * Filter out dynamic route to simplify manifest size * add test Co-authored-by: JJ Kasper <jj@jjsweb.site>
- Loading branch information
Showing
13 changed files
with
443 additions
and
5 deletions.
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.