react-grid-layout / react-resizable

A simple React component that is resizable with a handle.
https://strml.github.io/react-resizable/examples/1.html
MIT License
2.43k stars 366 forks source link

Yarn PnP webpack `react-dom` dependency issue #181

Open peterhirn opened 3 years ago

peterhirn commented 3 years ago

Thanks for opening an issue!

Please select the type of issue you're reporting. For questions.

Problem Report

Dependency on react-dom broken. Probably related to https://github.com/react-grid-layout/react-draggable/pull/525

yarn install

react-resizable@npm:3.0.4 [65850] doesn't provide react-dom (p951c8), requested by react-draggable

webpack

ERROR in ../../.yarn/__virtual__/react-draggable-virtual-79cbb65d2e/0/cache/react-draggable-npm-4.4.4-f0b7a5c546-b8258a5893.zip/node_modules/react-draggable/build/cjs/DraggableCore.js 14:39-59        
Module not found: Error: react-draggable tried to access react-dom (a peer dependency) but it isn't provided by its ancestors; this makes the require call ambiguous and unsound.

Workaround

Add to .yarnrc.yml

packageExtensions:
  react-resizable@*:
    peerDependencies:
      react-dom: "*"

Then run yarn install.

Poolshark commented 2 years ago

Same problem here. The workaround did not work for me. Just to be clear, my problem was react-draggable and not react-resizable! Further more, it seems like peerDependencies are not supported with @yarn v3.2.0.

My fix for the

Module not found: Error: react-draggable tried to access react-dom (a peer dependency) but it isn't provided by its ancestors; this makes the require call ambiguous and unsound.

error is:

packageExtensions:
  "react-draggable@*":
      dependencies:
        "react-dom": "*"

in the yarnrc.yml.

I hope this "hacks" don't become standard when working with Yarn > 1...