简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM