web-infra-dev / rspress

πŸ¦€πŸ’¨ A fast Rspack-based static site generator.
https://rspress.dev
MIT License
1.28k stars 114 forks source link

[Feature]: Support latest stable version of Yarn by default #1246

Open o-l-a-v opened 1 month ago

o-l-a-v commented 1 month ago

What problem does this feature solve?

As of writing, the latest version of Yarn is v4.3.1.

Your quickstart says using Yarn is an option:

But Yarn v4.3.1 uses Yarn PnP https://yarnpkg.com/features/pnp for node packages installation strategy by default, which Rspack does not seem to support.

Feature request:

Repro short recipe, using Yarn v4.3.1, everything default

yarn create rspress@latest
cd .\rspress-site\
yarn install
yarn run dev
With output on my system ```powershell PowerShell Core v7.4.3 x64 PS C:\Users\olav.birkeland\Desktop\tes> yarn create rspress@latest ➀ YN0000: Β· Yarn 4.3.1 ➀ YN0000: β”Œ Resolution step ➀ YN0085: β”‚ + create-rspress@npm:1.26.0 ➀ YN0000: β”” Completed ➀ YN0000: β”Œ Fetch step ➀ YN0013: β”‚ A package was added to the project (+ 383.84 KiB). ➀ YN0000: β”” Completed ➀ YN0000: β”Œ Link step ➀ YN0000: β”” Completed ➀ YN0000: Β· Done in 0s 213ms √ Project folder ... rspress-site √ Site Title ... Rspress √ Site Description ... Rspack-based Static Site Generator Done. Now run: cd rspress-site yarn install yarn run dev PS C:\Users\olav.birkeland\Desktop\tes> cd .\rspress-site\ PS C:\Users\olav.birkeland\Desktop\tes\rspress-site> yarn install ! The local project doesn't define a 'packageManager' field. Corepack will now add one referencing yarn@4.3.1+sha512.af78262d7d125afbfeed740602ace8c5e4405cd7f4735c08feb327286b2fdb2390fbca01589bfd1f50b1240548b74806767f5a063c94b67e431aabd0d86f7774. ! For more details about this field, consult the documentation at https://nodejs.org/api/packages.html#packagemanager ➀ YN0000: Β· Yarn 4.3.1 ➀ YN0000: β”Œ Resolution step ➀ YN0085: β”‚ + @types/node@npm:16.18.101, rspress@npm:1.26.0, @babel/runtime@npm:7.24.7, and 479 more. ➀ YN0000: β”” Completed in 1s 943ms ➀ YN0000: β”Œ Post-resolution validation ➀ YN0086: β”‚ Some peer dependencies are incorrectly met by dependencies; run yarn explain peer-requirements for details. ➀ YN0000: β”” Completed ➀ YN0000: β”Œ Fetch step ➀ YN0013: β”‚ A package was added to the project (+ 294.16 KiB). ➀ YN0000: β”” Completed in 0s 215ms ➀ YN0000: β”Œ Link step ➀ YN0000: β”‚ ESM support for PnP uses the experimental loader API and is therefore experimental ➀ YN0007: β”‚ core-js@npm:3.37.1 must be built because it never has been before or the last one failed ➀ YN0000: β”” Completed in 6s 528ms ➀ YN0000: Β· Done with warnings in 8s 770ms PS C:\Users\olav.birkeland\Desktop\tes\rspress-site> yarn run dev πŸ”₯ Rspress v1.26.0 > Network: http://192.168.86.105:3000/ > Network: http://localhost:3000/ > Network: http://172.30.96.1:3000/ start Compiling... error Compile error: Failed to compile, check the errors for troubleshooting. Γ— Resolve error: Can't resolve 'C:\Users\olav.birkeland\AppData\Local\Yarn\Berry\cache\@rsbuild-core-npm-1.0.0-alpha.6-c59c27cadc-10c0.zip\node_modules\@rsbuild\core\dist\client\overlay.js' in 'C:\Users\olav.birkeland\Desktop\tes\rspress-site' Γ— Resolve error: Can't resolve 'C:\Users\olav.birkeland\AppData\Local\Yarn\Berry\cache\@rspress-core-npm-1.26.0-ffa0db03a2-10c0.zip\node_modules\@rspress\core\dist\runtime\clientEntry.js' in 'C:\Users\olav.birkeland\Desktop\tes\rspress-site' Γ— Resolve error: Can't resolve 'C:\Users\olav.birkeland\Desktop\tes\rspress-site\.yarn\__virtual__\@rspack-plugin-react-refresh-virtual-e774b93185\4\AppData\Local\Yarn\Berry\cache\@rspack-plugin-react-refresh-npm-1.0.0-alpha.2-951b047d7e-10c0.zip\node_modules\@rspack\plugin-react-refresh\client\reactRefreshEntry.js' in 'C:\Users\olav.birkeland\Desktop\tes\rspress-site' Γ— Resolve error: Can't resolve 'C:\Users\olav.birkeland\AppData\Local\Yarn\Berry\cache\@rsbuild-core-npm-1.0.0-alpha.6-c59c27cadc-10c0.zip\node_modules\@rsbuild\core\dist\client\hmr.js' in 'C:\Users\olav.birkeland\Desktop\tes\rspress-site' Γ— Error: [html-rspack-plugin]: Child compilation failed: β”‚ Γ— Resolve error: Can't resolve 'C:\Users\olav.birkeland\AppData\Local\Yarn\Berry\cache\@rspress-core-npm-1.26.0-ffa0db03a2-10c0.zip\node_modules\@rspress\core\index.html' in 'C:\Users\olav.birkeland\Desktop\tes\rspress-site' β”‚ β”‚ at C:\Users\olav.birkeland\Desktop\tes\rspress-site\.yarn\__virtual__\html-rspack-plugin-virtual-ad2ec0b608\4\AppData\Local\Yarn\Berry\cache\html-rspack-plugin-npm-6.0.0-beta.3-e2e78ff833-10c0.zip\node_modules\html-rspack-plugin\lib\child-compiler.js:174:18 β”‚ at finalCallback (C:\Users\olav.birkeland\Desktop\tes\rspress-site\.yarn\__virtual__\@rspack-core-virtual-b1014f7446\4\AppData\Local\Yarn\Berry\cache\@rspack-core-npm-1.0.0-alpha.2-a7f9e1c38a-10c0.zip\node_modules\@rspack\core\dist\Compiler.js:348:17) β”‚ at C:\Users\olav.birkeland\Desktop\tes\rspress-site\.yarn\__virtual__\@rspack-core-virtual-b1014f7446\4\AppData\Local\Yarn\Berry\cache\@rspack-core-npm-1.0.0-alpha.2-a7f9e1c38a-10c0.zip\node_modules\@rspack\core\dist\Compiler.js:375:20 β”‚ at C:\Users\olav.birkeland\Desktop\tes\rspress-site\.yarn\__virtual__\@rspack-core-virtual-b1014f7446\4\AppData\Local\Yarn\Berry\cache\@rspack-core-npm-1.0.0-alpha.2-a7f9e1c38a-10c0.zip\node_modules\@rspack\core\dist\Compiler.js:471:28 β”‚ at done (C:\Users\olav.birkeland\AppData\Local\Yarn\Berry\cache\@rspack-lite-tapable-npm-1.0.0-alpha.2-cf220543eb-10c0.zip\node_modules\@rspack\lite-tapable\dist\index.js:478:13) β”‚ at AsyncSeriesHook.callAsyncStageRange (C:\Users\olav.birkeland\AppData\Local\Yarn\Berry\cache\@rspack-lite-tapable-npm-1.0.0-alpha.2-cf220543eb-10c0.zip\node_modules\@rspack\lite-tapable\dist\index.js:485:20) β”‚ at AsyncSeriesHook.callAsync (C:\Users\olav.birkeland\AppData\Local\Yarn\Berry\cache\@rspack-lite-tapable-npm-1.0.0-alpha.2-cf220543eb-10c0.zip\node_modules\@rspack\lite-tapable\dist\index.js:88:21) β”‚ at C:\Users\olav.birkeland\Desktop\tes\rspress-site\.yarn\__virtual__\@rspack-core-virtual-b1014f7446\4\AppData\Local\Yarn\Berry\cache\@rspack-core-npm-1.0.0-alpha.2-a7f9e1c38a-10c0.zip\node_modules\@rspack\core\dist\Compiler.js:467:41 β”‚ at C:\Users\olav.birkeland\Desktop\tes\rspress-site\.yarn\__virtual__\@rspack-core-virtual-b1014f7446\4\AppData\Local\Yarn\Berry\cache\@rspack-core-npm-1.0.0-alpha.2-a7f9e1c38a-10c0.zip\node_modules\@rspack\core\dist\Compiler.js:534:23 PS C:\Users\olav.birkeland\Desktop\tes\rspress-site> ```

What does the proposed API look like?

I have no idea.

chenjiahan commented 1 month ago

Thanks, we can add .yarnrc.yml before Rspack supports PnP. PR welcome πŸ˜„

Related Rspack issue: https://github.com/web-infra-dev/rspack/issues/2236