Hot reloading doesn't work when using module.exports
for docusaurus.config.js
and/or sidebars.js
#9698
Open
6 of 7 tasks
Labels
bug
An error in the Docusaurus core causing instability or issues with its execution
status: needs triage
This issue has not been triaged by maintainers
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
The text was updated successfully, but these errors were encountered: