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

bug: missing @babel/runtime dependency in yarn modern with pnp linker #2218

Closed
imccausl opened this issue Dec 16, 2023 · 3 comments · Fixed by #2219
Closed

bug: missing @babel/runtime dependency in yarn modern with pnp linker #2218

imccausl opened this issue Dec 16, 2023 · 3 comments · Fixed by #2219
Labels
bug Something isn't working released status:confirmed Described issue has been reproduced by the repo maintainer

Comments

@imccausl
Copy link
Contributor

Describe the bug

In yarn modern (version 2+) with the pnp linker, tests and build fails because helpers provided by @babel/runtime are missing. I believe @babel/runtime gets hoisted from another dependency (possibly aria-query according to yarn why @babel/runtime) in regular npm/yarn v1 so it seems to work. Yarn modern is more strict with dependency resolution, so I see failures after importing stream-chat-react components into a project and trying to run tests or build.

While I can also fix this by providing @babel/runtime myself, I don't think this is the "correct" solution. Rather, the solution should be to include @babel/runtime as a dependency in this project. From what I can tell, this is what is recommended when using @babel/plugin-transform-runtime according to the babel docs (unless I am misinterpreting what is written there, but I see a lot of other libraries that supply their own versions of @babel/runtime). See the the "technical details" section of babel-plugin-transform-runtime (https://babeljs.io/docs/babel-plugin-transform-runtime#technical-details):

Make sure you include @babel/runtime as a dependency.

I am happy to submit a PR to fix this issue. And would love to hear your thoughts!

To Reproduce

I've created a bug repro repo here: https://github.com/imccausl/stream-chat-react-yarn-modern-bug-repro-repo

Steps to reproduce the behaviour:

  1. Clone the project (https://github.com/imccausl/stream-chat-react-yarn-modern-bug-repro-repo)
  2. install the project nvm use && yarn install (uses yarn v4 with the pnp linker)
  3. yarn build to "build" the project with babel and webpack. You'll get an error: Can't resolve '@babel/runtime/helpers/defineProperty
  4. yarn test to run tests (transpiled with babel). You'll get an error: Cannot find module '@babel/runtime/helpers/extends'
  5. Clone (if necessary) and link the local stream-chat-react repo with yarn link /path/to/stream-chat-react (replacing /path/to with the correct path to your local stream-chat-react repo).
  6. In the local stream-chat-react repo, yarn add @babel/runtime (@babel/runtime should be a direct dependency not a dev dependency)
  7. Running yarn test or yarn build in the stream-chat-react-yarn-modern-bug-repro-repo will now work.

Expected behaviour

I expect that the required @babel/runtime helpers are provided by the 3rd party library I'm using so that my test and build don't fail. I shouldn't have to provide this in my project if I'm not using @babel/plugin-transform-runtime` for any of my own transpiled code.

Screenshots

N/A

Package version

  • stream-chat-react: 11.1.2
  • stream-chat-css: n/a
  • stream-chat-js: n/a

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context

Add any other context about the problem here.

@arnautov-anton
Copy link
Contributor

Hey, @imccausl, thank you for the detailed issue report (and the PR), we really appreciate it! Let us take a look at it and we'll get back to you ASAP. :)

@arnautov-anton arnautov-anton added status:confirmed Described issue has been reproduced by the repo maintainer and removed status: unconfirmed labels Dec 21, 2023
arnautov-anton added a commit that referenced this issue Dec 21, 2023
# Submit a pull request

### 🎯 Goal

Fixes #2218 

Provides better compatibility with yarn modern's pnp linker (maybe also
pnpm?) by explicitly providing required dependencies.

### 🛠 Implementation details

N/A

### 🎨 UI Changes

N/A

Co-authored-by: Anton Arnautov <43254280+arnautov-anton@users.noreply.github.com>
github-actions bot pushed a commit that referenced this issue Dec 21, 2023
## [11.2.1](v11.2.0...v11.2.1) (2023-12-21)

### Chores

* **deps:** add @babel/runtime to dependencies ([#2219](#2219)) ([c9f5844](c9f5844)), closes [#2218](#2218)
@stream-ci-bot
Copy link
Collaborator

🎉 This issue has been resolved in version 11.2.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@arnautov-anton
Copy link
Contributor

Getting back as promised; we've reviewed it and as you can see confirmed your issue - again, thank you for your contribution, @imccausl! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released status:confirmed Described issue has been reproduced by the repo maintainer
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants