fix(plugin-content-docs): ignore node_modules and dist when globbing category metadata - #12451
Conversation
…category metadata Fixes facebook#12128. When discovering category metadata files (_category_.{json,yml,yaml}), readCategoriesMetadata was not ignoring node_modules or dist folders. In monorepos with package-level node_modules symlinks or build output, this resulted in excessive file scanning and severe startup slowdowns (from ~34s to <1s). This adds '**/node_modules/**' and '**/dist/**' to the Globby ignore option and adds a regression test ensuring category files in those directories are skipped.
|
Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
✅ [V2]Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Motivation
Fixes #12128.
When discovering category metadata files (
**/_category_.{json,yml,yaml}),readCategoriesMetadatacalledGlobbywith onlycwd: contentPath. On monorepo sites with nestednode_modules(e.g. symlinked or per-package dependencies) or build output folders likedist/,Globbyscanned the entirety of these subdirectories. In reported monorepos, this caused Docusaurus startup times to degrade from sub-second to over 34 seconds.Solution
Add
ignore: ['**/node_modules/**', '**/dist/**']to theGlobbyconfiguration inreadCategoriesMetadata.Test Plan
packages/docusaurus-plugin-content-docs/src/sidebars/__tests__/index.test.tsverifying category metadata files located insidenode_modulesanddistdirectories are properly ignored during sidebar category discovery.