Open
Description
🐛 Bug Report
Prerequisites
- I'm using the latest version of Docusaurus.
- I have tried the
npm run clear
oryarn clear
command. - I have tried
rm -rf node_modules yarn.lock package-lock.json
and re-installing packages. - I have tried creating a repro with https://new.docusaurus.io
Description
In order to avoid having a huge sidebar.js
file,
we created a
main.js file and imported sidebars for different sections from external js files.
We then specified main.js as the sidebarPath.
The problem with this approach is:
- Every time that an imported file changes, the dev server does not recognize the change, thus not updating the sidebar accordingly.
- Even if the
main.js
file changes, it looks like it is caching the imported variables from the other files, which also prevents the update.
Have you read the Contributing Guidelines on issues?
Yes I have.
Steps to reproduce
- Use a
main.js
file for your sidebar that imports sub-sidebars from other files like
here. - Start the development server with
docusaurus start
. - Modify one of the imported files.
- Notice how the dev server does not see the change.
Expected behavior
Docusaurus should be able to notice which files are being imported
by main.js
and update its sidebar accordingly
Actual behavior
Docusaurus only updates if main.js
changes,
and even if it does change,
imported variables from other files are not updated.
Your environment
- Public source code: https://gitlab.com/fluidattacks/product/-/tree/master/docs/src
- Public site URL: https://docs.fluidattacks.com/
- Docusaurus version used:
2.0.0-beta.0
- Environment name and version (e.g. Chrome 78.0.3904.108, Node.js 10.17.0): N/A
- Operating system and version (e.g. Ubuntu 20.04.2 LTS): N/A
Reproducible demo
https://codesandbox.io/s/competent-sun-t28ho?file=/sidebar/secondary.js
You can try:
- Removing
secondary/two
fromSECONDARY
insidebar/secondary.js
. - Noticing how nothing changes.
- Removing
SECONDARY
frommain.js
. - Noticing how the sidebar disappears.
- Adding
SECONDARY
again tomain.js
. - Noticing how it adds the version that contains
secondary/one
andsecondary/three
instead of reloading the file and justaddingsecondary/one