honkit / honkit

:book: HonKit is building beautiful books using Markdown - Fork of GitBook

Home Page:https://honkit.netlify.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

reload infinitely when use soft link of node_modules for local serve

crifan opened this issue · comments

Summary

local debug:

npx honkit serve

  • using normal node_modules: OK
  • using soft link node_modules: infinite reload
    • soft link node_modules created by
      • ln -s ../../generated/honkit/node_modules node_modules
  • HonKit version: 8.5.2
  • node version: v17.7.1
  • npm version: 8.5.2

Step to reproduce

  1. npm install honkit --save-dev
  2. npx honkit init
  3. move node_modules to other (common) folder: ../../generated/honkit/node_modules
  4. create ln(soft link) for node_modules: ln -s ../../generated/honkit/node_modules node_modules
  5. npx honkit serve
  6. change content -> trigger reload, but infinite reload, reload dead forever
  • Link to code example:

Expected results

NO infinite reload == no reload deadlock

Actual results

infinite reload == reload deadlock

WX20220611-093903@2x

commented

const watcher = chokidar.watch(toWatch, {
cwd: dir,
ignored: "_book/**",
ignoreInitial: true,
});

Probably, We can avoid infinity loop by adding node_modules to ignored pattern.
However, I don't understand if it resolve all symlink issue.

Thanks for your reply.

Final worked by add node_modules to ignored list:

  • honkit/lib/cli/watch.js
    const watcher = chokidar_1.default.watch(toWatch, {
        cwd: dir,
        // ignored: "_book/**",
        ignored: ["_book/**", "node_modules/**"],
        ignoreInitial: true,
    });

honkit watcher ignore

-> so

  • here: ignored work for ln -s symlink
    • If not work, others may try followSymlinks for chokidar's watcher