pmndrs / use-cannon

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

Nullish coalescing operator (??) in `dist` files breaking current `create-react-app` setup #198

Closed javierbyte closed 3 years ago

javierbyte commented 3 years ago

Hello, I'm using node v14.17.0 and react-scripts 4.0.3. In 1.2.4 I get an error related to the ?? operator when trying to run a project:

./node_modules/@react-three/cannon/dist/index.js 196:22
Module parse failed: Unexpected token (196:22)
File was processed with these loaders:
 * ./node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
|       id,
|       type,
>       target: target ?? 'bodies'
|     });
|     return () => {

This error is not present at least in 1.2.1.

If this is not expected I should be able to make a PR to make sure to to transform those operators. Thanks for the great work!

Update: I created a PR #199

stockhuman commented 3 years ago

Hi there and thanks for the PR,

Node v14 supports the nullish coalescing operator, as does the CRA setup since 2019, but indeed CRA's development targets combined with native support in some browsers seemingly trips up webpack.. This solution will likely work for you in the meantime.