squidfunk / mkdocs-material

Documentation that simply works

Home Page:https://squidfunk.github.io/mkdocs-material/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`npm run build:dirty -- --watch` fails with an error

jbms opened this issue · comments

Contribution guidelines

I've found a bug and checked that ...

  • ... the problem doesn't occur with the mkdocs or readthedocs themes
  • ... the problem persists when all overrides are removed, i.e. custom_dir, extra_javascript and extra_css
  • ... the documentation does not mention anything about my problem
  • ... there are no open or closed issues that are related to my problem

Description

After running npm run build:dirty -- --watch, if you then edit one of the templates in src/partials/*.html, the build exits with the following error:

~/shared/mkdocs-material $ npm run build:dirty -- --watch

> mkdocs-material@8.3.8 build:dirty
> ts-node -T tools/build --dirty "--watch"

Browserslist: caniuse-lite is outdated. Please run:
npx browserslist@latest --update-db

Why you should do it regularly:
https://github.com/browserslist/browserslist#browsers-data-updating
/home/jbms/shared/mkdocs-material/node_modules/rxjs/src/internal/operators/mergeInternals.ts:71
    innerFrom(project(value, index++)).subscribe(
              ^
TypeError: file.replace is not a function
    at /home/jbms/shared/mkdocs-material/tools/build/copy/index.ts:108:37
    at doInnerSub (/home/jbms/shared/mkdocs-material/node_modules/rxjs/src/internal/operators/mergeInternals.ts:71:15)
    at outerNext (/home/jbms/shared/mkdocs-material/node_modules/rxjs/src/internal/operators/mergeInternals.ts:53:58)
    at OperatorSubscriber._this._next (/home/jbms/shared/mkdocs-material/node_modules/rxjs/src/internal/operators/OperatorSubscriber.ts:70:13)
    at OperatorSubscriber.Subscriber.next (/home/jbms/shared/mkdocs-material/node_modules/rxjs/src/internal/Subscriber.ts:75:12)
    at /home/jbms/shared/mkdocs-material/node_modules/rxjs/src/internal/operators/mergeInternals.ts:85:24
    at OperatorSubscriber._this._next (/home/jbms/shared/mkdocs-material/node_modules/rxjs/src/internal/operators/OperatorSubscriber.ts:70:13)
    at OperatorSubscriber.Subscriber.next (/home/jbms/shared/mkdocs-material/node_modules/rxjs/src/internal/Subscriber.ts:75:12)
    at FSWatcher.handler (/home/jbms/shared/mkdocs-material/node_modules/rxjs/src/internal/observable/fromEvent.ts:288:52)
    at FSWatcher.emit (node:events:390:28)

Adding a console.log statement to copyAll indicates that the file argument is an array:

[
  'partials/nav-item.html',
  Stats {
    dev: 65025,
    mode: 33188,
    nlink: 1,
    uid: 297878,
    gid: 89939,
    rdev: 0,
    blksize: 4096,
    ino: 10130539,
    size: 5727,
    blocks: 16,
    atimeMs: 1656695311294.666,
    mtimeMs: 1656695311294.666,
    ctimeMs: 1656695311294.666,
    birthtimeMs: 1656695084937.2944,
    atime: 2022-07-01T17:08:31.295Z,
    mtime: 2022-07-01T17:08:31.295Z,
    ctime: 2022-07-01T17:08:31.295Z,
    birthtime: 2022-07-01T17:04:44.937Z
  }
]

Adding a line:

if (Array.isArray(file)) file = file[0];

to copyAll avoids this error.

Expected behaviour

n/a

Actual behaviour

n/a

Steps to reproduce

n/a

Package versions

Configuration

n/a

System information

  • Operating system: Linux
  • Browser: n/a

Thanks for reporting. I'm not able to reproduce it. I'm running Node 16 on macOS.

It looks like there may be a difference between the API provided for file watching on Linux and macOS. I also can see that it does not reproduce on macOS.

Thanks for coming back. Interesting, then the error is very likely in the use of chokidar (the file watcher we use), and thus an upstream issue, either for chokidar's typings or for the actual business logic. If you can prove otherwise and we can actually do something about it (other than monkey-patching), please reopen.

It appears that the documentation for the rxjs fromEvent function is wrong. I filed a bug report.

ReactiveX/rxjs#7008