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

(Yarn PnP) Add react-transition-group as optional peer dependency #2346

Closed
blutorange opened this issue Oct 13, 2021 · 2 comments · Fixed by #2351
Closed

(Yarn PnP) Add react-transition-group as optional peer dependency #2346

blutorange opened this issue Oct 13, 2021 · 2 comments · Fixed by #2351
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Milestone

Comments

@blutorange
Copy link

When using Yarn PnP with e.g. webpack it results in an error because primereact attempts to import react-transition-group, but does not declare it in its dependencies. Yarn PnP requires that a package explicitly declares all packages it uses.

When it should not be a normal dependency, it needs to be declared as an optional peer dependency in the package.json:

{
  "peerDependencies": {
    "react-transition-group": "^4.4.1"
  },
  "peerDependenciesMeta": {
    "react-transition-group": {
      "optional": true
    }
  }
}

For reference, this is the kind of error yarn produces otherwise:

ERROR in ../../.yarn/__virtual__/primereact-virtual-f9a9246cfb/6/.yarn/berry/cache/primereact-npm-6.6.0-aedbba0e88-8.zip/node_modules/primereact/core/core.esm.js 4:0-74
Module not found: Error: Can't resolve 'react-transition-group' in '/home/user/git/xxx/src/main/web/.yarn/__virtual__/primereact-virtual-f9a9246cfb/6/.yarn/berry/cache/primereact-npm-6.6.0-aedbba0e88-8.zip/node_modules/primereact/core'
resolve 'react-transition-group' in '/home/user/git/xxx/src/main/web/.yarn/__virtual__/primereact-virtual-f9a9246cfb/6/.yarn/berry/cache/primereact-npm-6.6.0-aedbba0e88-8.zip/node_modules/primereact/core'
  Parsed request is a module
  using description file: /home/user/git/xxx/src/main/web/.yarn/__virtual__/primereact-virtual-f9a9246cfb/6/.yarn/berry/cache/primereact-npm-6.6.0-aedbba0e88-8.zip/node_modules/primereact/core/package.json (relative path: .)
    Field 'browser' doesn't contain a valid alias configuration
    resolve as module
      request is not managed by the pnpapi
        primereact tried to access react-transition-group, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
        Required package: react-transition-group
        Required by: primereact@virtual:b16796768ff87ddbece8b5bfc2039947cf3d8f163bc361bdb6f4a0bde13eb62e363041c182c4733efb250df91f2786b239ed15e45ee9b2a3a3c47ac3fd60a649#npm:6.6.0::__archiveUrl=https%3A%2F%2Fartifactory.xima-services.de%3A443%2Fartifactory%2Fapi%2Fnpm%2Fnpm-fs%2Fprimereact%2F-%2Fprimereact-6.6.0.tgz (via /home/user/git/xxx/src/main/web/.yarn/__virtual__/primereact-virtual-f9a9246cfb/6/.yarn/berry/cache/primereact-npm-6.6.0-aedbba0e88-8.zip/node_modules/primereact/core/)
 @ ../../.yarn/__virtual__/primereact-virtual-f9a9246cfb/6/.yarn/berry/cache/primereact-npm-6.6.0-aedbba0e88-8.zip/node_modules/primereact/inputtext/inputtext.esm.js 2:0-86 160:8-28 169:26-44 177:43-62 177:94-116 222:21-24 231:22-32 235:23-47
 @ ./src/script/components/form-store-header.tsx 4:0-49 7:78-87
 @ ./src/script/components/form-store.tsx 4:0-54 10:151-166
 @ ./src/script/render.ts 4:0-52 27:25-34
 @ ./src/index.ts 21:0-32 21:0-32
melloware added a commit to melloware/primereact that referenced this issue Oct 16, 2021
@melloware
Copy link
Member

Can you review my PR I submitted please?

@blutorange
Copy link
Author

@melloware Yes, that looks fine to me. This should make yarn happy.

@mertsincan mertsincan added the Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add label Nov 3, 2021
@mertsincan mertsincan added this to the 7.0.0.Final milestone Nov 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants