Skip to content

Generate dependency map for sidebar, docusaurus.config, etc. in hot reload #5039

Open
@dsalaza4

Description

@dsalaza4

🐛 Bug Report

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn 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:

  1. Every time that an imported file changes, the dev server does not recognize the change, thus not updating the sidebar accordingly.
  2. 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

  1. Use a main.js file for your sidebar that imports sub-sidebars from other files like
    here.
  2. Start the development server with docusaurus start.
  3. Modify one of the imported files.
  4. 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

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.
  2. Noticing how nothing changes.
  3. Removing SECONDARY from main.js.
  4. Noticing how the sidebar disappears.
  5. Adding SECONDARY again to main.js.
  6. Noticing how it adds the version that contains secondary/one and secondary/three
    instead of reloading the file and justadding secondary/one

Metadata

Metadata

Assignees

No one assigned

    Labels

    difficulty: advancedIssues that are complex, e.g. large scoping for long-term maintainability.domain: dxRelated to developer experience of working on Docusaurus sitesproposalThis issue is a proposal, usually non-trivial change

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions