pmndrs / react-spring

✌️ A spring physics based React animation library
http://www.react-spring.dev/
MIT License
27.93k stars 1.19k forks source link

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

Closed everdimension closed 1 month ago

everdimension commented 1 year ago

Which react-spring target are you using?

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-springshared.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

-

joshuaellis commented 1 year ago

Can you share a reproduction of this please

everdimension commented 1 year ago

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

cherishs001 commented 1 year ago

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

mateusvelleda commented 1 year ago

actually it was introduced at 9.7.0

rangaraju29139 commented 1 year ago

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

Producdevity commented 10 months ago

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!

sarocu commented 4 months ago

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

wegry commented 4 months ago

@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": "*"
tylerlaprade commented 1 month ago

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.