Module.exports and es6 Import

后端 未结 3 1807
再見小時候
再見小時候 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:58

    If you would like to import:

    module.exports = Tiger
    

    you may use following construction:

    import * as Tiger from './animals'
    

    Then it will work.

    Another option is changing the export as described by @Matt Molnar but it is only possible if you are the author of the imported code.

提交回复
热议问题