Repository: dai-shi/waku
Pull request #1090 (2024-12-25 05:09:47)

refactor: define-router
remove `pattern`

vercel[bot]: [vc]: #VTAhik8MUKG9DfF7eiegpIfq9FvsIqdjbJfidMptj2Q=:eyJpc01vbm9yZXBvIjp0cnVlLCJ0eXBlIjoiZ2l0aHViIiwicHJvamVjdHMiOlt7Im5hbWUiOiJ3YWt1IiwiaW5zcGVjdG9yVXJsIjoiaHR0cHM6Ly92ZXJjZWwuY29tL2RhaXNoaXMtcHJvamVjdHMvd2FrdS8yVHZxejFmVkd2NDRhYkhoZHVZYkdSbmVQdW4yIiwicHJldmlld1VybCI6Indha3UtZ2l0LXJlZmFjdG9yLWRlZmluZS1yb3V0ZXItZGFpc2hpcy1wcm9qZWN0cy52ZXJjZWwuYXBwIiwibmV4dENvbW1pdFN0YXR1cyI6IlBFTkRJTkcifV19
**The latest updates on your projects**. Learn more about [Vercel for Git ↗︎](https://vercel.link/github-learn-more)

| Name | Status | Preview | Updated (UTC) |
| :--- | :----- | :------ | :------ |
| **waku** | 🔄 Building ([Inspect](https://vercel.com/daishis-projects/waku/2Tvqz1fVGv44abHhduYbGRnePun2)) | [Visit Preview](https://waku-git-refactor-define-router-daishis-projects.vercel.app) | Dec 25, 2024 5:09am |


codesandbox-ci[bot]: This pull request is automatically built and testable in [CodeSandbox](https://codesandbox.io).

  To see build info of the built libraries, click [here](https://ci.codesandbox.io/status/dai-shi/waku/pr/1090/builds/573633) or the icon next to each commit SHA.

Patch:
diff --git a/packages/waku/src/router/create-pages.ts b/packages/waku/src/router/create-pages.ts
index 41898445..2b4eb542 100644
--- a/packages/waku/src/router/create-pages.ts
+++ b/packages/waku/src/router/create-pages.ts
@@ -7,7 +7,6 @@ import {
   joinPath,
   parsePathWithSlug,
   getPathMapping,
-  path2regexp,
   pathSpecAsString,
 } from '../lib/utils/path.js';
 import type { PathSpec } from '../lib/utils/path.js';
@@ -226,7 +225,7 @@ export const createPages = <
       ...wildcardPagePathMap.keys(),
     ];
     for (const p of allPaths) {
-      if (new RegExp(path2regexp(parsePathWithSlug(p))).test(path)) {
+      if (getPathMapping(parsePathWithSlug(p), path)) {
         return p;
       }
     }
@@ -398,8 +397,8 @@ export const createPages = <
     getPathConfig: async () => {
       await configure();
       const paths: {
-        pattern: string;
         path: PathSpec;
+        pathPattern?: PathSpec;
         routeElement: { isStatic?: boolean };
         elements: Record<string, { isStatic?: boolean }>;
         noSsr: boolean;
@@ -409,10 +408,6 @@ export const createPages = <
       for (const [path, { literalSpec, originalSpec }] of staticPathMap) {
         const noSsr = noSsrSet.has(literalSpec);
 
-        const pattern = originalSpec
-          ? path2regexp(originalSpec)
-          : path2regexp(literalSpec);
-
         const layoutPaths = getLayouts(originalSpec ?? literalSpec);
 
         const elements = {
@@ -430,8 +425,8 @@ export const createPages = <
         };
 
         paths.push({
-          pattern,
           path: literalSpec,
+          ...(originalSpec && { pathPattern: originalSpec }),
           routeElement: {
             isStatic: true,
           },
@@ -441,7 +436,6 @@ export const createPages = <
       }
       for (const [path, [pathSpec]] of dynamicPagePathMap) {
         const noSsr = noSsrSet.has(pathSpec);
-        const pattern = path2regexp(parsePathWithSlug(path));
         const layoutPaths = getLayouts(pathSpec);
         const elements = {
           ...layoutPaths.reduce<Record<string, { isStatic: boolean }>>(
@@ -457,7 +451,6 @@ export const createPages = <
           [`page:${path}`]: { isStatic: false },
         };
         paths.push({
-          pattern,
           path: pathSpec,
           routeElement: { isStatic: true },
           elements,
@@ -481,7 +474,6 @@ export const createPages = <
           [`page:${path}`]: { isStatic: false },
         };
         paths.push({
-          pattern: path2regexp(parsePathWithSlug(path)),
           path: pathSpec,
           routeElement: { isStatic: true },
           elements,
diff --git a/packages/waku/src/router/define-router.ts b/packages/waku/src/router/define-router.ts
index a9447f68..e1995741 100644
--- a/packages/waku/src/router/define-router.ts
+++ b/packages/waku/src/router/define-router.ts
@@ -11,7 +11,7 @@ import {
   HAS404_ID,
   SKIP_HEADER,
 } from './common.js';
-import { getPathMapping } from '../lib/utils/path.js';
+import { getPathMapping, path2regexp } from '../lib/utils/path.js';
 import type { PathSpec } from '../lib/utils/path.js';
 import { ServerRouter } from './client.js';
 import { getContext } from '../middleware/context.js';
@@ -64,8 +64,8 @@ const ROUTE_SLOT_ID_PREFIX = 'route:';
 export function unstable_defineRouter(fns: {
   getPathConfig: () => Promise<
     Iterable<{
-      pattern: string; // TODO we should probably remove this and use path2regexp internally
       path: PathSpec;
+      pathPattern?: PathSpec;
       routeElement: { isStatic?: boolean };
       elements: Record<SlotId, { isStatic?: boolean }>;
       noSsr?: boolean;
@@ -84,8 +84,8 @@ export function unstable_defineRouter(fns: {
 }) {
   const platformObject = unstable_getPlatformObject();
   type MyPathConfig = {
+    pathSpec: PathSpec;
     pattern: string;
-    pathname: PathSpec;
     staticElementIds: SlotId[];
     isStatic?: boolean | undefined;
     specs: { noSsr?: boolean; is404: boolean };
@@ -103,8 +103,8 @@ export function unstable_defineRouter(fns: {
           item.path[0]!.type === 'literal' &&
           item.path[0]!.name === '404';
         return {
-          pattern: item.pattern,
-          pathname: item.path,
+          pathSpec: item.path,
+          pattern: path2regexp(item.pathPattern || item.path),
           staticElementIds: Object.entries(item.elements).flatMap(
             ([id, { isStatic }]) => (isStatic ? [id] : []),
           ),
@@ -134,7 +134,7 @@ export function unstable_defineRouter(fns: {
     }
   > => {
     const pathConfig = await getMyPathConfig();
-    const found = pathConfig.find(({ pathname: pathSpec }) =>
+    const found = pathConfig.find(({ pathSpec }) =>
       getPathMapping(pathSpec, pathname),
     );
     const has404 = pathConfig.some(({ specs: { is404 } }) => is404);
@@ -156,7 +156,7 @@ export function unstable_defineRouter(fns: {
   ): Promise<string[]> => {
     const pathConfig = await getMyPathConfig();
     return skip.filter((slotId) => {
-      const found = pathConfig.find(({ pathname: pathSpec }) =>
+      const found = pathConfig.find(({ pathSpec }) =>
         getPathMapping(pathSpec, pathname),
       );
       return !!found && found.staticElementIds.includes(slotId);
@@ -217,7 +217,7 @@ export function unstable_defineRouter(fns: {
     const path2moduleIds: Record<string, string[]> = {};
 
     await Promise.all(
-      pathConfig.map(async ({ pathname: pathSpec, pattern }) => {
+      pathConfig.map(async ({ pathSpec, pattern }) => {
         if (pathSpec.some(({ type }) => type !== 'literal')) {
           return;
         }
@@ -243,7 +243,7 @@ globalThis.__WAKU_ROUTER_PREFETCH__ = (path) => {
 };`;
     type BuildConfig = Awaited<ReturnType<GetBuildConfig>>;
     const buildConfig: BuildConfig = [];
-    for (const { pathname: pathSpec, isStatic, specs } of pathConfig) {
+    for (const { pathSpec, isStatic, specs } of pathConfig) {
       const entries: BuildConfig[number]['entries'] = [];
       if (pathSpec.every(({ type }) => type === 'literal')) {
         const pathname = '/' + pathSpec.map(({ name }) => name).join('/');
@@ -251,7 +251,7 @@ globalThis.__WAKU_ROUTER_PREFETCH__ = (path) => {
         entries.push({ rscPath, isStatic });
       }
       buildConfig.push({
-        pathSpec: pathSpec,
+        pathSpec,
         isStatic,
         entries,
         customCode:


Test patch:
diff --git a/packages/waku/tests/create-pages.test.ts b/packages/waku/tests/create-pages.test.ts
index c8c45595..b1f52978 100644
--- a/packages/waku/tests/create-pages.test.ts
+++ b/packages/waku/tests/create-pages.test.ts
@@ -440,13 +440,7 @@ describe('createPages', () => {
         },
         routeElement: { isStatic: true },
         noSsr: false,
-        path: [
-          {
-            name: 'test',
-            type: 'literal',
-          },
-        ],
-        pattern: '^/test$',
+        path: [{ name: 'test', type: 'literal' }],
       },
     ]);
 
@@ -476,13 +470,7 @@ describe('createPages', () => {
         },
         routeElement: { isStatic: true },
         noSsr: false,
-        path: [
-          {
-            name: 'test',
-            type: 'literal',
-          },
-        ],
-        pattern: '^/test$',
+        path: [{ name: 'test', type: 'literal' }],
       },
     ]);
     const route = await renderRoute('/test', {
@@ -519,13 +507,7 @@ describe('createPages', () => {
         },
         routeElement: { isStatic: true },
         noSsr: false,
-        path: [
-          {
-            name: 'test',
-            type: 'literal',
-          },
-        ],
-        pattern: '^/test$',
+        path: [{ name: 'test', type: 'literal' }],
       },
     ]);
     const route = await renderRoute('/test', {
@@ -566,13 +548,7 @@ describe('createPages', () => {
         },
         routeElement: { isStatic: true },
         noSsr: false,
-        path: [
-          {
-            name: 'test',
-            type: 'literal',
-          },
-        ],
-        pattern: '^/test$',
+        path: [{ name: 'test', type: 'literal' }],
       },
     ]);
 
@@ -607,16 +583,9 @@ describe('createPages', () => {
         routeElement: { isStatic: true },
         noSsr: false,
         path: [
-          {
-            name: 'test',
-            type: 'literal',
-          },
-          {
-            name: 'nested',
-            type: 'literal',
-          },
+          { name: 'test', type: 'literal' },
+          { name: 'nested', type: 'literal' },
         ],
-        pattern: '^/test/nested$',
       },
     ]);
     const route = await renderRoute('/test/nested', {
@@ -652,16 +621,9 @@ describe('createPages', () => {
         routeElement: { isStatic: true },
         noSsr: false,
         path: [
-          {
-            name: 'test',
-            type: 'literal',
-          },
-          {
-            name: 'nested',
-            type: 'literal',
-          },
+          { name: 'test', type: 'literal' },
+          { name: 'nested', type: 'literal' },
         ],
-        pattern: '^/test/nested$',
       },
     ]);
     const route = await renderRoute('/test/nested', {
@@ -695,16 +657,9 @@ describe('createPages', () => {
         routeElement: { isStatic: true },
         noSsr: false,
         path: [
-          {
-            name: 'test',
-            type: 'literal',
-          },
-          {
-            name: 'nested',
-            type: 'literal',
-          },
+          { name: 'test', type: 'literal' },
+          { name: 'nested', type: 'literal' },
         ],
-        pattern: '^/test/nested$',
       },
     ]);
 
@@ -739,20 +694,15 @@ describe('createPages', () => {
         routeElement: { isStatic: true },
         noSsr: false,
         path: [
-          {
-            name: 'test',
-            type: 'literal',
-          },
-          {
-            name: 'w',
-            type: 'literal',
-          },
-          {
-            name: 'x',
-            type: 'literal',
-          },
+          { name: 'test', type: 'literal' },
+          { name: 'w', type: 'literal' },
+          { name: 'x', type: 'literal' },
+        ],
+        pathPattern: [
+          { name: 'test', type: 'literal' },
+          { name: 'a', type: 'group' },
+          { name: 'b', type: 'group' },
         ],
-        pattern: '^/test/([^/]+)/([^/]+)$',
       },
       {
         elements: {
@@ -762,20 +712,15 @@ describe('createPages', () => {
         routeElement: { isStatic: true },
         noSsr: false,
         path: [
-          {
-            name: 'test',
-            type: 'literal',
-          },
-          {
-            name: 'y',
-            type: 'literal',
-          },
-          {
-            name: 'z',
-            type: 'literal',
-          },
+          { name: 'test', type: 'literal' },
+          { name: 'y', type: 'literal' },
+          { name: 'z', type: 'literal' },
+        ],
+        pathPattern: [
+          { name: 'test', type: 'literal' },
+          { name: 'a', type: 'group' },
+          { name: 'b', type: 'group' },
         ],
-        pattern: '^/test/([^/]+)/([^/]+)$',
       },
     ]);
     const route = await renderRoute('/test/y/z', {
@@ -805,20 +750,10 @@ describe('createPages', () => {
         routeElement: { isStatic: true },
         noSsr: false,
         path: [
-          {
-            name: 'test',
-            type: 'literal',
-          },
-          {
-            name: 'a',
-            type: 'group',
-          },
-          {
-            name: 'b',
-            type: 'group',
-          },
+          { name: 'test', type: 'literal' },
+          { name: 'a', type: 'group' },
+          { name: 'b', type: 'group' },
         ],
-        pattern: '^/test/([^/]+)/([^/]+)$',
       },
     ]);
     const route = await renderRoute('/test/w/x', {
@@ -849,20 +784,14 @@ describe('createPages', () => {
         routeElement: { isStatic: true },
         noSsr: false,
         path: [
-          {
-            name: 'test',
-            type: 'literal',
-          },
-          {
-            name: 'a',
-            type: 'literal',
-          },
-          {
-            name: 'b',
-            type: 'literal',
-          },
+          { name: 'test', type: 'literal' },
+          { name: 'a', type: 'literal' },
+          { name: 'b', type: 'literal' },
+        ],
+        pathPattern: [
+          { name: 'test', type: 'literal' },
+          { name: 'path', type: 'wildcard' },
         ],
-        pattern: '^/test/(.*)$',
       },
     ]);
     const route = await renderRoute('/test/a/b', {
@@ -885,23 +814,16 @@ describe('createPages', () => {
     const { getPathConfig, renderRoute } = injectedFunctions();
     expect(await getPathConfig()).toEqual([
       {
-        routeElement: { isStatic: true },
         elements: {
           root: { isStatic: true },
           'page:/test/[...path]': { isStatic: false },
         },
+        routeElement: { isStatic: true },
         noSsr: false,
         path: [
-          {
-            name: 'test',
-            type: 'literal',
-          },
-          {
-            name: 'path',
-            type: 'wildcard',
-          },
+          { name: 'test', type: 'literal' },
+          { name: 'path', type: 'wildcard' },
         ],
-        pattern: '^/test/(.*)$',
       },
     ]);
     const route = await renderRoute('/test/a/b', {
@@ -949,34 +871,22 @@ describe('createPages', () => {
     const { getPathConfig } = injectedFunctions();
     expect(await getPathConfig()).toEqual([
       {
-        routeElement: { isStatic: true },
         elements: {
           root: { isStatic: true },
           'page:/static': { isStatic: true },
         },
+        routeElement: { isStatic: true },
         noSsr: true,
-        path: [
-          {
-            name: 'static',
-            type: 'literal',
-          },
-        ],
-        pattern: '^/static$',
+        path: [{ name: 'static', type: 'literal' }],
       },
       {
-        routeElement: { isStatic: true },
         elements: {
           root: { isStatic: true },
           'page:/dynamic': { isStatic: false },
         },
+        routeElement: { isStatic: true },
         noSsr: true,
-        path: [
-          {
-            name: 'dynamic',
-            type: 'literal',
-          },
-        ],
-        pattern: '^/dynamic$',
+        path: [{ name: 'dynamic', type: 'literal' }],
       },
     ]);
   });
@@ -1054,18 +964,11 @@ describe('createPages', () => {
           'page:/client/static': { isStatic: true },
         },
         routeElement: { isStatic: true },
-        pattern: '^/client/static$',
+        noSsr: false,
         path: [
-          {
-            type: 'literal',
-            name: 'client',
-          },
-          {
-            type: 'literal',
-            name: 'static',
-          },
+          { name: 'client', type: 'literal' },
+          { name: 'static', type: 'literal' },
         ],
-        noSsr: false,
       },
       {
         elements: {
@@ -1073,22 +976,17 @@ describe('createPages', () => {
           'page:/server/static/static-echo': { isStatic: true },
         },
         routeElement: { isStatic: true },
-        pattern: '^/server/static/([^/]+)$',
+        noSsr: false,
         path: [
-          {
-            type: 'literal',
-            name: 'server',
-          },
-          {
-            type: 'literal',
-            name: 'static',
-          },
-          {
-            type: 'literal',
-            name: 'static-echo',
-          },
+          { name: 'server', type: 'literal' },
+          { name: 'static', type: 'literal' },
+          { name: 'static-echo', type: 'literal' },
+        ],
+        pathPattern: [
+          { name: 'server', type: 'literal' },
+          { name: 'static', type: 'literal' },
+          { name: 'echo', type: 'group' },
         ],
-        noSsr: false,
       },
       {
         elements: {
@@ -1096,22 +994,17 @@ describe('createPages', () => {
           'page:/server/static/static-echo-2': { isStatic: true },
         },
         routeElement: { isStatic: true },
-        pattern: '^/server/static/([^/]+)$',
+        noSsr: false,
         path: [
-          {
-            type: 'literal',
-            name: 'server',
-          },
-          {
-            type: 'literal',
-            name: 'static',
-          },
-          {
-            type: 'literal',
-            name: 'static-echo-2',
-          },
+          { name: 'server', type: 'literal' },
+          { name: 'static', type: 'literal' },
+          { name: 'static-echo-2', type: 'literal' },
+        ],
+        pathPattern: [
+          { name: 'server', type: 'literal' },
+          { name: 'static', type: 'literal' },
+          { name: 'echo', type: 'group' },
         ],
-        noSsr: false,
       },
       {
         elements: {
@@ -1119,26 +1012,19 @@ describe('createPages', () => {
           'page:/server/static/static-echo/static-echo-2': { isStatic: true },
         },
         routeElement: { isStatic: true },
-        pattern: '^/server/static/([^/]+)/([^/]+)$',
+        noSsr: false,
         path: [
-          {
-            type: 'literal',
-            name: 'server',
-          },
-          {
-            type: 'literal',
-            name: 'static',
-          },
-          {
-            type: 'literal',
-            name: 'static-echo',
-          },
-          {
-            type: 'literal',
-            name: 'static-echo-2',
-          },
+          { name: 'server', type: 'literal' },
+          { name: 'static', type: 'literal' },
+          { name: 'static-echo', type: 'literal' },
+          { name: 'static-echo-2', type: 'literal' },
+        ],
+        pathPattern: [
+          { name: 'server', type: 'literal' },
+          { name: 'static', type: 'literal' },
+          { name: 'echo', type: 'group' },
+          { name: 'echo2', type: 'group' },
         ],
-        noSsr: false,
       },
       {
         elements: {
@@ -1146,26 +1032,19 @@ describe('createPages', () => {
           'page:/server/static/hello/hello-2': { isStatic: true },
         },
         routeElement: { isStatic: true },
-        pattern: '^/server/static/([^/]+)/([^/]+)$',
+        noSsr: false,
         path: [
-          {
-            type: 'literal',
-            name: 'server',
-          },
-          {
-            type: 'literal',
-            name: 'static',
-          },
-          {
-            type: 'literal',
-            name: 'hello',
-          },
-          {
-            type: 'literal',
-            name: 'hello-2',
-          },
+          { name: 'server', type: 'literal' },
+          { name: 'static', type: 'literal' },
+          { name: 'hello', type: 'literal' },
+          { name: 'hello-2', type: 'literal' },
+        ],
+        pathPattern: [
+          { name: 'server', type: 'literal' },
+          { name: 'static', type: 'literal' },
+          { name: 'echo', type: 'group' },
+          { name: 'echo2', type: 'group' },
         ],
-        noSsr: false,
       },
       {
         elements: {
@@ -1173,22 +1052,17 @@ describe('createPages', () => {
           'page:/static/wild/bar': { isStatic: true },
         },
         routeElement: { isStatic: true },
-        pattern: '^/static/wild/(.*)$',
+        noSsr: false,
         path: [
-          {
-            type: 'literal',
-            name: 'static',
-          },
-          {
-            type: 'literal',
-            name: 'wild',
-          },
-          {
-            type: 'literal',
-            name: 'bar',
-          },
+          { name: 'static', type: 'literal' },
+          { name: 'wild', type: 'literal' },
+          { name: 'bar', type: 'literal' },
+        ],
+        pathPattern: [
+          { name: 'static', type: 'literal' },
+          { name: 'wild', type: 'literal' },
+          { name: 'wild', type: 'wildcard' },
         ],
-        noSsr: false,
       },
       {
         elements: {
@@ -1196,26 +1070,18 @@ describe('createPages', () => {
           'page:/static/wild/hello/hello-2': { isStatic: true },
         },
         routeElement: { isStatic: true },
-        pattern: '^/static/wild/(.*)$',
+        noSsr: false,
         path: [
-          {
-            type: 'literal',
-            name: 'static',
-          },
-          {
-            type: 'literal',
-            name: 'wild',
-          },
-          {
-            type: 'literal',
-            name: 'hello',
-          },
-          {
-            type: 'literal',
-            name: 'hello-2',
-          },
+          { name: 'static', type: 'literal' },
+          { name: 'wild', type: 'literal' },
+          { name: 'hello', type: 'literal' },
+          { name: 'hello-2', type: 'literal' },
+        ],
+        pathPattern: [
+          { name: 'static', type: 'literal' },
+          { name: 'wild', type: 'literal' },
+          { name: 'wild', type: 'wildcard' },
         ],
-        noSsr: false,
       },
       {
         elements: {
@@ -1223,30 +1089,19 @@ describe('createPages', () => {
           'page:/static/wild/foo/foo-2/foo-3': { isStatic: true },
         },
         routeElement: { isStatic: true },
-        pattern: '^/static/wild/(.*)$',
+        noSsr: false,
         path: [
-          {
-            type: 'literal',
-            name: 'static',
-          },
-          {
-            type: 'literal',
-            name: 'wild',
-          },
-          {
-            type: 'literal',
-            name: 'foo',
-          },
-          {
-            type: 'literal',
-            name: 'foo-2',
-          },
-          {
-            type: 'literal',
-            name: 'foo-3',
-          },
+          { name: 'static', type: 'literal' },
+          { name: 'wild', type: 'literal' },
+          { name: 'foo', type: 'literal' },
+          { name: 'foo-2', type: 'literal' },
+          { name: 'foo-3', type: 'literal' },
+        ],
+        pathPattern: [
+          { name: 'static', type: 'literal' },
+          { name: 'wild', type: 'literal' },
+          { name: 'wild', type: 'wildcard' },
         ],
-        noSsr: false,
       },
       {
         elements: {
@@ -1254,18 +1109,11 @@ describe('createPages', () => {
           'page:/client/dynamic': { isStatic: false },
         },
         routeElement: { isStatic: true },
-        pattern: '^/client/dynamic$',
+        noSsr: false,
         path: [
-          {
-            type: 'literal',
-            name: 'client',
-          },
-          {
-            type: 'literal',
-            name: 'dynamic',
-          },
+          { name: 'client', type: 'literal' },
+          { name: 'dynamic', type: 'literal' },
         ],
-        noSsr: false,
       },
       {
         elements: {
@@ -1273,22 +1121,12 @@ describe('createPages', () => {
           'page:/server/one/[echo]': { isStatic: false },
         },
         routeElement: { isStatic: true },
-        pattern: '^/server/one/([^/]+)$',
+        noSsr: false,
         path: [
-          {
-            type: 'literal',
-            name: 'server',
-          },
-          {
-            type: 'literal',
-            name: 'one',
-          },
-          {
-            type: 'group',
-            name: 'echo',
-          },
+          { name: 'server', type: 'literal' },
+          { name: 'one', type: 'literal' },
+          { name: 'echo', type: 'group' },
         ],
-        noSsr: false,
       },
       {
         elements: {
@@ -1296,26 +1134,13 @@ describe('createPages', () => {
           'page:/server/two/[echo]/[echo2]': { isStatic: false },
         },
         routeElement: { isStatic: true },
-        pattern: '^/server/two/([^/]+)/([^/]+)$',
+        noSsr: false,
         path: [
-          {
-            type: 'literal',
-            name: 'server',
-          },
-          {
-            type: 'literal',
-            name: 'two',
-          },
-          {
-            type: 'group',
-            name: 'echo',
-          },
-          {
-            type: 'group',
-            name: 'echo2',
-          },
+          { name: 'server', type: 'literal' },
+          { name: 'two', type: 'literal' },
+          { name: 'echo', type: 'group' },
+          { name: 'echo2', type: 'group' },
         ],
-        noSsr: false,
       },
       {
         elements: {
@@ -1323,22 +1148,12 @@ describe('createPages', () => {
           'page:/server/wild/[...wild]': { isStatic: false },
         },
         routeElement: { isStatic: true },
-        pattern: '^/server/wild/(.*)$',
+        noSsr: false,
         path: [
-          {
-            type: 'literal',
-            name: 'server',
-          },
-          {
-            type: 'literal',
-            name: 'wild',
-          },
-          {
-            type: 'wildcard',
-            name: 'wild',
-          },
+          { name: 'server', type: 'literal' },
+          { name: 'wild', type: 'literal' },
+          { name: 'wild', type: 'wildcard' },
         ],
-        noSsr: false,
       },
       {
         elements: {
@@ -1346,26 +1161,13 @@ describe('createPages', () => {
           'page:/server/oneAndWild/[slug]/[...wild]': { isStatic: false },
         },
         routeElement: { isStatic: true },
-        pattern: '^/server/oneAndWild/([^/]+)/(.*)$',
+        noSsr: false,
         path: [
-          {
-            type: 'literal',
-            name: 'server',
-          },
-          {
-            type: 'literal',
-            name: 'oneAndWild',
-          },
-          {
-            type: 'group',
-            name: 'slug',
-          },
-          {
-            type: 'wildcard',
-            name: 'wild',
-          },
+          { name: 'server', type: 'literal' },
+          { name: 'oneAndWild', type: 'literal' },
+          { name: 'slug', type: 'group' },
+          { name: 'wild', type: 'wildcard' },
         ],
-        noSsr: false,
       },
     ]);
     const route = await renderRoute('/server/two/a/b', {