Skip to content

Commit

Permalink
feat: add support for .ts extension
Browse files Browse the repository at this point in the history
  • Loading branch information
ifeanyiisitor committed Aug 19, 2023
1 parent 871a719 commit 00dc28c
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -69,4 +69,4 @@
"engines": {
"node": ">=16.0.0"
}
}
}
8 changes: 4 additions & 4 deletions src/utils/__test__/convertPagePathToRoutePath.test.ts
Expand Up @@ -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
{
Expand Down
8 changes: 4 additions & 4 deletions src/utils/__test__/convertRoutePathToPagePath.test.ts
Expand Up @@ -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
{
Expand Down
6 changes: 3 additions & 3 deletions src/utils/__test__/findPageFiles.test.ts
Expand Up @@ -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',
Expand Down Expand Up @@ -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
{
Expand Down
6 changes: 3 additions & 3 deletions src/utils/__test__/findRouteFiles.test.ts
Expand Up @@ -17,7 +17,7 @@ describe('findRouteFiles', () => {
'(layout).tsx': '',
'(loading).jsx': '',
'(error).tsx': '',
'(route).tsx': '',
'(route).ts': '',
// Nested routes
'test1.(page).tsx': '',
'test2.(layout).tsx': '',
Expand Down Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion src/utils/findPageFiles.ts
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/findRouteFiles.ts
Expand Up @@ -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
)
) {
Expand Down

0 comments on commit 00dc28c

Please sign in to comment.