Configurable entry file path names (routes, root, entry.client, entry.server) #13268
Replies: 2 comments
-
Created a draft PR for a possible implementation here in #13269. |
Beta Was this translation helpful? Give feedback.
-
Having thought about this more, I think there are maybe two concerns here: the root file, which is potentially a Initially we grasped for using vite virtual modules to abstract how the entry and root files ares resolved, but currently they're read directly from the file system: https://github.com/remix-run/react-router/blob/main/packages/react-router-dev/config/config.ts#L748, but I think using virtual modules to resolve these files might make it easier to customize this behavior. |
Beta Was this translation helpful? Give feedback.
-
Configurable entry file path names
Summary
The standard entry file names (
root
,routes
,entry.client
,entry.server
) should be configurable via the React Router configuration, allowing projects to use custom file names and paths while maintaining the same functionality.Motivation
While the default conventions are clear and work well for new projects, we have found that with many React Router apps, it becomes cumbersome to manage all of these files for each application. For example, we have a shared
root.tsx
that is used in dozens of applications, and the contents of that file is effectively re-exporting all of the functionality from a shared package:Rather than having to manage all of these "shell" entry files, we'd like to centralize to a single implementation and point each application to that source root file.
Furthermore, this would offer a mechanism that library authors could use to provide custom implementations of the default entry files through exposing a configuration preset that points one or more of the entry files to their custom implementations.
Proposed Solution
Add configuration options to
react-router.config.ts
for specifying custom file names:Implementation Details
appDirectory
, or be an absolute path that doesn't necessarily live within theappDirectory
to support shared configurations across multiple applications.Breaking Changes
None. This is a purely additive change that maintains backward compatibility with existing projects.
Beta Was this translation helpful? Give feedback.
All reactions