mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-09 04:22:07 +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 {
|
return {
|
||||||
wildcard: wildcardConfig,
|
wildcard: wildcardConfig,
|
||||||
images:
|
images:
|
||||||
@@ -1369,6 +1386,22 @@ export async function serverBuild({
|
|||||||
// to prevent a local/deploy mismatch
|
// to prevent a local/deploy mismatch
|
||||||
...(!isCorrectMiddlewareOrder ? middleware.staticRoutes : []),
|
...(!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/`
|
// Next.js page lambdas, `static/` folder, reserved assets, and `public/`
|
||||||
// folder
|
// folder
|
||||||
{ handle: 'filesystem' },
|
{ handle: 'filesystem' },
|
||||||
|
|||||||
@@ -2229,7 +2229,11 @@ export async function getMiddlewareBundle({
|
|||||||
prerenderBypassToken: string;
|
prerenderBypassToken: string;
|
||||||
routesManifest: RoutesManifest;
|
routesManifest: RoutesManifest;
|
||||||
isCorrectMiddlewareOrder: boolean;
|
isCorrectMiddlewareOrder: boolean;
|
||||||
}) {
|
}): Promise<{
|
||||||
|
staticRoutes: Route[];
|
||||||
|
dynamicRouteMap: Map<string, RouteWithSrc>;
|
||||||
|
edgeFunctions: Record<string, EdgeFunction>;
|
||||||
|
}> {
|
||||||
const middlewareManifest = await getMiddlewareManifest(
|
const middlewareManifest = await getMiddlewareManifest(
|
||||||
entryPath,
|
entryPath,
|
||||||
outputDirectory
|
outputDirectory
|
||||||
@@ -2420,7 +2424,6 @@ export async function getMiddlewareBundle({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,16 +11,27 @@
|
|||||||
"status": 200,
|
"status": 200,
|
||||||
"mustContain": "hello from app/dashboard"
|
"mustContain": "hello from app/dashboard"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"path": "/dashboard",
|
||||||
|
"status": 200,
|
||||||
|
"headers": {
|
||||||
|
"__flight__": "1"
|
||||||
|
},
|
||||||
|
"mustContain": "M1:{",
|
||||||
|
"mustNotContain": "<html"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"path": "/dashboard/another",
|
"path": "/dashboard/another",
|
||||||
"status": 200,
|
"status": 200,
|
||||||
"mustContain": "hello from newroot/dashboard/another"
|
"mustContain": "hello from newroot/dashboard/another"
|
||||||
},
|
},
|
||||||
{
|
// TODO: uncomment after this is fixed upstream
|
||||||
"path": "/dashboard/deployments/123",
|
// x-ref: https://vercel.slack.com/archives/C035J346QQL/p1663820032810519?thread_ts=1663775935.504379&cid=C035J346QQL
|
||||||
"status": 200,
|
// {
|
||||||
"mustContain": "hello from app/dashboard/deployments/[id]. ID is: <!-- -->123"
|
// "path": "/dashboard/deployments/123",
|
||||||
},
|
// "status": 200,
|
||||||
|
// "mustContain": "hello from app/dashboard/deployments/[id]. ID is: <!-- -->123"
|
||||||
|
// },
|
||||||
{
|
{
|
||||||
"path": "/",
|
"path": "/",
|
||||||
"status": 200,
|
"status": 200,
|
||||||
@@ -31,11 +42,12 @@
|
|||||||
"status": 200,
|
"status": 200,
|
||||||
"mustContain": "hello from pages/blog/[slug]"
|
"mustContain": "hello from pages/blog/[slug]"
|
||||||
},
|
},
|
||||||
{
|
// TODO: uncomment after this is fixed upstream
|
||||||
"path": "/dynamic/category-1/id-1",
|
// {
|
||||||
"status": 200,
|
// "path": "/dynamic/category-1/id-1",
|
||||||
"mustContain": "{"category":"category-1","id":"id-1"}"
|
// "status": 200,
|
||||||
},
|
// "mustContain": "{"category":"category-1","id":"id-1"}"
|
||||||
|
// },
|
||||||
{
|
{
|
||||||
"path": "/dashboard/changelog",
|
"path": "/dashboard/changelog",
|
||||||
"status": 200,
|
"status": 200,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
const os = require('os');
|
const os = require('os');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
|
const json5 = require('json5');
|
||||||
const { glob } = require('@vercel/build-utils');
|
const { glob } = require('@vercel/build-utils');
|
||||||
|
|
||||||
function runAnalyze(wrapper, context) {
|
function runAnalyze(wrapper, context) {
|
||||||
@@ -18,7 +19,7 @@ async function runBuildLambda(inputPath) {
|
|||||||
if (typeof expect !== 'undefined') {
|
if (typeof expect !== 'undefined') {
|
||||||
expect(nowJsonRef).toBeDefined();
|
expect(nowJsonRef).toBeDefined();
|
||||||
}
|
}
|
||||||
const nowJson = require(nowJsonRef.fsPath);
|
const nowJson = json5.parse(await fs.readFile(nowJsonRef.fsPath, 'utf8'));
|
||||||
const build = nowJson.builds[0];
|
const build = nowJson.builds[0];
|
||||||
|
|
||||||
if (typeof expect !== 'undefined') {
|
if (typeof expect !== 'undefined') {
|
||||||
|
|||||||
Reference in New Issue
Block a user