react-spring icon indicating copy to clipboard operation
react-spring copied to clipboard

[bug]: Cannot find module '@react-spring/rafz'

Open everdimension opened this issue 1 year ago • 8 comments

Which react-spring target are you using?

  • [X] @react-spring/web

What version of react-spring are you using?

9.7.3

What's Wrong?

I am having an issue similar to https://github.com/pmndrs/react-spring/issues/1559

I am using parcel to build my project. I am seeing this type warning:

node_modules/@react-spring/shared/dist/react-spring_shared.modern.d.ts:1:27 - error TS2307: Cannot find module '@react-spring/rafz' or its corresponding type declarations.

1 import { raf, Rafz } from '@react-spring/rafz';

To Reproduce

npm i @react-spring/web
... later in project ...
import { useSpring } from '@react-spring/web';

I can see that @react-spring/rafz is not in my node_modules, but in fact it's being used by @react-spring/shared package: image

Expected Behaviour

I think @react-spring/rafz is expected to be installed along with @react-spring/web

Link to repo

everdimension avatar Jul 04 '23 08:07 everdimension

Can you share a reproduction of this please

joshuaellis avatar Jul 04 '23 09:07 joshuaellis

Sure!

Turns out this wasn't a parcel issue, but a tsc issue

Here's the reproduction repo: https://github.com/everdimension/react-spring-raf-repro

everdimension avatar Jul 04 '23 11:07 everdimension

I had the same problem, and I solved it temporarily by manually installing @react-spring/rafz, it looks like the @react-spring/rafz dependency is missing from the @react-spring/shared package

cherishs001 avatar Jul 06 '23 02:07 cherishs001

actually it was introduced at 9.7.0

mateusvelleda avatar Aug 16 '23 17:08 mateusvelleda

Hi everyone and @everdimension , I am beginner to Open-sourse Contributions and React ecosystem. With whatever understanding that I have understood from this issue, I just want to express my point of view.

My Observations: As it is mentioned in the share readmefile, the shared library have the helper functions only to core and web libraries. I Don't think rafz has to be included as a dependency to web.

My Proposed Solution: If we are using the "@react-spring/rafz" functionality , we have to explicitly import it. image

shared docs

Appreciate the feedback if I have misunderstood the issue.

Thanks rangaraju

rangaraju29139 avatar Aug 22 '23 01:08 rangaraju29139

Sure!

Turns out this wasn't a parcel issue, but a tsc issue

Here's the reproduction repo: https://github.com/everdimension/react-spring-raf-repro

@everdimension Could you explain how you determined this? Thanks!

Producdevity avatar Oct 24 '23 19:10 Producdevity

I additionally ran into this when disabling hoisting within PNPM - what was the tsc workaround?

sarocu avatar Apr 04 '24 18:04 sarocu

@sarocu With Yarn 4, adding a explicit dependency in the .yarnrc.yml (I think pnpm has a similar mechanism) should do the trick.

# yarnrc.yml
packageExtensions:
  "@react-spring/shared@*":
    dependencies:
      "@react-spring/rafz": "*"
  "@react-spring/web@*":
    dependencies:
      "csstype": "*"

wegry avatar Apr 05 '24 16:04 wegry

I also have this problem when running tsc. For now, I manually added @react-spring/rafz to my package.json, but ideally this dependency would be included directly in @react-spring/web.

tylerlaprade avatar Jul 19 '24 15:07 tylerlaprade