ES6 `export * from import`?

后端 未结 2 566
暗喜
暗喜 2020-12-02 19:45

Is there a syntax using ES6 or ES7 or babel which will allow me to easily bundle together many groups of sub files?

E.g., given:

./action_creators/i         


        
相关标签:
2条回答
  • 2020-12-02 20:12

    Default export as Default:

    export {default} from './something';
    

    Default export as Named:

    export {default as foo} from './something';
    

    Named export as Default:

    export {foo as default} from './something';
    

    Named export as Named:

    export {foo} from './something';
    

    Named export as Renamed:

    export {foo as bar} from './something';
    
    0 讨论(0)
  • 2020-12-02 20:17

    Yes, ES6 supports directly exporting imported modules:

    export { name1, name2, …, nameN } from …;
    
    export {FooAction, BarAction} from './action_creators/index.js'
    

    You can also re-export all exports of the imported module using the * syntax:

    export * from …;
    
    export * from './action_creators/index.js';
    

    More info on MDN.

    0 讨论(0)
提交回复
热议问题