Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[webpack 5] Yarn v2 can't resolve file loader in docs plugin #4778

Closed
RDIL opened this issue May 12, 2021 · 4 comments · Fixed by #6047 · May be fixed by #4708
Closed

[webpack 5] Yarn v2 can't resolve file loader in docs plugin #4778

RDIL opened this issue May 12, 2021 · 4 comments · Fixed by #6047 · May be fixed by #4708
Labels
bug An error in the Docusaurus core causing instability or issues with its execution

Comments

@RDIL
Copy link
Contributor

RDIL commented May 12, 2021

🐛 Bug Report

On webpack 5, Yarn 2 can't resolve file-loader when building docs.

Have you read the Contributing Guidelines on issues?

Yes

To Reproduce

Clone https://github.com/rdilweb/rdil.rocks and update the Docusaurus version in the /docs project - then yarn && yarn build.

Expected behavior

Build passes.

Actual Behavior

file-loader not found error.

Your Environment

Reproducible Demo

https://github.com/rdilweb/rdil.rocks

@RDIL RDIL added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels May 12, 2021
@slorber
Copy link
Collaborator

slorber commented May 12, 2021

It's something I noticed during the Webpack 5 PR.

Our Yarn2 e2e test did not use the latest version of Docusaurus.
After I fixed it, Yarn2 failed due to this missing file-loader.
As a temporary solution, added the file-loader to the init template sites so it can build on Yarn2.

This should be fixed once we migrate to the new assets system: #4708

@HazyFish
Copy link

HazyFish commented Jul 16, 2021

Any update on this? The PR has been inactive for 2 months now. The temporary solution doesn't work although I have file-loader and url-loader as dependencies.

Module not found: Error: Can't resolve 'url' in '.yarn\$$virtual\@docusaurus-core-virtual-ee257a6165\0\cache\@docusaurus-core-npm-2.0.0-beta.3-e31061f4c9-86b35725e9.zip\node_modules\@docusaurus\core\lib\webpack\react-dev-utils-webpack5'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "url": require.resolve("url/") }'
        - install 'url'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "url": false }

@slorber
Copy link
Collaborator

slorber commented Jul 16, 2021

@HazyFish this PR is stuck until I figure out a proper way to solve this problem: webpack/webpack#12900 (comment)
(any help welcome)

Your issue does not look related to Yarn2/file-loader/url-loader but more about Webpack not polyfilling nodejs modules anymore.
https://blog.sindresorhus.com/webpack-5-headache-b6ac24973bf1

You can add the missing polyfills yourself if you need to: create a local docusaurus plugin that modify the existing Webpack configuration to add that polyfill

@Josh-Cena Josh-Cena removed the status: needs triage This issue has not been triaged by maintainers label Oct 30, 2021
@hhaoao
Copy link

hhaoao commented Nov 14, 2021

oh, Is there any progress on this issue?
I installed these two missing packages and it works fine.

testing-library/testing-library-docs#928

pnpm add url-loader @mdx-js/react

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution
Projects
None yet
5 participants