facebook / facebook/docusaurus
Generate dependency map for sidebar, docusaurus.config, etc. in hot reload
- Lenguaje dominante
- TypeScript
- Estrellas
- 66.2k
- Forks
- 10k
- Merge medio
- 1 d 3 h
- PR fusionados (30 d)
- 52
Descripción
## 🐛 Bug Report
### Prerequisites
- [X] I'm using the latest version of Docusaurus.
- [X] I have tried the `npm run clear` or `yarn clear` command.
- [X] I have tried `rm -rf node_modules yarn.lock package-lock.json` and re-installing packages.
- [X] 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](https://gitlab.com/fluidattacks/product/-/blob/cf751f2b62f08e529dd4a13e694406d03e8f1418/docs/src/sidebar/main.js) file and [imported sidebars for different sections from external js files](https://gitlab.com/fluidattacks/product/-/tree/cf751f2b62f08e529dd4a13e694406d03e8f1418/docs/src/sidebar).
We then [specified main.js as the sidebarPath](https://gitlab.com/fluidattacks/product/-/blob/cf751f2b62f08e529dd4a13e694406d03e8f1418/docs/src/docusaurus.config.js#L117).
The problem with this approach is:
1. Every time that an imported file changes, the dev server does not recognize the change, thus not updating the sidebar accordingly.
1. 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](https://github.com/facebook/docusaurus/blob/master/CONTRIBUTING.md#reporting-new-issues)?
Yes I have.
## Steps to reproduce
1. Use a `main.js` file for your sidebar that imports sub-sidebars from other files like
[here](https://gitlab.com/fluidattacks/product/-/blob/cf751f2b62f08e529dd4a13e694406d03e8f1418/docs/src/sidebar/main.js).
1. Start the development server with `docusaurus start`.
1. Modify one of the imported files.
1. 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:
1. Removing `secondary/two` from `SECONDARY` in `sidebar/secondary.js`.
1. Noticing how nothing changes.
1. Removing `SECONDARY` from `main.js`.
1. Noticing how the sidebar disappears.
1. Adding `SECONDARY` again to `main.js`.
1. Noticing how it adds the version that contains `secondary/one` and `secondary/three`
instead of reloading the file and justadding `secondary/one`
Guía de contribución
Evaluación
Este issue todavía no se ha evaluado.