Skip to content

Docusaurus slow on a monorepo site due to globbing node_modules #12128

Description

@hariabinesh-l-4219

Have you read the Contributing Guidelines on issues?

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.
  • I have read the console error message carefully (if applicable).

Description

The issue seems to be globby scanning all node_modules folders which was the main reason for slowness.

Before fixing log:
[PERF] CLI start > Load site > Load plugins > Load plugins content > Load docs@default > contentLoaded() - 39.57 ms - (Heap 115mb -> 117mb / Total 272mb)
[PERF] CLI start > Load site > Load plugins > Load plugins content > Load docs@default - 34.38 seconds! - (Heap 87mb -> 117mb / Total 272mb)

After fixing:
[PERF] CLI start > Load site > Load plugins > Load plugins content > Load docs@default > contentLoaded() - 41.76 ms - (Heap 101mb -> 104mb / Total 222mb)
[PERF] CLI start > Load site > Load plugins > Load plugins content > Load docs@default - 329.71 ms - (Heap 94mb -> 104mb / Total 222mb)
[PERF] CLI start > Load site > Load plugins > Load plugins content - 329.90 ms - (Heap 94mb -> 104mb / Total 222mb)

async function readCategoriesMetadata(contentPath) {
    const categoryFiles = await (0, utils_1.Globby)('**/_category_.{json,yml,yaml}', {
        cwd: contentPath,
        ignore: ['**/node_modules/**', '**/dist/**'], --> fix
    });

Need to add ignore to globby to fix the slowness

Reproducible demo

No response

Steps to reproduce

Have a monorepo with node_modules linked to each packages.

Expected behavior

Docusaurus should start within seconds.

Actual behavior

Docusaurus is very slow to start

Your environment

  • Public source code:
  • Public site URL:
  • Docusaurus version used:
  • Environment name and version (e.g. Chrome 89, Node.js 16.4):
  • Operating system and version (e.g. Ubuntu 20.04.2 LTS):

Self-service

  • I'd be willing to fix this bug myself.

Activity

  1. added
    bugAn error in the Docusaurus core causing instability or issues with its execution
    status: needs triageThis issue has not been triaged by maintainers
    on Jun 9, 2026
  2. beanscg commented on Jun 9, 2026

    @beanscg
  3. slorber commented on Jun 12, 2026

    @slorber
    Collaborator

    Have a monorepo with node_modules linked to each package.

    Could you please tell us more, giving an example tree of what your monorepo looks like? I'd like to understand better before applying a fix.

  4. changed the title [-]Docusaurus is too slow on a monorepo site[/-] on Jun 12, 2026
  5. hariabinesh-l-4219 commented on Jun 15, 2026

    @hariabinesh-l-4219
    Author

    @slorber

    Our MonoRepo consists of below pnpm-workspace.yaml config.

    hoist: true
    hoistWorkspacePackages: true
    linkWorkspacePackages: deep

    |packages
    |--buttons
    |----node_modules
    |------icons-svg
    |--------1k+ files
    |--icons-svg
    |----1k+files though symlinked
    |--accordion
    |----node_modules
    |------icons-svg
    |--------1k+ files
    |------buttons
    |--------button files again

    We have around 180+ packages. Some packages like svg icons have around 1k+ files ( individual tsx files ). Since linked deeply, majority of packages will be dependencies of other packages.

  6. Lokesh2704soni commented on Jul 13, 2026

    @Lokesh2704soni
  7. slorber commented on Jul 16, 2026

    @slorber
    Collaborator

    It's still not clear enough to me. I see a monorepo with packages in it, but I don't see:

    • where your site lives
    • where are the docs files
    • how are the plugin configured, scanning which paths?

    Your original issue only mentions the readCategoriesMetadata() docs plugin function.
    But wouldn't you also need to prevent the plugins from scanning node_modules searching for md/mdx files?

    Are you using the existing plugin's excludes options? Would it work if we wired that exclude option to the readCategoriesMetadata() globbing?

  8. Jashvanthan commented on Sep 29, 2026

    @Jashvanthan

    Hi maintainers,

    I’d like to investigate this performance issue and contribute a fix.

    I understand that Docusaurus can become significantly slower on monorepo sites because globbing operations can scan node_modules unnecessarily.

    I’d like to reproduce the performance issue, identify the relevant globbing calls, and evaluate whether adding targeted ignore patterns or narrowing the search scope can eliminate unnecessary filesystem traversal without changing the expected behavior.

    I’ll also add regression/performance coverage where appropriate and keep the change scoped to the affected code path.

    Could you please confirm the preferred implementation direction before I start?

    Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAn error in the Docusaurus core causing instability or issues with its execution

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions