question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

HMR not working when vue scoped style block is removed

See original GitHub issue

Describe the bug

Modules are not removed from the ModuleGraph, even when they don’t exist anymore.

This can break HMR updates of other modules.

Reproduction

Start with two style blocks in a vue SFC:

<style scoped>
...
</style>

<style module>
...
</style>

Changes within both style blocks trigger correct HMR updates.

Now, remove the first block completely. Then update the content of the remaining block. This will trigger a HMR update for the missing block and the client is not updated.

The same thing happens when just changing a single <style scoped> to <style module>.

System Info

I’m observing this with vite-plugin-vue2, but this should be the same with the vue 3 plugin - the code is the same, because the problem is in the invalid modules list provided in the context to handleHotUpdate.

Output of npx envinfo --system --npmPackages vite,@vitejs/plugin-vue --binaries --browsers:

  System:
    OS: Linux 5.12 Alpine Linux
    CPU: (32) x64 AMD Ryzen 9 3950X 16-Core Processor
    Memory: 103.17 GB / 125.81 GB
    Container: Yes
    Shell: 1.32.1 - /bin/ash
  Binaries:
    Node: 16.2.0 - /usr/local/bin/node
    Yarn: 1.22.5 - /usr/local/bin/yarn
    npm: 7.13.0 - /usr/local/bin/npm
  npmPackages:
    vite: 2.3.5 => 2.3.5
    vite-plugin-vue2: 1.5.2 => 1.5.2

Used package manager: yarn

Logs

Once the module graph is in the invalid state, vite will print the following when changing the remaining <style module> block:

[vite] hmr update [...]?vue&type=style&index=0&scoped=true&lang.scss

The reference for “scoped” is still there, even though it’s now a module.


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

  • Read the Contributing Guidelines.
  • Read the docs.
  • Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
  • Provide a description in this issue that describes the bug.
  • Make sure this is a Vite issue and not a framework-specific issue. For example, if it’s a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/vue-next instead.
  • Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
wolfgangwalthercommented, Mar 11, 2022

I’m now on 2.8.6 and can’t reproduce it anymore. It must have been fixed in the meantime.

0reactions
bluwycommented, Mar 11, 2022

@wolfgangwalther Does this still happen with the latest version of Vite and @vitejs/plugin-vue? A repo/stackblitz would be great too to quickly spin up and test it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

vue.js - Scoped CSS not being applied within the component
Show activity on this post. The <style> uses the scoped attribute. When applied, the CSS does not get loaded in. When scoped is...
Read more >
Single-File Components - Vue.js
The <template> , <script> , and <style> blocks encapsulate and colocate the view, logic and styling of a component in the same file....
Read more >
Vue - Parcel
Parcel supports Vue automatically using the @parcel/transformer-vue plugin. When a .vue file is detected, it will be installed into your project automatically.
Read more >
Vue.js and Webpack 4 From Scratch, Part 2 - ITNEXT
Let's start by getting webpack-dev-server setup, by doing this we won't need to keep running our build script to see the changes in...
Read more >
How to configure Webpack 4 with VueJS : a complete guide
For the past 2 months, I have worked on many parts of the application ... .css .scss and .sass files are loaded with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found