async-library / react-async

🍾 Flexible promise-based React data loader

Home Page:https://docs.react-async.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

List prop-types under optionalDependencies

Eli-Black-Work opened this issue · comments

react-async uses prop-types if it's available, but it doesn't list it as an optional dependency in its package.json

This means that users see a warning when using Yarn's PnP (Plug and Play) feature:

WARNING in ../.yarn/$$virtual/react-async-virtual-3d2eb0f2b6/0/cache/react-async-npm-10.0.1-4e014b49b8-dd7e80d975.zip/node_modules/react-async/dist-web/index.js 35:14-35
Module not found: Error: Can't resolve 'prop-types' in 'C:\my-project\.yarn\$$virtual\react-async-virtual-3d2eb0f2b6\0\cache\react-async-npm-10.0.1-4e014b49b8-dd7e80d975.zip\node_modules\react-async\dist-web'
 @ ../.yarn/$$virtual/@my-project-virtual-d9fa77a61d/5/my-project/my-file.js 2:0-39 32:20-28

I think that the fix should be for react-async to add prop-types as an optional dependency in its package.json file, like so:

"optionalDependencies": {
   "prop-types": "*"
}

This was previously reported at #115, but that issue is closed, so I'm opening a new one 🙂

As a temporary workaround, users can add the following lines to their .yarmrc.yml file 🙂

# react-async depends on prop-types but doesn't yet list it as an optional dependency, so we see a warning when we compile.
# This fixes that warnings.
#
# Bug report: https://github.com/async-library/react-async/issues/322
packageExtensions:
    react-async@*:
        peerDependencies:
            "prop-types": "*"