Skip to content

fix(hmr): entry mod's importers contains css mod invalidate hmr - #3929

Merged
patak-cat merged 2 commits into
vitejs:mainfrom
Y1D7NG:hotfix-hmr
Jun 28, 2021
Merged

fix(hmr): entry mod's importers contains css mod invalidate hmr#3929
patak-cat merged 2 commits into
vitejs:mainfrom
Y1D7NG:hotfix-hmr

Conversation

@Y1D7NG

@Y1D7NG Y1D7NG commented Jun 24, 2021

Copy link
Copy Markdown
Contributor

Description

fix #3913 #3716

HMR is not working as change entry javascript file or index.html

Additional context

entry file main.js:

import './index.css';

index.css:

@tailwind base;

hmr is not working as change themain.js, the client receive the error update message - hmr update index.css

PostCSS plugin Tailwind JIT register any file as a dependency to a CSS file. Although main.js is an entry file, main.js module's importers includes index.css module. Through the propagateUpdate function, get the wrong result that index.css needs to be updated.

function propagateUpdate(


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.

@yyx990803

Copy link
Copy Markdown
Member

Thanks @OneNail - the fix is correct, but the way it is implemented can be a bit difficult to read for future maintainers. I refactored it to be more explicit what case it is handling.

@patak-cat
patak-cat merged commit d97b33a into vitejs:main Jun 28, 2021
@Y1D7NG
Y1D7NG deleted the hotfix-hmr branch June 28, 2021 14:38
aleclarson pushed a commit to aleclarson/vite that referenced this pull request Nov 8, 2021
…js#3929)

* fix(hmr): entry mod's importers contains css mod invalidate hmr

* Update hmr.ts

Co-authored-by: Evan You <yyx990803@gmail.com>
@fabio-ivona

fabio-ivona commented Aug 2, 2022

Copy link
Copy Markdown

@yyx990803

If I've well understood the related issues, it seems that this fix aims to full reload the page when a tailwindcss app.css change is triggered by a change in an html file (or similar)

this works well quite all the times, but our plugin for livewire hot reload is broken by this (because it triggers a full reload while the client part of the plugin is trying to refresh the single livewire component)

is there any way to make this feature opt-in? or will you accept a PR to allowe to disable this in config

there are cases where a full reload is not needed (if not detrimental) when app.css is updated by tailwind

for reference:

https://github.com/def-studio/vite-livewire-plugin/discussions/12
https://github.com/laravel/vite-plugin/issues/111

@Niputi

Niputi commented Aug 2, 2022

Copy link
Copy Markdown
Contributor

@fabio-ivona please open a new issue

@fabio-ivona

Copy link
Copy Markdown

@Niputi thanks for your repy!

done in #9512

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vite Hot Reload not working

5 participants