From 00dc28c9654132d24aecffceeb7baea7a6a171c6 Mon Sep 17 00:00:00 2001 From: Ifeanyi Isitor Date: Sat, 19 Aug 2023 10:13:30 +0100 Subject: [PATCH] feat: add support for `.ts` extension --- package.json | 2 +- src/utils/__test__/convertPagePathToRoutePath.test.ts | 8 ++++---- src/utils/__test__/convertRoutePathToPagePath.test.ts | 8 ++++---- src/utils/__test__/findPageFiles.test.ts | 6 +++--- src/utils/__test__/findRouteFiles.test.ts | 6 +++--- src/utils/findPageFiles.ts | 2 +- src/utils/findRouteFiles.ts | 2 +- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index 38e7eabf..9198914d 100644 --- a/package.json +++ b/package.json @@ -69,4 +69,4 @@ "engines": { "node": ">=16.0.0" } -} \ No newline at end of file +} diff --git a/src/utils/__test__/convertPagePathToRoutePath.test.ts b/src/utils/__test__/convertPagePathToRoutePath.test.ts index 267ad79d..37e17e75 100644 --- a/src/utils/__test__/convertPagePathToRoutePath.test.ts +++ b/src/utils/__test__/convertPagePathToRoutePath.test.ts @@ -16,12 +16,12 @@ describe('convertPagePathToRoutePath', () => { routePath: '/somePath/routes/(loading).tsx', }, { - pagePath: '/somePath/(.routes)/error.tsx', - routePath: '/somePath/routes/(error).tsx', + pagePath: '/somePath/(.routes)/error.js', + routePath: '/somePath/routes/(error).js', }, { - pagePath: '/somePath/(.routes)/route.tsx', - routePath: '/somePath/routes/(route).tsx', + pagePath: '/somePath/(.routes)/route.ts', + routePath: '/somePath/routes/(route).ts', }, // Nested routes { diff --git a/src/utils/__test__/convertRoutePathToPagePath.test.ts b/src/utils/__test__/convertRoutePathToPagePath.test.ts index a62bf584..52ffebd1 100644 --- a/src/utils/__test__/convertRoutePathToPagePath.test.ts +++ b/src/utils/__test__/convertRoutePathToPagePath.test.ts @@ -16,12 +16,12 @@ describe('convertRoutePathToPagePath', () => { pagePath: '/somePath/(.routes)/loading.tsx', }, { - routePath: '/somePath/routes/(error).tsx', - pagePath: '/somePath/(.routes)/error.tsx', + routePath: '/somePath/routes/(error).js', + pagePath: '/somePath/(.routes)/error.js', }, { - routePath: '/somePath/routes/(route).tsx', - pagePath: '/somePath/(.routes)/route.tsx', + routePath: '/somePath/routes/(route).ts', + pagePath: '/somePath/(.routes)/route.ts', }, // Nested routes { diff --git a/src/utils/__test__/findPageFiles.test.ts b/src/utils/__test__/findPageFiles.test.ts index 4995a6cb..094c6f69 100644 --- a/src/utils/__test__/findPageFiles.test.ts +++ b/src/utils/__test__/findPageFiles.test.ts @@ -17,7 +17,7 @@ describe('findPageFiles', () => { 'layout.tsx': 'content here', 'loading.jsx': 'content here', 'error.tsx': 'content here', - 'route.tsx': 'content here', + 'route.ts': 'content here', // Nested routes 'test1.page.tsx': 'content here', 'test2.layout.tsx': 'content here', @@ -66,9 +66,9 @@ describe('findPageFiles', () => { }, { routePath: convertPagePathToRoutePath( - '/mocked/path/(.routes)/route.tsx' + '/mocked/path/(.routes)/route.ts' ), - pagePath: '/mocked/path/(.routes)/route.tsx', + pagePath: '/mocked/path/(.routes)/route.ts', }, // Nested routes { diff --git a/src/utils/__test__/findRouteFiles.test.ts b/src/utils/__test__/findRouteFiles.test.ts index 65422dd2..dbb3445d 100644 --- a/src/utils/__test__/findRouteFiles.test.ts +++ b/src/utils/__test__/findRouteFiles.test.ts @@ -17,7 +17,7 @@ describe('findRouteFiles', () => { '(layout).tsx': '', '(loading).jsx': '', '(error).tsx': '', - '(route).tsx': '', + '(route).ts': '', // Nested routes 'test1.(page).tsx': '', 'test2.(layout).tsx': '', @@ -50,8 +50,8 @@ describe('findRouteFiles', () => { routePath: '/mocked/path/routes/(page).js', }, { - pagePath: '/mocked/path/(.routes)/route.tsx', - routePath: '/mocked/path/routes/(route).tsx', + pagePath: '/mocked/path/(.routes)/route.ts', + routePath: '/mocked/path/routes/(route).ts', }, // Nested routes { diff --git a/src/utils/findPageFiles.ts b/src/utils/findPageFiles.ts index 03c66a35..c42998c7 100644 --- a/src/utils/findPageFiles.ts +++ b/src/utils/findPageFiles.ts @@ -15,7 +15,7 @@ export function findPageFiles(rootFolder: string): RouteFile[] { if (stat.isDirectory()) { traverseDirectory(absolutePath) - } else if (/\/\(\.routes\)\/.*\.(tsx|jsx|js)$/.test(absolutePath)) { + } else if (/\/\(\.routes\)\/.*\.(tsx|ts|jsx|js)$/.test(absolutePath)) { pageFiles.push({ routePath: convertPagePathToRoutePath(absolutePath), pagePath: absolutePath, diff --git a/src/utils/findRouteFiles.ts b/src/utils/findRouteFiles.ts index 2cb94313..e26af8ad 100644 --- a/src/utils/findRouteFiles.ts +++ b/src/utils/findRouteFiles.ts @@ -16,7 +16,7 @@ export function findRouteFiles(rootFolder: string): RouteFile[] { if (stat.isDirectory()) { traverseDirectory(absolutePath) } else if ( - /\/routes\/(.*\.)?\((page|layout|error|loading|route)\)\.(tsx|jsx|js)$/.test( + /\/routes\/(.*\.)?\((page|layout|error|loading|route)\)\.(tsx|ts|jsx|js)$/.test( absolutePath ) ) {