ES6 module syntax: is it possible to `export * as Name from …`?

前端 未结 4 1705
小蘑菇
小蘑菇 2020-12-01 23:17

See question title. I found a great reference for the forms of export available, but I have not seen what I\'m looking for.

Is it possible to do somethi

4条回答
  •  攒了一身酷
    2020-12-02 00:11

    No, it's not allowed in JS either, however there is a proposal to add it. For now, just use the two-step process with importing into a local variable and exporting that:

    // file: constants.js
    export const SomeConstant1 = 'yay';
    export const SomeConstant2 = 'yayayaya';
    
    // file: index.js
    import * as Constants from './constants.js';
    export {Constants};
    

提交回复
热议问题