react-three-rapier icon indicating copy to clipboard operation
react-three-rapier copied to clipboard

fix: update dependencies, normalize testing

Open wiledal opened this issue 1 year ago â€Ē 5 comments

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 or jsdom environment
  • New versions of three-stdlib (common dependency in all r3/* libs) has a lottiejs 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 apply vitest-canvas-mock in the setup-file
  • Unfortunately, for some reason, the Vercel deployment of the demo breaks when updating any of these libraries.
    • Switching from happy-dom to jsdom breaks Vercel deployment
    • Updating vitest to the latest version breaks Vercel deployment

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

wiledal avatar Jan 29 '24 18:01 wiledal

⚠ïļ 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

changeset-bot[bot] avatar Jan 29 '24 18:01 changeset-bot[bot]

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

wiledal avatar Sep 19 '24 19:09 wiledal

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

isaac-mason avatar Sep 20 '24 04:09 isaac-mason

I'll try updating the node.js version in vercel and re-running 🙂

isaac-mason avatar Sep 20 '24 04:09 isaac-mason

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

isaac-mason avatar Sep 20 '24 04:09 isaac-mason

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.

wiledal avatar Sep 30 '24 18:09 wiledal

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.

isaac-mason avatar Oct 01 '24 15:10 isaac-mason

Built and deployed successfully! https://react-three-rapier-jjahtxe68-pmndrs.vercel.app/

isaac-mason avatar Oct 01 '24 15:10 isaac-mason