Module.exports and es6 Import

后端 未结 3 1797
再見小時候
再見小時候 2020-12-29 02:17

React with babel. I have this confusion with imports and module.exports. I assume babel when converting the ES6 code to ES5 converts the imports and exports to require and

3条回答
  •  甜味超标
    2020-12-29 02:47

    export { Tiger } would be equivalent to module.exports.Tiger = Tiger.

    Conversely, module.exports = Tiger would be equivalent to export default Tiger.

    So when you use module.exports = Tiger and then attempt import { Tiger } from './animals' you're effectively asking for Tiger.Tiger.

提交回复
热议问题