Closed
Description
- Your OS: OSX 10.12.6
- Node.js version: 9.4.0
- VuePress version: 0.8.4
Summary
This issue was found by @meteorlxy at #348
unlinking a markdown/component file will cause an webapck error first, and then successfully compiled after the prepare finish.
Why having this bug?
Let me take a vue component file as an example.
- When you add a new component,
chokidar
catch theadd
event, and re-generated the temp files. so the process is:
add compoennt
=> update by chokidar => temp file change => webpack HMR
- When you delete the component you just added, first, webpack catch the
unlink
event immediately and tried to run HMR, but an linked module was missing so an error will be emitted soon, At the same time thechokidar
catch theunlink
event too, after several ms, temp files are re-generated, so webpack will update again, then the error disappeared. so the process is:
delete component
=> webpack HMR => emit error.
=> update by chokidar => .... => temp file change => webpack HMR => error fixed.
Workaround
Exclude the files at docs/**
in webpack and add change
event to chokidar
. then the process will be:
delete component
=> update by chokidar => .... => temp file change => webpack HMR => error fixed.
But this solution has a side effect is that when you only typed some words, update by chokidar
will be re-run.
Ideal workaround
if webpack
watchOptions can support conditional ignore, there will be a perfect fix:
change
=> webpack HMRadd/unlink/addDir/unlinkDir
=> only update by chokidar (disable webpack HMR)
I just checked the watchpack
:
And also checked webpack's docs / code but didn't find any approach.
cc @yyx990803