react-three-rapier
react-three-rapier copied to clipboard
fix: update dependencies, normalize testing
Description
- Update some high-level dependencies
- Update test suite dependencies location
- ~Add .yarnrc.yml to support yarn 4~
- This is the recommended way to go, but not supported on Vercel, so let's skip for now
Problems with this update:
- r3/rapier in 'independent' stepping mode, relies on
requestAnimationFrame
, which breaks testing when running tests outside of a browser environment- We solve this by running tests with the
happy-dom
orjsdom
environment
- We solve this by running tests with the
- New versions of
three-stdlib
(common dependency in all r3/* libs) has alottiejs
implementation which is optimized for ssr, and does some canvas operations immediately when run in a browser environment. This breaks tests.- To fix this, we can run in
jsdom
, and applyvitest-canvas-mock
in the setup-file
- To fix this, we can run in
- Unfortunately, for some reason, the Vercel deployment of the
demo
breaks when updating any of these libraries.- Switching from
happy-dom
tojsdom
breaks Vercel deployment - Updating
vitest
to the latest version breaks Vercel deployment
- Switching from
As I personally don't have access to the Vercel deployment logs or settings, it's nearly impossible to replicate. It's very odd that the testing suite, which is not even run on Vercel, would be affecting the deployment.
Further work is needed to make this up to date with current versions of all the dependent software.
Type of change
- ðĶ Other (tests, refactoring, docs, etc.)
Checklist:
- [x] ð I have performed a self-review of my code
- [x] ðĒ All new and existing unit tests pass
â ïļ No Changeset found
Latest commit: 2b78326a534ff8f105265ec6047a1636a3968156
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
â Update
I cloned the repo and tried reproducing the issue. Out of the box, the demo does not build.
I solved it by setting the install script on Vercel to cd ../; yarn
, so that the install happens on the workspace root rather than in the demo itself.
Since I don't have access to the pmndrs Vercel account, I cannot check to see what's up, but it might be related. Although it's odd how it has worked before in that case.
@drcmda, any chance you could have a look? A dump of the build error on Vercel would be nice, too.
Hey @wiledal I can help with vercel debugging!
Looks like the last build failed on this:
[2/4] Fetching packages...
error [email protected]: The engine "node" is incompatible with this module. Expected version ">=18". Got "16.20.2"
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
Error: Command "yarn install" exited with 1
I'll try updating the node.js version in vercel and re-running ð
ok, now the vercel deployment is up to a new error
ð error @react-three/rapier An unhandled Rollup error occurred: packages/react-three-rapier/src/utils/utils-collider.ts (2:7) Error when using sourcemap for reporting an error: Can't resolve original location of error.
ð info If want to learn more about the above error, check https://preconstruct.tools/errors
ð info If the error is not there and you want to learn more about it, open an issue at https://github.com/preconstruct/preconstruct/issues/new
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: Command "yarn build && cd demo && npx vite build" exited with 1
Thanks @isaac-mason! I'm just back from a vacay ðī. I'm trying to reproduce this error on Vercel on a forked repo. Could you let me know what the Vercel project's Build & Development Settings
-settings are?
Edit: Ah, I think I got it now.
Preset: Other
Root Directory: <empty>
Build command: yarn build && cd demo && npx vite build
Output directory: demo/dist
Install command: yarn
Getting the same errors, will fiddle a bit to see if I can find a solution.
Edit 2: I can get this working when configuring
Preset: Vite
Root Directory: demo
Build command: <empty>
Output directory: <empty>
Install command: cd ../; yarn
It will be compiling "from source", though I'm not sure how preconstruct deals with the built packages in this context, or if it really matters... That being said, it would be great knowing why rollup fails to build packages after updating the unrelated testing suite.
I've updated the pmndrs react-three-rapier vercel app to have the same configuration now ð
I'm not very familiar with preconstruct either, would be good to understand.
Built and deployed successfully! https://react-three-rapier-jjahtxe68-pmndrs.vercel.app/