Changes to this document are not reflected (even something minor like a change to the title string) unless the project is rebuilt. This issue does not occur if module.exports is not used:
There's a small section in the migration guide for migrating from v2 to v3 that mentions the new internal config loading library was changed from import-fresh to jiti. Specifically, the migration guide mentions the library is responsible for loading files such as docusaurus.config.js, sidebars.js, and Docusaurus plugins:
In theory, you have nothing to do, and your existing config files should keep working as before. However, this is a major dependency swap and subtle behavior changes could occur.
The subtle problematic behavior outlined in this issue seems to be due to this major dependency swap (I never encountered this problematic behavior with my v2 sites).
Visit the link to the example repo and try making changes to either the docusaurus.config.js or sidebars.js files as they currently exist (i.e., with module.exports). The changes will not register and hot reloading will fail. It's as if these files are not being watched anymore.
Expected behavior
Simple changes to the docusaurus.config.js file should be reflected via hot reloading (and they are when not using module.exports):
Similarly, changes to sidebars.js should be reflected via hot reloading (and they also are when not using module.exports):
Actual behavior
Simple changes to docusaurus.config.js do not register and hot reloading fails when module.exports is present:
Have you read the Contributing Guidelines on issues?
Prerequisites
npm run clear
oryarn clear
command.rm -rf node_modules yarn.lock package-lock.json
and re-installing packages.Description
Hot reloading for
docusaurus.config.js
ceases to work if it usesmodule.exports
:Changes to this document are not reflected (even something minor like a change to the
title
string) unless the project is rebuilt. This issue does not occur ifmodule.exports
is not used:Similarly, hot reloading for
sidebars.js
ceases to work ifmodule.exports
is used:This problem goes away once
module.exports
is not used:There's a small section in the migration guide for migrating from v2 to v3 that mentions the new internal config loading library was changed from
import-fresh
tojiti
. Specifically, the migration guide mentions the library is responsible for loading files such asdocusaurus.config.js
,sidebars.js
, and Docusaurus plugins:The subtle problematic behavior outlined in this issue seems to be due to this major dependency swap (I never encountered this problematic behavior with my v2 sites).
Reproducible demo
https://stackblitz.com/edit/github-cvjzww-1ay5tg?file=docusaurus.config.js
Steps to reproduce
Visit the link to the example repo and try making changes to either the
docusaurus.config.js
orsidebars.js
files as they currently exist (i.e., withmodule.exports
). The changes will not register and hot reloading will fail. It's as if these files are not being watched anymore.Expected behavior
Simple changes to the
docusaurus.config.js
file should be reflected via hot reloading (and they are when not usingmodule.exports
):Similarly, changes to
sidebars.js
should be reflected via hot reloading (and they also are when not usingmodule.exports
):Actual behavior
Simple changes to
docusaurus.config.js
do not register and hot reloading fails whenmodule.exports
is present:The same problem applies to
sidebars.js
:Your environment
See example repo link for complete environment.
Self-service