facebook / facebook/docusaurus
Docusaurus slow on a monorepo site due to globbing node_modules
- Dominant language
- TypeScript
- Stars
- 66.2k
- Forks
- 10k
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 52
Description
### Have you read the Contributing Guidelines on issues?
- [x] I have read the [Contributing Guidelines on issues](https://github.com/facebook/docusaurus/blob/main/CONTRIBUTING.md#issues).
### 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.
- [ ] I have tried creating a repro with https://new.docusaurus.io.
- [x] 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)
```js
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
- [x] I'd be willing to fix this bug myself.
Contributor guide
Assessment
This issue has not been assessed yet.