Search code examples
babeljses6-module-loader

ES6 export from Syntax on submodule


I have the following structure

 components/
   index.js
   Messages/
    index.js
    error.jsx
    info.jsx
    success.jsx 

Messages/index.js export the three messages as :

export {Info} from './info'
export {Error} from './error'
export {Success} from './success'

And components/index.js does the following:

 import * as Message from './Message'
 export {Message}

Is there a way for me to do it without the import?

I am using webpack and Babel with es2015 presets


Solution

  • According to Mozilla's ES2015 documentation https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export you can just do

    export * from './Messages';