Skip to content

Commit 8928f7b

Browse files
feat: support multiple extensions for routes file (#17)
1 parent b8a2a5f commit 8928f7b

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

.changeset/cold-icons-lick.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'rsbuild-plugin-react-router': patch
3+
---
4+
5+
search for routes file with any extention

.changeset/social-flowers-itch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'rsbuild-plugin-react-router': patch
3+
---
4+
5+
support multiple extentions for routes file, like js,ts,jsx etc

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,16 @@ export const pluginReactRouter = (
9797
return {} as Config;
9898
});
9999

100-
const routesPath = resolve(appDirectory, 'routes.ts');
100+
const routesPath = findEntryFile(resolve(appDirectory, 'routes'));
101101

102102
// Then read the routes
103103
const routeConfig = await jiti
104104
.import<RouteConfigEntry[]>(routesPath, {
105105
default: true,
106106
})
107107
.catch(error => {
108-
console.error('Failed to load routes.ts:', error);
109-
console.error('No routes.ts found in app directory.');
108+
console.error('Failed to load routes file:', error);
109+
console.error('No routes file found in app directory.');
110110
return [] as RouteConfigEntry[];
111111
});
112112

0 commit comments

Comments
 (0)