The package @wordpress/patterns attempts to use @babel/runtime from build/store/index.js and a few other files, but does not declare a dependency or peer dependency on that package.
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.json
yarn set version stable
yarn add @wordpress/patterns react@^18 react-dom@^18 jsdom global-jsdom
yarn add yjs (to work around a bug in y-webrtc)
yarn node -e 'require( "global-jsdom/register" ); const x = require( "@wordpress/patterns" ); console.log( typeof x );'
With pnpm:
- Create a temporary directory, and cd into it.
echo 'hoist-pattern=[]' > .npmrc
pnpm add @wordpress/patterns global-jsdom (note pnpm 8 defaults to installing peer deps)
pnpm add yjs (to work around a bug in y-webrtc)
node -e 'require( "global-jsdom/register" ); const x = require( "@wordpress/patterns" ); console.log( typeof x );'
Expected behavior
Output along the lines of
Actual behavior
With yarn:
Error: @wordpress/patterns 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/patterns@virtual:dc3fc578bfa5e06182a4d2be39ede0bc5b74940b1ffe0d70c26892ab140a4699787750fba175dc306292e80b4aa2c8c5f68c2a821e69b2c37e360c0dff36ff66#npm:1.2.0 (via /tmp/test/.yarn/__virtual__/@wordpress-patterns-virtual-5df8c0f107/0/cache/@wordpress-patterns-npm-1.2.0-9eb13a7726-413f267854.zip/node_modules/@wordpress/patterns/build/store/)
Require stack:
- /tmp/test/.yarn/__virtual__/@wordpress-patterns-virtual-5df8c0f107/0/cache/@wordpress-patterns-npm-1.2.0-9eb13a7726-413f267854.zip/node_modules/@wordpress/patterns/build/store/index.js
- /tmp/test/.yarn/__virtual__/@wordpress-patterns-virtual-5df8c0f107/0/cache/@wordpress-patterns-npm-1.2.0-9eb13a7726-413f267854.zip/node_modules/@wordpress/patterns/build/index.js
With pnpm:
Error: Cannot find module '@babel/runtime/helpers/interopRequireDefault'
Require stack:
- /tmp/test/node_modules/.pnpm/@wordpress+patterns@1.2.0_react-dom@18.2.0_react@18.2.0/node_modules/@wordpress/patterns/build/store/index.js
- /tmp/test/node_modules/.pnpm/@wordpress+patterns@1.2.0_react-dom@18.2.0_react@18.2.0/node_modules/@wordpress/patterns/build/index.js
The package
@wordpress/patternsattempts to use@babel/runtimefrombuild/store/index.jsand a few other files, but does not declare a dependency or peer dependency on that package.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:
echo '{}' > package.jsonyarn set version stableyarn add @wordpress/patterns react@^18 react-dom@^18 jsdom global-jsdomyarn add yjs(to work around a bug in y-webrtc)yarn node -e 'require( "global-jsdom/register" ); const x = require( "@wordpress/patterns" ); console.log( typeof x );'With pnpm:
echo 'hoist-pattern=[]' > .npmrcpnpm add @wordpress/patterns global-jsdom(note pnpm 8 defaults to installing peer deps)pnpm add yjs(to work around a bug in y-webrtc)node -e 'require( "global-jsdom/register" ); const x = require( "@wordpress/patterns" ); console.log( typeof x );'Expected behavior
Output along the lines of
Actual behavior
With yarn:
With pnpm: