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

Unlinking md/vue file will cause an temporary webapck error #351

Closed
ulivz opened this issue May 6, 2018 · 1 comment
Closed

Unlinking md/vue file will cause an temporary webapck error #351

ulivz opened this issue May 6, 2018 · 1 comment
Assignees
Labels
type: enhancement Request to enhance an existing feature

Comments

@ulivz
Copy link
Member

ulivz commented May 6, 2018

  • 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.

  1. When you add a new component, chokidar catch the add event, and re-generated the temp files. so the process is:
add compoennt 
      => update by chokidar => temp file change => webpack HMR
  1. 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 the chokidar catch the unlink 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 HMR
  • add/unlink/addDir/unlinkDir => only update by chokidar (disable webpack HMR)

I just checked the watchpack:

https://github.com/webpack/watchpack/blob/8d839e8b6edb87f9cd8a1ff97028060c4ecc9bee/lib/DirectoryWatcher.js#L67-L72

And also checked webpack's docs / code but didn't find any approach.

cc @yyx990803

@ulivz
Copy link
Member Author

ulivz commented Aug 20, 2018

We're closing this issue as stale as it's more than 20 days without activity, and without an associated Pull Request. Please feel free to continue discussion. We'll reopen this issue if anything actionable is posted.

@ulivz ulivz closed this as completed Aug 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement Request to enhance an existing feature
Projects
None yet
Development

No branches or pull requests

2 participants