Skip to content

@wordpress/patterns is missing a dependency on @babel/runtime #54115

@anomiex

Description

@anomiex

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:

  1. Create a temporary directory, and cd into it.
  2. echo '{}' > package.json
  3. yarn set version stable
  4. yarn add @wordpress/patterns react@^18 react-dom@^18 jsdom global-jsdom
  5. yarn add yjs (to work around a bug in y-webrtc)
  6. yarn node -e 'require( "global-jsdom/register" ); const x = require( "@wordpress/patterns" ); console.log( typeof x );'

With pnpm:

  1. Create a temporary directory, and cd into it.
  2. echo 'hoist-pattern=[]' > .npmrc
  3. pnpm add @wordpress/patterns global-jsdom (note pnpm 8 defaults to installing peer deps)
  4. pnpm add yjs (to work around a bug in y-webrtc)
  5. node -e 'require( "global-jsdom/register" ); const x = require( "@wordpress/patterns" ); console.log( typeof x );'

Expected behavior

Output along the lines of

object

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

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions