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

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

Closed
anomiex opened this issue Sep 1, 2023 · 0 comments · Fixed by #54118
Closed

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

anomiex opened this issue Sep 1, 2023 · 0 comments · Fixed by #54118
Assignees
Labels
[Status] In Progress Tracking issues with work in progress

Comments

@anomiex
Copy link
Contributor

anomiex commented Sep 1, 2023

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
anomiex added a commit to anomiex/gutenberg that referenced this issue Sep 1, 2023
Build code transformations can introduce dependencies on packages such
as @wordpress/element and @babel/runtime. These need to be declared if
the package is to function correctly with yarn's p'n'p or pnpm with
hoisting disabled.

- @wordpress/patterns depends on @babel/runtime (fixes WordPress#54115)
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Sep 1, 2023
gziolo pushed a commit that referenced this issue Sep 2, 2023
…54118)

Build code transformations can introduce dependencies on packages such
as @wordpress/element and @babel/runtime. These need to be declared if
the package is to function correctly with yarn's p'n'p or pnpm with
hoisting disabled.

- @wordpress/patterns depends on @babel/runtime (fixes #54115)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Status] In Progress Tracking issues with work in progress
1 participant