Skip to content

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

Closed

Description

@RDIL

🐛 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

Activity

  1. added
    bug
    status: needs triage
    on May 12, 2021
  2. slorber commented on May 12, 2021

    @slorber
    Collaborator

    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

  3. HazyFish commented on Jul 16, 2021

    @HazyFish

    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 }
    
  4. slorber commented on Jul 16, 2021

    @slorber
    Collaborator

    @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

  5. removed
    status: needs triage
    on Oct 30, 2021
  6. hhaoao commented on Nov 14, 2021

    @hhaoao

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions