Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ThreeJS minimum version is too old #711

Closed
dmurvihill opened this issue Sep 10, 2024 · 15 comments
Closed

ThreeJS minimum version is too old #711

dmurvihill opened this issue Sep 10, 2024 · 15 comments
Labels
bug Something isn't working
Milestone

Comments

@dmurvihill
Copy link

dmurvihill commented Sep 10, 2024

Description

You added imports of BatchedMesh recently. This package requires three >= 0.151 but BatchedMesh wasn't added until 0.158. Update the peer dependency in package.json to fix.

Recommend adding three-version to your matrix strategy in GitHub Actions, to test with different verisions of three.

Reproduction steps

  1. npm install [email protected]
  2. npm test

Version

0.7.7

@dmurvihill dmurvihill added the bug Something isn't working label Sep 10, 2024
@gkjohnson
Copy link
Owner

cc @agargaro - any thoughts on this? Sounds like builds are failing because we're trying to import BatchedMesh when it hasn't been made available in previous versions of three.js, yet. Perhaps an import statement like this would work:

import { ... } from 'three';
import * as THREE from 'three';

const BatchedMesh = THREE.BatchedMesh || null;

@gkjohnson gkjohnson added this to the v0.7.8 milestone Sep 10, 2024
@agargaro
Copy link
Contributor

Yes, you are right. I will provide the fix shortly 🙏

@gkjohnson
Copy link
Owner

Recommend adding three-version to your matrix strategy in GitHub Actions, to test with different verisions of three.

@dmurvihill would you like to make a PR with this change? I'm not familiar with how to do this.

@gkjohnson gkjohnson modified the milestones: v0.7.8, v0.7.9 Sep 11, 2024
@timoisalive
Copy link

I started getting an error some days ago:

ERROR in ./node_modules/three-mesh-bvh/src/utils/ExtensionUtilities.js 6:20-37
export 'BatchedMesh' (imported as 'THREE') was not found in 'three'

but the above PR didn't seem to fix it, the version 0.7.8 still has the same issue.

Was the PR supposed to fix this or is this something else...?

@gkjohnson
Copy link
Owner

The PR fixed it for native implementations and Vite. If it isn't fixed in your bundler then please provide your build process.

@Adamatoma
Copy link

Recommend adding three-version to your matrix strategy in GitHub Actions, to test with different verisions of three.

@dmurvihill would you like to make a PR with this change? I'm not familiar with how to do this.

@gkjohnson In my opinion, by modifing the three version in package.json like this could specify the version that your project depends on, it might helps :)

"peerDependencies": {
    "three": ">= 0.158.0"
  },

@Adamatoma
Copy link

I started getting an error some days ago:

ERROR in ./node_modules/three-mesh-bvh/src/utils/ExtensionUtilities.js 6:20-37
export 'BatchedMesh' (imported as 'THREE') was not found in 'three'

but the above PR didn't seem to fix it, the version 0.7.8 still has the same issue.

Was the PR supposed to fix this or is this something else...?

@timoisalive Same here, I found 2 solutions we could do in our own project:

  1. Improve the three verions >= 0.158.0
  2. Use pnpm overrides config to specify the three-mesh-bvh package version < 0.7.7 by adding config to package.json file like this, 0.7.4 works for me:
"pnpm": {
     "overrides": {
          "three-mesh-bvh": "0.7.4"
      }
 }

@gkjohnson
Copy link
Owner

by modifing the three version in package.json like this could specify the version that your project depends on, it might helps

Of course adjusting the peer dependency would fix this but this would make it a breaking change when it doesn't have to be. This is why I have asked for what bundler this is happening in it can be investigated. If it's the case that some bundlers are needlessly strict in this situation then there may be no other option beyond doing a major release and deprecating v0.7.7 and 0.7.8.

@timoisalive
Copy link

The PR fixed it for native implementations and Vite. If it isn't fixed in your bundler then please provide your build process.

I'm using webpack 5.94.0.

@timoisalive
Copy link

@timoisalive Same here, I found 2 solutions we could do in our own project:

  1. Improve the three verions >= 0.158.0
  2. Use pnpm overrides config to specify the three-mesh-bvh package version < 0.7.7 by adding config to package.json file like this, 0.7.4 works for me:

Thanks @Adamatoma for the tips! If I downgrade to 0.7.4 I get another issue:
TS2339: Property 'boundsTree' does not exist on type 'BufferGeometry<NormalBufferAttributes>'..

Can't remember getting that before... 🤷

@shivamkr0304
Copy link

I started getting an error some days ago:

ERROR in ./node_modules/three-mesh-bvh/src/utils/ExtensionUtilities.js 6:20-37
export 'BatchedMesh' (imported as 'THREE') was not found in 'three'

but the above PR didn't seem to fix it, the version 0.7.8 still has the same issue.

Was the PR supposed to fix this or is this something else...?

Were u able to get the solution? if yes..please tell me the same

@agargaro
Copy link
Contributor

agargaro commented Sep 17, 2024

I started getting an error some days ago:

ERROR in ./node_modules/three-mesh-bvh/src/utils/ExtensionUtilities.js 6:20-37
export 'BatchedMesh' (imported as 'THREE') was not found in 'three'

but the above PR didn't seem to fix it, the version 0.7.8 still has the same issue.
Was the PR supposed to fix this or is this something else...?

Were u able to get the solution? if yes..please tell me the same

I don't use webpack but I tried it locally and it seems possible to skip that error by adding this to webpack.config.js.

module: {
    parser: {
      javascript: {
        importExportsPresence: false
      }
    }
  }

Can this be considered a valid solution?

@gkjohnson
Copy link
Owner

There's no reason this should have to fail in Webpack bundles but unfortunately I don't have the time to track this down or look for alternatives. I've deprecated v0.7.7 and v0.7.8 and published v0.8.0 with a peer dependency requirement of three.js v0.158.0.

If someone would like to update CI process to check for compatible three.js versions that would be great.

@timoisalive
Copy link

Ok, thanks for your effort @gkjohnson , I updated the libraries as follows and finally the error is gone! 🥳

    "@react-three/drei": "^9.112.0",
    "@react-three/fiber": "^8.17.7",
    "three": "^0.159.0",
    "three-mesh-bvh": "^0.8.0",

@dmurvihill
Copy link
Author

Still not working on 0.158.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants