pmndrs / use-cannon

👋💣 physics based hooks for @react-three/fiber
https://cannon.pmnd.rs
2.74k stars 153 forks source link

Can't resolve 'worker_thread' #351

Closed N1ark closed 2 years ago

N1ark commented 2 years ago

It seems the changes done in https://github.com/pmndrs/use-cannon/blob/5ff2baacd7caff2079b21b42ea9ca7798070a5d9/rollup.config.js altered what was done in https://github.com/pmndrs/use-cannon/commit/37fcb7dd74d2456289c4047fd06bf01a4c77e4d6 to fix this issue (#86), making it return:

This is what I get when trying to npm run build:

Module not found: Error: Can't resolve 'worker_threads' in `.../node_modules/@react-three/cannon/dist'

I am not well-versed enough in React/npm to be able to add much to this, sorry! All I can say is that switching back to 3.7.0 (the version prior to the breaking commit) fixed the issue.

bjornstar commented 2 years ago

I'm not seeing any problems with the latest versions, can you tell me more about how you're using it?

fxrysh commented 2 years ago

I'm also having the same issue. I'm using webpack for bundling and building my app. Here's the code:

// Core.tsx

// ...
import { Physics } from '@react-three/cannon';

export default function Core(): JSX.Element {
    // ...
}

Warning from webpack:

WARNING in ./node_modules/@react-three/cannon/dist/index.js 11:81-113
Module not found: Error: Can't resolve 'worker_threads' in '/home/kyuzu/Project/portfolio/node_modules/@react-three/cannon/dist'
 @ ./components/Core.tsx 4:0-46 40:42-49
 @ ./app/App.tsx 2:24-52
 @ ./app/index.tsx 3:0-15
 @ ./src/app.ts 1:0-22
 @ ./src/index.ts 2:0-15