content
content copied to clipboard
Parenthesis the file path prevent hot reloading of content
Version
@nuxt/content: 1.14.0 nuxt: 2.15.7
Steps to reproduce
Create a Nuxt + @nuxt/content project in directory where some ancestor has parenthesis in the name. For example, ~/Work (Open Source)/my-project
What is Expected?
When I change text in .md or .yml files within the content
directory, for the changes to hot reload in my browser when as long as yarn dev
is running.
What is actually happening?
Content changes do not hot reload. I need to restart yarn dev
before the changes appear in browser. And they do appear on restart of Nuxt. This seems to be an issue only with the hot reloading of content feature. When I move the same project out of a file path containing parenthesis, it works as expected.
@weotch
This seems to be an issue only with the hot reloading of content feature.
Just in case, do you mean that hot reload works when you edit other files than markdown files in content
directory, even if the project root is in directory where some ancestor has parenthesis in the name?
I meant that hot reload of Vue components works fine, like if I edit components of the Nuxt project that is using @nuxt/content.
@weotch
TL;DR
At the moment, you can't enjoy hot-reloading of files in content
directory, if parentheses are included in ancestor directory names.
Spending whole Saturday (I was not so productive 😇), finally I found the root cause:
With parentheses in ancestor directory names, change
events are not emitted by the file watcher.
Since Nuxt Content hot-reloads UI in the browser, listening the events, it doesn't do anything if there is no event.
Nuxt Content uses chokidar, and the bug is in it. I already reported the bug to the upstream repository with reproduction demo. 😄
@Atinux @Tahul
Sorry to mention in the weekend.
JFYR, if Nuxt Content v2 and/or Docus depends on chokidar, they would have the same kind of limitation. I'm glad to write some notes about this limitation somewhere in docs, so let me know if you want.
~~Or, if you take it positively, it might the time to implement your own file watcher like unjs/watch
.~~
⬆️ Forgive me to say such a stupid thing. My brain is not working since it's almost 4 a.m. in my place.
...I don't know the way to break my habit that I can't sleep, if I find a bug report, until I fix a bug or at least find the root cause.
Ha sorry for interrupting your Saturday with this 😓. I appreciate your investigation!
No need to apologise for pinging on weekend @NozomuIkuta and thank you for investigating the issue :blush:
Docus and even Nuxt 3 is also using chokidar
via unstorage: https://github.com/unjs/unstorage/blob/main/package.json#L43
We can track the issue you created and see if it can be solved: https://github.com/paulmillr/chokidar/issues/1165
I like the idea of unjs/watch
but Paul Miller is doing a great job with chokidar and this kind of tool take a lot of time, no need to re-invent the wheel but instead helping on other open source projects.
cc @pi0 (FYI)
@weotch
Ha sorry for interrupting your Saturday with this 😓. I appreciate your investigation!
There is definitely no problem on your side. 🙌 Sorry, my words were not enough.
I'm glad to help people in any way I can do. In some meaning, contributing to OSS and playing TV games on weekends are just same kind of thing to me.
My bad is that I tend to play these games too much until I get win some medals. 😅