Support for Integrating Routes from Packages in React Router route manifest #13358
fernandojbf
started this conversation in
Proposals
Replies: 1 comment 2 replies
-
It’s not a direct solution to your problem but you can export routes definition from the package instead of this approach. It’ll be more bulletproof, package will be self contained and there’re some helpers like “prefix” and “relative” for this. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I'm working on a project that includes shared routes/pages via packages. To achieve this, we made a solution that adds these routes dynamically via a
routes.ts
file.Since React Router does not natively allow adding routes from outside the project, we implemented a workaround that matches the
node_modules
file via a relative path:This translates to:
This setup worked well with Yarn since the file paths resolved correctly.
The Problem
We are migrating to pnpm, and due to how
viteManifest
is created, the chunk names now point to the.pnpm/
folder instead of thenode_modules
package path. This breaks the build since our workaround depends on thenode_modules
structure and the chunk is search bylet entryChunk = viteManifest[rootRelativeFilePath];
.My Question
Is there (or will be) a way to officially integrate routes from external packages into the React Router routes manifest? I understand that our current approach relies on implementation details that can change and may not be ideal. However, having built-in support for sharing routes across packages could be valuable.
We have the options to create local files and import/export the package. But if we had a way to use the manifest, the routes could be integrated from the package directly (multiple routes, etc)
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions