pmndrs / react-spring

✌️ A spring physics based React animation library
http://www.react-spring.dev/
MIT License
28.05k stars 1.19k forks source link

why require('react-spring') returns string instead of object #2213

Closed jeven2016 closed 11 months ago

jeven2016 commented 11 months ago

Which react-spring target are you using?

What version of react-spring are you using?

9.7.3

What's Wrong?

the following code will print a string instead of an object: const rs = require('react-spring'); console.log(rs) //it prints: '/static/media/react-spring.development.286d67301b2cd6cdd0f1.cjs' console.log(typeof rs) // it prints: 'string'

To Reproduce

  1. create a react project by create-react-app tool yarn create react-app mytest

  2. add react-spring using yarn yarn add react-spring

  3. edit src/index.js and add the following code: const rs = require('react-spring'); console.log(rs) //it prints: '/static/media/react-spring.development.286d67301b2cd6cdd0f1.cjs' console.log(typeof rs) // it prints: 'string'

the dependencies: node: v18.17.1 "react": "^18.2.0", "react-dom": "^18.2.0", "react-scripts": "5.0.1", "react-spring": "^9.7.3",

what weird is it works as expected in codesandbox , so I'm not sure if there any bugs involved, hope someone can take a look , thanks.

Expected Behaviour

const rs = require('react-spring');
the rs should be a object

Link to repo

what weird is it works as expected in codesandbox , so I'm not sure if there any bugs involved,

joshuaellis commented 11 months ago

if it works in codesandbox then it's likely something to do with your code setup, I'd encourage you to supply a reproduction of your issue so it can be reviewed.