easyops-cn / docusaurus-search-local

Offline/local search for Docusaurus v2/v3
https://easyops-cn.github.io/docusaurus-search-local/
MIT License
712 stars 90 forks source link

Upgrade Docusaurus - Enable Docusaurus Faster on website #468

Open slorber opened 2 weeks ago

slorber commented 2 weeks ago

Docusaurus maintainer here 👋

This is a POC to ensure this plugin is compatible with Docusaurus Faster

I'm not sure how your setup works exactly, not super familiar with Yarn PnP but got some annoying errors due to it 😅

I'm able to build with Webpack, but Rspack fails with this error I can't solve when PnP is enabled:

[ERROR] Client bundle compiled with errors therefore further build is impossible. × Module not found: Can't resolve '/Users/sebastienlorber/Desktop/projects/docusaurus-search-local-easyops-cn/.yarn/virtual/@docusaurus-core-virtual-aaf120fccf/0/cache/@docusaurus-core-npm-3.5.2-canary-6122-e777a73518-b778e9de54.zip/node_modules/@docusaurus/core/lib/client/clientEntry.js' in '/Users/sebastienlorber/Desktop/projects/docusaurus-search-local-easyops-cn/website'

And idea?

Benchmark

Using node modules linker

Cold builds - much faster

hyperfine --prepare 'yarn workspace website clear' --runs 3 'DOCUSAURUS_FASTER=false yarn build:website' 'DOCUSAURUS_FASTER=true yarn build:website'

Benchmark 1: DOCUSAURUS_FASTER=false yarn build:website
  Time (mean ± σ):     11.864 s ±  0.251 s    [User: 19.999 s, System: 5.471 s]
  Range (min … max):   11.609 s … 12.110 s    3 runs

Benchmark 2: DOCUSAURUS_FASTER=true yarn build:website
  Time (mean ± σ):      3.139 s ±  0.050 s    [User: 4.666 s, System: 0.862 s]
  Range (min … max):    3.106 s …  3.196 s    3 runs

Summary
  DOCUSAURUS_FASTER=true yarn build:website ran
    3.78 ± 0.10 times faster than DOCUSAURUS_FASTER=false yarn build:website

Warm builds - same:

DOCUSAURUS_FASTER=false yarn build:website
hyperfine --runs 3 'DOCUSAURUS_FASTER=false yarn build:website' 'DOCUSAURUS_FASTER=true yarn build:website'

Benchmark 1: DOCUSAURUS_FASTER=false yarn build:website
  Time (mean ± σ):      3.031 s ±  0.066 s    [User: 3.602 s, System: 0.539 s]
  Range (min … max):    2.990 s …  3.107 s    3 runs

  Warning: The first benchmarking run for this command was significantly slower than the rest (3.107 s). This could be caused by (filesystem) caches that were not filled until after the first run. You should consider using the '--warmup' option to fill those caches before the actual benchmark. Alternatively, use the '--prepare' option to clear the caches before each timing run.

Benchmark 2: DOCUSAURUS_FASTER=true yarn build:website
  Time (mean ± σ):      3.120 s ±  0.084 s    [User: 4.671 s, System: 0.859 s]
  Range (min … max):    3.065 s …  3.217 s    3 runs

Summary
  DOCUSAURUS_FASTER=false yarn build:website ran
    1.03 ± 0.04 times faster than DOCUSAURUS_FASTER=true yarn build:website

Summary by CodeRabbit

coderabbitai[bot] commented 2 weeks ago

Walkthrough

This pull request includes updates to several configuration files in the project. The .gitignore file now excludes the .idea directory. The .yarnrc.yml file has been modified to include a new property for package linking and an extension for specific Docusaurus packages. The package.json files for both the main project and the website have updated Docusaurus package versions from 3.0.0 to 3.6.0, with additional scripts and dependencies added in the website's configuration. New experimental features are introduced in the Docusaurus configuration for both the main project and the multi-docs setup.

Changes

File Change Summary
.gitignore - Added entry for .idea to be ignored by Git.
.yarnrc.yml - Added property nodeLinker: node-modules.
- Introduced section packageExtensions for @docusaurus/bundler, @docusaurus/theme-common, terser-webpack-plugin, and css-minimizer-webpack-plugin with respective dependencies.
package.json - Updated resolutions for several Docusaurus packages from 3.0.0 to 3.6.0:
@docusaurus/core, @docusaurus/module-type-aliases, @docusaurus/preset-classic, @docusaurus/theme-classic, @docusaurus/theme-common, @docusaurus/plugin-content-docs.
website/docusaurus.config.js - Added configuration option: future: { experimental_faster: { swcJsLoader: true, swcJsMinimizer: true, swcHtmlMinimizer: true, lightningCssMinimizer: true, rspackBundler: false, mdxCrossCompilerCache: true } }.
website/package.json - Added script "clear": "docusaurus clear".
- Updated dependency versions for @docusaurus/core, @docusaurus/preset-classic, @docusaurus/theme-classic, and @docusaurus/theme-common from ^3.0.0 to 3.6.0.
- Added new dependency @docusaurus/faster with version 3.6.0.
website-multi-docs/docusaurus.config.js - Added configuration section: future: { experimental_faster: { swcJsLoader: true, swcJsMinimizer: true, swcHtmlMinimizer: true, lightningCssMinimizer: true, rspackBundler: false, mdxCrossCompilerCache: true } }.
website-multi-docs/package.json - Updated dependency versions for @docusaurus/core, @docusaurus/plugin-content-docs, @docusaurus/preset-classic, @docusaurus/theme-classic, @docusaurus/theme-common from ^3.0.0 to 3.6.0.
- Added new dependency @docusaurus/faster with version 3.6.0.
website/babel.config.js - Removed Babel configuration file.
website-multi-docs/babel.config.js - Removed Babel configuration file.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
🪧 Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit , please review it.` - `Generate unit testing code for this file.` - `Open a follow-up GitHub issue for this discussion.` - Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples: - `@coderabbitai generate unit testing code for this file.` - `@coderabbitai modularize this function.` - PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples: - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.` - `@coderabbitai read src/utils.ts and generate unit testing code.` - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.` - `@coderabbitai help me debug CodeRabbit configuration file.` Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. ### CodeRabbit Commands (Invoked using PR comments) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai full review` to do a full review from scratch and review all the files again. - `@coderabbitai summary` to regenerate the summary of the PR. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository. - `@coderabbitai help` to get help. ### Other keywords and placeholders - Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. - Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description. - Add `@coderabbitai` anywhere in the PR title to generate the title automatically. ### CodeRabbit Configuration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information. - If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json` ### Documentation and Community - Visit our [Documentation](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.
netlify[bot] commented 2 weeks ago

Deploy Preview for easyops-cn-docusaurus-search-local failed.

Name Link
Latest commit ac4af80991f35a6d7d01a72f4beae3577d8ce4cf
Latest deploy log https://app.netlify.com/sites/easyops-cn-docusaurus-search-local/deploys/6728d06a98ae3b00084c4d09
weareoutman commented 2 weeks ago

👍 Great work!

I got no idea why it doesn't work with yarn PnP, either. Though using node modules linker works, right? Maybe related to dependencies with canary versions.

slorber commented 2 weeks ago

I'll try again once v3.6 is out and we'll see

For now it's already nice to have a POC proving that this plugin works with the new bundler :)

slorber commented 1 week ago

Docusaurus v3.6 is out: https://docusaurus.io/blog/releases/3.6

PR ready to review (but still fighting with PnP issues)

Unfortunately, the Yarn PnP error remains, and it only builds with node linker. Maybe @arcanis any idea what could cause this error?

[ERROR] Client bundle compiled with errors therefore further build is impossible.
× Module not found: Can't resolve '/Users/sebastienlorber/Desktop/projects/docusaurus-search-local-easyops-cn/.yarn/__virtual__/@docusaurus-core-virtual-22c3351990/0/cache/@docusaurus-core-npm-3.6.0-794aa300d6-d024957005.zip/node_modules/@docusaurus/core/lib/client/clientEntry.js' in '/Users/sebastienlorber/Desktop/projects/docusaurus-search-local-easyops-cn/website'

Edit, it seems using rspackBundler: false fix that error, and there's a related Rspack issue: https://github.com/web-infra-dev/rspack/issues/2236