react-spring
react-spring copied to clipboard
[bug]: Cannot find module '@react-spring/rafz'
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:
Expected Behaviour
I think @react-spring/rafz
is expected to be installed along with @react-spring/web
Link to repo
Can you share a reproduction of this please
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
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
actually it was introduced at 9.7.0
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.
Appreciate the feedback if I have misunderstood the issue.
Thanks rangaraju
Sure!
Turns out this wasn't a parcel issue, but a
tsc
issueHere's the reproduction repo: https://github.com/everdimension/react-spring-raf-repro
@everdimension Could you explain how you determined this? Thanks!
I additionally ran into this when disabling hoisting within PNPM - what was the tsc
workaround?
@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": "*"
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
.