javascriptmoduleecmascript-6babeljs

Is there any one-line analogy in ES6 for ES5 `module.exports = require('./inner.js')`?


// before
module.exports = require('./inner.js');
// nowadays
export default from './inner.js';

i'm trying to do this, but babel allow it only in es7 stage 1 as it is proposal for now. So for now, im stick to these two lines:

import sticker from './box-sticker.jsx';
export default sticker;

Can I shorter them to one?


Solution

  • You should be able to do

    export {default as default} from './inner.js';
    // or even
    export {default} from './inner.js';
    

    with current ES6 semantics.

    However I don't think there's anything wrong with using the ES next proposal, I'm pretty confident that it will make it into ES7 ES8.