-
Notifications
You must be signed in to change notification settings - Fork 913
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
[Hot Reload] Add line in <template> cause state lost #1682
Comments
I haven't dug into this yet. But at first glance, it seems that it's because the changed line numbers lead to changing padding lines for the script block, which in turn triggers a hot-reload of the script, and |
@sodatea You're right! |
Found the padding-line codes: https://github.com/vuejs/vue/blob/fb589e6f9bc7db56a508f8f610ce321377bf0a6f/src/sfc/parser.js#L103-L106 // pad content so that linters and pre-processors can output correct
// line numbers in errors and warnings
if (currentBlock.type !== 'template' && options.pad) {
text = padContent(currentBlock, options.pad) + Seems like it's a choice between accurate line number in error and the hot reload tolerance now. Maybe webpack HMR module should do the Anyway, if we put the |
I guess #1795 is the exact same issue as described here. Unfortunately, placing the By the way, this behaviour also happens when you just replace a character in the template (which means line numbers shouldn't change), or when editing something in the |
Same issue here with v15.9.1 and latest webpack v4. Using Edit: |
@sodatea is this an issue that can be solved in vue-loader or it has to be fixed in the sfc/parser (as linked above) ? I tried to look into vue-loader hmr code, can't figure it out and all I see is that Edit: Moving the |
have u fix this bug with any solutions? |
Version
15.9.2
Reproduction link
https://github.com/tianjianchn/vue-hello-world/tree/vue-loader-hot-reload-bug
Steps to reproduce
count
count
by 1 when clickingWhat is expected?
the
count
value should be kept, other than restored to the initial value.What is actually happening?
the
count
value was restored to the initial value.The text was updated successfully, but these errors were encountered: