Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 73f473b

Browse files
feat: add suffix to rsc txt files for easy routing
* enables easy handling for cdns or proxies to identify rsc payloads and route them correctly beside other txt files
1 parent e590df4 commit 73f473b

File tree

9 files changed

+7004
-6939
lines changed

9 files changed

+7004
-6939
lines changed

packages/next/src/client/components/router-reducer/fetch-server-response.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,9 @@ export async function fetchServerResponse(
154154
// to the request.
155155
url = new URL(url)
156156
if (url.pathname.endsWith('/')) {
157-
url.pathname += 'index.txt'
157+
url.pathname += 'index.rsc.txt'
158158
} else {
159-
url.pathname += '.txt'
159+
url.pathname += '.rsc.txt'
160160
}
161161
}
162162
}

packages/next/src/client/route-params.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,11 @@ export function urlToUrlWithoutFlightMarker(url: URL): URL {
149149
if (process.env.NODE_ENV === 'production') {
150150
if (
151151
process.env.__NEXT_CONFIG_OUTPUT === 'export' &&
152-
urlWithoutFlightParameters.pathname.endsWith('.txt')
152+
urlWithoutFlightParameters.pathname.endsWith('.rsc.txt')
153153
) {
154154
const { pathname } = urlWithoutFlightParameters
155-
const length = pathname.endsWith('/index.txt') ? 10 : 4
156-
// Slice off `/index.txt` or `.txt` from the end of the pathname
155+
const length = pathname.endsWith('/index.rsc.txt') ? 14 : 8
156+
// Slice off `/index.rsc.txt` or `.rsc.txt` from the end of the pathname
157157
urlWithoutFlightParameters.pathname = pathname.slice(0, -length)
158158
}
159159
}

packages/next/src/export/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -821,7 +821,7 @@ async function exportAppImpl(
821821
outDir,
822822
`${route}${
823823
subFolders && route !== '/index' ? `${sep}index` : ''
824-
}.txt`
824+
}.rsc.txt`
825825
)
826826
: join(pagesDataDir, `${route}.json`)
827827

test/integration/app-dir-export/test/utils.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,20 @@ export const expectedWhenTrailingSlashTrue = [
4343
: []),
4444
'_next/static/test-build-id/_ssgManifest.js',
4545
'another/first/index.html',
46-
'another/first/index.txt',
46+
'another/first/index.rsc.txt',
4747
'another/index.html',
48-
'another/index.txt',
48+
'another/index.rsc.txt',
4949
'another/second/index.html',
50-
'another/second/index.txt',
50+
'another/second/index.rsc.txt',
5151
'api/json',
5252
'api/txt',
5353
'client/index.html',
54-
'client/index.txt',
54+
'client/index.rsc.txt',
5555
'favicon.ico',
5656
'image-import/index.html',
57-
'image-import/index.txt',
57+
'image-import/index.rsc.txt',
5858
'index.html',
59-
'index.txt',
59+
'index.rsc.txt',
6060
'robots.txt',
6161
]
6262

@@ -73,20 +73,20 @@ const expectedWhenTrailingSlashFalse = [
7373
: []),
7474
'_next/static/test-build-id/_ssgManifest.js',
7575
'another.html',
76-
'another.txt',
76+
'another.rsc.txt',
7777
'another/first.html',
78-
'another/first.txt',
78+
'another/first.rsc.txt',
7979
'another/second.html',
80-
'another/second.txt',
80+
'another/second.rsc.txt',
8181
'api/json',
8282
'api/txt',
8383
'client.html',
84-
'client.txt',
84+
'client.rsc.txt',
8585
'favicon.ico',
8686
'image-import.html',
87-
'image-import.txt',
87+
'image-import.rsc.txt',
8888
'index.html',
89-
'index.txt',
89+
'index.rsc.txt',
9090
'robots.txt',
9191
]
9292

test/integration/file-serving/test/index.test.js

Lines changed: 1826 additions & 1761 deletions
Large diffs are not rendered by default.

test/rspack-build-tests-manifest.json

Lines changed: 1290 additions & 1290 deletions
Large diffs are not rendered by default.

test/rspack-dev-tests-manifest.json

Lines changed: 1290 additions & 1290 deletions
Large diffs are not rendered by default.

test/turbopack-build-tests-manifest.json

Lines changed: 1290 additions & 1290 deletions
Large diffs are not rendered by default.

test/turbopack-dev-tests-manifest.json

Lines changed: 1290 additions & 1290 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)