[remix] Don't create output for Pathless Layout Routes without any child routes at the root level (#9539)

Fixes https://github.com/vercel/community/discussions/1587.
This commit is contained in:
Nathan Rajlich
2023-02-24 17:17:01 -08:00
committed by GitHub
parent 48eed7532a
commit 3a65acfb32
6 changed files with 59 additions and 8 deletions

View File

@@ -237,6 +237,12 @@ module.exports = config;`;
const path = getPathFromRoute(route, remixConfig.routes);
// If the route is a pathless layout route (at the root level)
// and doesn't have any sub-routes, then a function should not be created.
if (!path) {
continue;
}
let isEdge = false;
for (const currentRoute of getRouteIterator(route, remixConfig.routes)) {
const staticConfig = staticConfigsMap.get(currentRoute);

View File

@@ -41,9 +41,12 @@ export function getPathFromRoute(
route: ConfigRoute,
routes: RouteManifest
): string {
if (route.id === 'root' || (route.parentId === 'root' && route.index)) {
return 'index';
}
const pathParts: string[] = [];
for (const currentRoute of getRouteIterator(route, routes)) {
if (currentRoute.index) pathParts.push('index');
if (currentRoute.path) pathParts.push(currentRoute.path);
}
const path = pathParts.reverse().join('/');