rescript-react
rescript-react copied to clipboard
Upgrading to @rescript/react is incompatible with most of my app’s dependencies based on reason/react
Some scripts that I use in my app are breaking. For example:
- rescript-recoil
- bs-reach
- re-formality
is there a way to fix this other than waiting for the third-party libs to catch up?
example of error
It's possible that your build is stale.
Try to clean the artifacts and build again?
Here's the original error message
The files /code/sobras/node_modules/rescript-recoil/lib/ocaml/recoil.cmi
and /code/sobras/node_modules/@rescript/react/lib/ocaml/react.cmi
make inconsistent assumptions over interface React
example 2
It's possible that your build is stale.
Try to clean the artifacts and build again?
Here's the original error message
The files /Users/jorgec/Downloads/code/sobras/node_modules/@rescript/react/lib/ocaml/react.cmi
and /Users/jorgec/Downloads/code/sobras/node_modules/re-formality/lib/ocaml/formality.cmi
make inconsistent assumptions over interface React
example 3
It's possible that your build is stale.
Try to clean the artifacts and build again?
Here's the original error message
The files /Users/jorgec/Downloads/code/sobras/node_modules/@rescript/react/lib/ocaml/reactDOMRe.cmi
and /Users/jorgec/Downloads/code/sobras/node_modules/bs-reach/lib/ocaml/slider-Reach.cmi
make inconsistent assumptions over interface React
Hm, I think this is the moment where third party packages need to create a new npm package that does align with the new rescript & rescript-react ecosystem.
Not only because it's not possible to drive two different packages with the same exposed toplevel module names, but also because the package names like bs-xyz, and the module source code are inconsistent with ReScript's recommendations.
As a quick workaround, I'd copy the bs-reach / re-formality libraries into your app code and remove the dependency. bs-reach hasn't gotten any updates for quite some time, so I'd actually argue that you should copy it anyways, since you get more control over the code when you find interface mismatches.
I can't find any details about ˋrescript-reasonˋ... was this a typo?
@ryyppy it was a typo! I meant rescript-recoil. I edited my initial comment.
Since re-formality depend on ppx, is it straightforward to just copy the code? I've never built a ppx
Migrated my projects:
- [x] rescript-recoil → 1.0.0
- [x] rescript-pages → 1.0.1
- [x] ~~reason-react-compat~~ → [email protected]
- [x] ~~reason-react-update~~ → [email protected]
@vasco3 huh that's weird... just checking re-formality, it doesn't look like it has a dependency to reason-react?
So as long as the library + ppx don't use any of the old ReasonReact toplevel modules, or some funky bindings from ReactDOMRe that have been deprecated for a while, it should actually work fine. The problems arise when you have a package that has a dependency on reason-react, like bloodyowl had.
\cc @alexfedoseev just to verify what reason-react apis are being used, because I can't find any hints in the source code so far
@ryyppy Current published package contains 2 versions of the lib:
- PPX: current
- Non-PPX: kept for backward compatibility to make transition to the current one easier
PPX version uses:
React.useReducerReact.useEffect*React.useMemo*
Non-PPX version uses:
React.useReducerReact.useEffect*React.useMemo*ReactEvent.Form.*
Package has only one dependency and it's not reason-react.
@ryyppy on re-formality maybe it's the references to ReactEvent?
https://github.com/MinimaHQ/re-formality/blob/73b9badf03eeaf1fa38fde9af33c0d354650be6e/lib/src/FormalityCompat__PublicHelpers.re#L4
@vasco3 @ryyppy I found a culprit: https://github.com/MinimaHQ/re-formality/blob/master/lib/bsconfig.json#L5
The package doesn't have reason-react as an npm dependency but it's included in bs-dependencies. B/c all users had reason-react installed, it was working. Now the package name changed and it causes issues. I will release a fix this weekend.
After more than one and a half years, all projects that are still active will already have updated the dependency to @rescript/react.
If there is still anything missing, please open an issue on that project's issue tracker.