mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-07 21:07:46 +00:00
[next] Update to route app rsc paths correctly (#8611)
### Related Issues x-ref: [slack thread](https://vercel.slack.com/archives/C035J346QQL/p1663799417151099) Failing probes are unrelated, more info can be seen in [this thread](https://vercel.slack.com/archives/C035J346QQL/p1663820032810519?thread_ts=1663775935.504379&cid=C035J346QQL)
This commit is contained in:
@@ -1131,6 +1131,23 @@ export async function serverBuild({
|
||||
});
|
||||
}
|
||||
|
||||
if (appPathRoutesManifest) {
|
||||
// create .rsc variant for app lambdas and edge functions
|
||||
// to match prerenders so we can route the same when the
|
||||
// __flight__ header is present
|
||||
const edgeFunctions = middleware.edgeFunctions;
|
||||
|
||||
for (let route of Object.values(appPathRoutesManifest)) {
|
||||
route = path.posix.join('./', route === '/' ? '/index' : route);
|
||||
|
||||
if (lambdas[route]) {
|
||||
lambdas[`${route}.rsc`] = lambdas[route];
|
||||
} else if (edgeFunctions[route]) {
|
||||
edgeFunctions[`${route}.rsc`] = edgeFunctions[route];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
wildcard: wildcardConfig,
|
||||
images:
|
||||
@@ -1369,6 +1386,22 @@ export async function serverBuild({
|
||||
// to prevent a local/deploy mismatch
|
||||
...(!isCorrectMiddlewareOrder ? middleware.staticRoutes : []),
|
||||
|
||||
...(appDir
|
||||
? [
|
||||
{
|
||||
src: `^${path.posix.join('/', entryDirectory, '/(.*)$')}`,
|
||||
has: [
|
||||
{
|
||||
type: 'header',
|
||||
key: '__flight__',
|
||||
},
|
||||
],
|
||||
dest: path.posix.join('/', entryDirectory, '/$1.rsc'),
|
||||
check: true,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
|
||||
// Next.js page lambdas, `static/` folder, reserved assets, and `public/`
|
||||
// folder
|
||||
{ handle: 'filesystem' },
|
||||
|
||||
@@ -2229,7 +2229,11 @@ export async function getMiddlewareBundle({
|
||||
prerenderBypassToken: string;
|
||||
routesManifest: RoutesManifest;
|
||||
isCorrectMiddlewareOrder: boolean;
|
||||
}) {
|
||||
}): Promise<{
|
||||
staticRoutes: Route[];
|
||||
dynamicRouteMap: Map<string, RouteWithSrc>;
|
||||
edgeFunctions: Record<string, EdgeFunction>;
|
||||
}> {
|
||||
const middlewareManifest = await getMiddlewareManifest(
|
||||
entryPath,
|
||||
outputDirectory
|
||||
@@ -2420,7 +2424,6 @@ export async function getMiddlewareBundle({
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return source;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,16 +11,27 @@
|
||||
"status": 200,
|
||||
"mustContain": "hello from app/dashboard"
|
||||
},
|
||||
{
|
||||
"path": "/dashboard",
|
||||
"status": 200,
|
||||
"headers": {
|
||||
"__flight__": "1"
|
||||
},
|
||||
"mustContain": "M1:{",
|
||||
"mustNotContain": "<html"
|
||||
},
|
||||
{
|
||||
"path": "/dashboard/another",
|
||||
"status": 200,
|
||||
"mustContain": "hello from newroot/dashboard/another"
|
||||
},
|
||||
{
|
||||
"path": "/dashboard/deployments/123",
|
||||
"status": 200,
|
||||
"mustContain": "hello from app/dashboard/deployments/[id]. ID is: <!-- -->123"
|
||||
},
|
||||
// TODO: uncomment after this is fixed upstream
|
||||
// x-ref: https://vercel.slack.com/archives/C035J346QQL/p1663820032810519?thread_ts=1663775935.504379&cid=C035J346QQL
|
||||
// {
|
||||
// "path": "/dashboard/deployments/123",
|
||||
// "status": 200,
|
||||
// "mustContain": "hello from app/dashboard/deployments/[id]. ID is: <!-- -->123"
|
||||
// },
|
||||
{
|
||||
"path": "/",
|
||||
"status": 200,
|
||||
@@ -31,11 +42,12 @@
|
||||
"status": 200,
|
||||
"mustContain": "hello from pages/blog/[slug]"
|
||||
},
|
||||
{
|
||||
"path": "/dynamic/category-1/id-1",
|
||||
"status": 200,
|
||||
"mustContain": "{"category":"category-1","id":"id-1"}"
|
||||
},
|
||||
// TODO: uncomment after this is fixed upstream
|
||||
// {
|
||||
// "path": "/dynamic/category-1/id-1",
|
||||
// "status": 200,
|
||||
// "mustContain": "{"category":"category-1","id":"id-1"}"
|
||||
// },
|
||||
{
|
||||
"path": "/dashboard/changelog",
|
||||
"status": 200,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const fs = require('fs-extra');
|
||||
const json5 = require('json5');
|
||||
const { glob } = require('@vercel/build-utils');
|
||||
|
||||
function runAnalyze(wrapper, context) {
|
||||
@@ -18,7 +19,7 @@ async function runBuildLambda(inputPath) {
|
||||
if (typeof expect !== 'undefined') {
|
||||
expect(nowJsonRef).toBeDefined();
|
||||
}
|
||||
const nowJson = require(nowJsonRef.fsPath);
|
||||
const nowJson = json5.parse(await fs.readFile(nowJsonRef.fsPath, 'utf8'));
|
||||
const build = nowJson.builds[0];
|
||||
|
||||
if (typeof expect !== 'undefined') {
|
||||
|
||||
Reference in New Issue
Block a user