Repository navigation
Conversation
|
Deploy preview for docusaurus-2 ready! Built with commit 4943ae2 |
|
Can we cut a new I'm using |
@pranaygp I tested on my local machine with various docusaurus packages unplugged and with my changes manually applied, and it can run in pnp loose mode. However I do not control the release process. |
|
We'll cut a new release within the next few days. |
|
@SamChou19815 I followed the instructions on your repo and it worked like a charm. It's rather annoying to have to use pnpify (I haven't needed it for anything else so far) but I'm glad it works for now |
|
@SamChou19815 would the previous plugin import syntax still work at all? If not we will have to update the docs asap to prevent more reports like #2825. I'm wondering whether we should change the default template's |
Managed to reproduce. Working on a fix. |
Ahh I forgot about that. Thanks for the reminder.
Got it, thank you! |
Motivation
Issue #2576 shows that docusaurus v2 doesn't work with Yarn v2 with pnp enabled.
This diff doesn't try to resolve the issue of the plugin system caused by the incompatibility: it can be solved by using the pnpLoose mode for now. Instead, it will fix some of the webpack plugin loading issue related to yarn pnp.
Inside the webpack config file, it refers to presets and plugins by strings, like
'@babel/plugin-transform-runtime'. This setup happens to work with the traditional package managers' behavior onnode_modules, which tries to hoist@babel/plugin-transform-runtimeto the top-levelnode_modulesif it can. However, it won't work under pnp, which expects that all dependencies are explictly declared.In this case, since it's declared in a string form, it's webpack instead of
@docusaurus/corethat will resolve this module to an absolute path. Sincewebpackdoesn't declare@babel/plugin-transform-runtimeas dependency, the resolution failed. By usingrequire.resolve, we ensure that@docusaurus/corewill resolve the path. Since@docusaurus/coredeclared@babel/plugin-transform-runtimeas a dependency, the resolution will succeed and results in a correct absolute path for webpack to consume.Have you read the Contributing Guidelines on pull requests?
Yes
Test Plan
(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work. Bonus points for screenshots and videos!)
I have setup a repo to show that these are the minimal changes necessary to make docusaurus work under
pnpMode: loose.Also, all the tests still passes and deploy preview still works.
Related PRs
(If this PR adds or changes functionality, please take some time to update the docs at https://github.com/facebook/docusaurus, and link to your PR here.)