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: invalidate inlined proxy scripts on change #5891

Merged
merged 5 commits into from
Dec 2, 2021

Conversation

matthewp
Copy link
Contributor

Description

The dev HTML plugin converts inline module scripts into external proxy scripts. This change makes it so that when a proxy script is cached it also invalidates the module within the module graph. Without this if the script ever changes then the module will be stale.

Additional context

None


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.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • 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).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@matthewp matthewp changed the title Invalidate inlined proxy scripts on change fix: invalidate inlined proxy scripts on change Nov 29, 2021
@matthewp
Copy link
Contributor Author

I don't know why a downstream merge closed this! Reopening.

@matthewp matthewp reopened this Nov 29, 2021
Shinigami92
Shinigami92 previously approved these changes Nov 30, 2021
@Shinigami92 Shinigami92 added the p3-minor-bug An edge case that only affects very specific usage (priority) label Nov 30, 2021
@Shinigami92 Shinigami92 marked this pull request as draft December 2, 2021 08:30
@patak-dev patak-dev marked this pull request as ready for review December 2, 2021 14:36
@patak-dev patak-dev merged commit 5b8c58b into vitejs:main Dec 2, 2021
@patak-dev
Copy link
Member

Let's get this one in, it would be great to get a test in the CI for it at one point 🙏🏼

@matthewp
Copy link
Contributor Author

matthewp commented Dec 2, 2021

Let's get this one in, it would be great to get a test in the CI for it at one point 🙏🏼

Would love some advice on this. This change requires:

  1. An inline script in HTML.
  2. That changes on each request.
  3. Where multiple requests actually happen.

Most of the tests in Vite are frontend (SPA) oriented as far as I can tell. Which makes sense given the normal use-cases, but it makes testing server-oriented code more difficult.

One thing that makes Vite difficult to test is that a lot of functionality is inside of the HTTP server, and testing HTTP servers can be quite difficult. If the middleware were abstracted so that they did not depend on a running port it would be easier to test their functionality.

@matthewp matthewp deleted the invalidate-proxy2 branch December 2, 2021 16:16
@patak-dev
Copy link
Member

@drwpow added two playgrounds: ssr-html and ssr-pug, that are closer to what Astro is doing

To test this, I think that this dynamic script could be changed with a counter when a particular request is issued to the server, and then you could check that HMR was properly triggered here by checking some side effect on the DOM. But I need to dig a bit deeper to see if there are blockers to do this, maybe it is more clear to @drwpow that was already playing with these tests.

@drwpow
Copy link
Contributor

drwpow commented Dec 2, 2021

But I need to dig a bit deeper to see if there are blockers to do this, maybe it is more clear to @drwpow that was already playing with these tests.

No blockers that I’m aware of. That sounds like a good test of this invalidation to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants