Skip to content

Commit a7fe3ba

Browse files
committed
feat: introduce dynamicIO
1 parent eb2e08c commit a7fe3ba

File tree

121 files changed

+349
-166
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+349
-166
lines changed

next.config.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import type { NextConfig } from 'next';
1+
import type { NextConfig } from "next";
22

33
const nextConfig: NextConfig = {
44
// logging: {
55
// fetches: {
66
// fullUrl: true,
77
// },
88
// },
9-
transpilePackages: ["shiki"],
109
experimental: {
10+
dynamicIO: true,
1111
taint: true,
1212
// typedRoutes: true,
1313
},

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"@shikijs/transformers": "^1.22.2",
2020
"algoliasearch": "^4.24.0",
2121
"instantsearch.js": "^4.75.3",
22-
"next": "15.0.1",
22+
"next": "canary",
2323
"react": "^18.3.1",
2424
"react-dom": "^18.3.1",
2525
"react-instantsearch": "^7.13.6",

pnpm-lock.yaml

+49-49
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/service-worker.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ self.addEventListener("fetch", (e) => {
1111
e.respondWith(
1212
(async () => {
1313
const res = await fetch(e.request);
14-
const createdAt = Date.now();
14+
const createdAt = performance.now();
1515

1616
// res.text() fails is when trying to read the same response stream twice.
1717
const clone = res.clone();

src/app/api/now/route.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import { NextResponse } from "next/server";
22

3-
export const revalidate = 0;
4-
53
export async function GET() {
64
return NextResponse.json({
7-
now: Date.now(),
5+
now: performance.now(),
86
});
97
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export async function getNow(id?: string) {
2-
return Date.now();
2+
return performance.now();
33
}

src/app/examples/(caching)/full-route-cache/dynamic/page.tsx src/app/examples/(caching)/_full-route-cache/dynamic/page.tsx

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1+
"use cache";
2+
13
// [!code word:force-dynamic]
24
import { Boundary } from "@/app/_components/boundary";
35
import { Suspense } from "react";
46

5-
export const dynamic = "force-dynamic";
6-
// or
7-
// export const revalidate = 0;
8-
9-
export default function Page() {
7+
export default async function Page() {
108
return (
119
<div className="flex gap-4">
1210
<Suspense fallback={<Loading />}>

src/app/examples/(caching)/full-route-cache/page.tsx src/app/examples/(caching)/_full-route-cache/page.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
"use cache";
2+
13
import { Boundary } from "@/app/_components/boundary";
24
import { Link } from "@/app/_components/link";
35
import type { PropsWithChildren } from "react";
46

5-
export default function Page() {
7+
export default async function Page() {
68
return (
79
<Boundary label="Page">
810
<div className="flex flex-col gap-2">
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// [!code word:revalidate]
2+
import { Boundary } from "@/app/_components/boundary";
3+
4+
export default async function Page() {
5+
"use cache";
6+
7+
return <Boundary label="Page">{performance.now()}</Boundary>;
8+
}

src/app/examples/(caching)/full-route-cache/static/page.tsx src/app/examples/(caching)/_full-route-cache/static/page.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
"use cache";
2+
13
import { Boundary } from "@/app/_components/boundary";
24
import { Suspense } from "react";
35

4-
export default function Page() {
6+
export default async function Page() {
57
return (
68
<div className="flex gap-4 w-full">
79
<Suspense fallback={<Loading />}>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// [!code word:use cache]
2+
3+
export default async function Page() {
4+
return (
5+
<div className="space-y-4">
6+
<NoCached />
7+
<Cached />
8+
</div>
9+
);
10+
}
11+
12+
async function NoCached() {
13+
return <p>no cached: {performance.now()}</p>;
14+
}
15+
16+
async function Cached() {
17+
"use cache";
18+
19+
return <p>cached: {performance.now()}</p>;
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// [!code word:use cache]
2+
3+
"use cache";
4+
5+
export default async function Page() {
6+
return (
7+
<div>
8+
<p>{performance.now()}</p>
9+
<Child />
10+
</div>
11+
);
12+
}
13+
14+
function Child() {
15+
return <p>{performance.now()}</p>;
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// [!code word:use cache]
2+
3+
export default async function Page() {
4+
return (
5+
<div>
6+
<p>no cached: {performance.now()}</p>
7+
<p>cached: {getNow()}</p>
8+
</div>
9+
);
10+
}
11+
12+
async function getNow() {
13+
"use cache";
14+
15+
return performance.now();
16+
}

0 commit comments

Comments
 (0)