Skip to content
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

fix(hmr): package.json change should trigger server restart #15519

Merged

Conversation

btea
Copy link
Collaborator

@btea btea commented Jan 6, 2024

Description

When vite starts the project, the following prompt will appear. After I change the type field value to module according to the prompts, I hope the server can restart.
image

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines, especially the Pull Request Guidelines.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Update the corresponding documentation if needed.
  • Ideally, include relevant tests that fail without this PR but pass with it.

Copy link

stackblitz bot commented Jan 6, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

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

Sounds like a good addition to me. I know Astro does this manually today too.

@bluwy bluwy added the p2-nice-to-have Not breaking anything but nice to have (priority) label Jan 8, 2024
@patak-dev patak-dev added this to the 5.1 milestone Jan 8, 2024
@patak-dev
Copy link
Member

We are starting merging PRs towards Vite 5.1, I think we can move forward with this one so it is included in the first beta.

@patak-dev patak-dev merged commit 260ebbf into vitejs:main Jan 8, 2024
10 checks passed
@patak-dev
Copy link
Member

One detail we should review though is that when a new dependency is installed, the package json will change, triggering an unneeded reload (as it isn't used yet). Then the user will add the import and another reload will be triggered. I still think that it is better to have the reload, and we can later check if we could avoid some reloads if possible (if this becomes a drag in DX)

@btea btea deleted the fix/package-json-change-trigger-restart branch January 9, 2024 00:03
@btea
Copy link
Collaborator Author

btea commented Jan 9, 2024

@patak-dev Yes, you are right. I created a new pr #15543 based on your suggestion and will only compare the changes in the type field to determine whether a restart is needed.

patak-dev added a commit that referenced this pull request Jan 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2-nice-to-have Not breaking anything but nice to have (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants