react-router
react-router copied to clipboard
fix(vite): loadEnv before reading routes
This PR moves the loadDotEnv function prior to configuring the routes.
Why is this important?
I have another project where routes are dynamically generated based on the value of a VITE_* variable, but when running react-router dev, I always get undefined unless I restart manually.
This PR removes the need for restarting manually every time.
🦋 Changeset detected
Latest commit: f9153ce77146a2eec02f4997ef76537eac65192d
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 11 packages
| Name | Type |
|---|---|
| @react-router/dev | Patch |
| @react-router/fs-routes | Patch |
| @react-router/remix-routes-option-adapter | Patch |
| create-react-router | Patch |
| react-router | Patch |
| react-router-dom | Patch |
| @react-router/architect | Patch |
| @react-router/cloudflare | Patch |
| @react-router/express | Patch |
| @react-router/node | Patch |
| @react-router/serve | Patch |
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
Hi @RFCreate,
Welcome, and thank you for contributing to React Router!
Before we consider your pull request, we ask that you sign our Contributor License Agreement (CLA). We require this only once.
You may review the CLA and sign it by adding your name to contributors.yml.
Once the CLA is signed, the CLA Signed label will be added to the pull request.
If you have already signed the CLA and received this response in error, or if you have any questions, please contact us at [email protected].
Thanks!
- The Remix team
Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳
Could you remove the upgrades to Vite in the package.json files? You only need to upgrade with pnpm, because that version selector will include 6.3.0.
I would rather not touch versions but pnpm keeps resolving Vite to version 6.2.5 which will fail in the integration test.
You can see that with Vite version 6.2.7 (latest in 6.2.x) the variable does not even appear after restarting.
@timdorr is there a reason for not moving Vite to ^6.3.0?
No, I was just trying to cut down on noise in the PR so the change is more visible.
The only thing I could think of is to reorder the commits so that the last two are the important ones.
Had to resolve the merge conflicts.
@brophdawg11 Sorry for the ping, is there something missing?
I added a changeset just in case, apart from that everything is the same.
I rewrote the tests to use the new fixtures and added back in the Vite v5 template. That confirmed that there aren't any breaking changes as part of this PR, so I downgraded the changeset from major to patch.
Thanks for the help.