-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Closed
Labels
[Feature] MediaAnything that impacts the experience of managing mediaAnything that impacts the experience of managing media[Status] In ProgressTracking issues with work in progressTracking issues with work in progress[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intended
Description
The package @wordpress/upload-media attempts to use @babel/runtime from ./build/index.js, build/store/index.js, and ./build/components/provider/index.js, but does not declare a dependency or peer dependency on that package.
It also attempts to use react from ./build-module/components/provider/index.js, ./build/components/provider/index.js, and a few other files, but does not declare a dependency or peer dependency on that package either.
This happens to work with npm's hoisting due to other dependencies pulling that package in, but will fail with yarn's p'n'p or pnpm with hoisting disabled.
Reproduction
With yarn:
- Create a temporary directory, and cd into it.
echo '{}' > package.jsonyarn set version stableyarn add @wordpress/upload-media react@^18 react-dom@^18yarn node -e 'const x = require( "@wordpress/upload-media" ); console.log( typeof x );'
With pnpm:
- Create a temporary directory, and cd into it.
echo 'hoist-pattern=[]' > .npmrcpnpm add @wordpress/upload-media(note pnpm defaults to installing peer deps)node -e 'const x = require( "@wordpress/upload-media" ); console.log( typeof x );'
Expected behavior
Output along the lines of
object
Actual behavior
With yarn:
Error: @wordpress/upload-media tried to access @babel/runtime, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
Required package: @babel/runtime (via "@babel/runtime/helpers/interopRequireDefault")
Required by: @wordpress/upload-media@npm:0.1.0 (via /home/brad/.yarn/berry/cache/@wordpress-upload-media-npm-0.1.0-b86497bcf7-10c0.zip/node_modules/@wordpress/upload-media/build/)
Require stack:
- /home/brad/.yarn/berry/cache/@wordpress-upload-media-npm-0.1.0-b86497bcf7-10c0.zip/node_modules/@wordpress/upload-media/build/index.js
- /tmp/test/[eval]
With pnpm:
Error: Cannot find module '@babel/runtime/helpers/interopRequireDefault'
Require stack:
- /tmp/test/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]_react-dom@18._5ilcwks4ynxyxsosgzuhvejga4/node_modules/@wordpress/upload-media/build/index.js
- /tmp/test/[eval]
Metadata
Metadata
Assignees
Labels
[Feature] MediaAnything that impacts the experience of managing mediaAnything that impacts the experience of managing media[Status] In ProgressTracking issues with work in progressTracking issues with work in progress[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intended