Skip to content

fix(dev/config): skip package.json resolution with custom server.entry #13744

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 16, 2025

Conversation

markmals
Copy link
Contributor

@markmals markmals commented Jun 4, 2025

Skip package.json file checks when a user-supplied entry.server file is present

Copy link

changeset-bot bot commented Jun 4, 2025

🦋 Changeset detected

Latest commit: 233b0e0

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

@remix-cla-bot
Copy link
Contributor

remix-cla-bot bot commented Jun 4, 2025

Hi @markmals,

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

@MichaelDeBoey MichaelDeBoey changed the title Fix package.json resolution with custom server entry fix(dev/config): fix package.json resolution with custom server.entry Jun 4, 2025
Copy link
Member

@MichaelDeBoey MichaelDeBoey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rebase your branch onto latest dev

@remix-cla-bot
Copy link
Contributor

remix-cla-bot bot commented Jun 7, 2025

Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳

@markmals markmals requested a review from MichaelDeBoey June 7, 2025 16:43
@markmals
Copy link
Contributor Author

markmals commented Jun 7, 2025

@MichaelDeBoey done! Let me know if there's anything else I need to do. I couldn't figure out how to make this PR target dev instead of main in the GitHub UI

@timdorr timdorr changed the base branch from main to dev June 7, 2025 18:24
@markmals
Copy link
Contributor Author

After some trial and error (namely, running deno clean a bunch), I got this to successfully work without a package.json in the Deno template without errors. It was a struggle getting it up and running so I would appreciate others helping me with a sanity check here remix-run/react-router-templates#134

@brookslybrand
Copy link
Contributor

Hey @markmals I think this is pretty reasonable, thanks for adding it!

Will you

  1. Create an issue to explain the problem this is solving
  2. Create a change set so this goes out in the next patch release?

@markmals
Copy link
Contributor Author

@brookslybrand done! #13743

@timdorr
Copy link
Member

timdorr commented Jun 13, 2025

Also, not to be overly pedantic, but can we add a test to prevent a regression in the future? Sorry for all the hoops to jump through!

@markmals
Copy link
Contributor Author

I can definitely do that, but I would like some guidance on what kind of test this should be. I could add a Deno fixture to @react-router/dev but I'm not sure how testing Deno would work with the current Jest and CI setup and it may introduce complexities and dependencies that members of the team would like to weigh in on?

@timdorr
Copy link
Member

timdorr commented Jun 13, 2025

Hmm, I'm not 100% sure it's testable via our current test infra. I saw the fixtures/basic path and assumed that could be used, but it doesn't look to be hooked up to anything.

@markmals
Copy link
Contributor Author

Do you have thoughts, @brookslybrand?

@markdalgleish markdalgleish changed the title fix(dev/config): fix package.json resolution with custom server.entry fix(dev/config): skip package.json resolution with custom server.entry Jun 15, 2025
@markdalgleish
Copy link
Member

markdalgleish commented Jun 15, 2025

Since this is difficult to test and any regressions will be trivial to catch, and the existing package.json resolution logic didn't have any specific tests around it, I'm comfortable merging this fix without adding new tests.


if (!packageJsonPath) {
throw new Error(
`Could not find package.json in ${rootDirectory} or any of its parent directories. Please add a package.json, or provide a custom entry.server.tsx/jsx file in your app directory.`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that this error can also be avoided by introducing a custom entry.server.tsx/jsx, I've expanded the error message to make this clear, similar to the error message following this one.

Copy link
Member

@markdalgleish markdalgleish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

@markdalgleish markdalgleish merged commit 70dba29 into remix-run:dev Jun 16, 2025
8 checks passed
Copy link
Contributor

🤖 Hello there,

We just published version 7.6.3-pre.0 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

Copy link
Contributor

🤖 Hello there,

We just published version 7.6.3 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants