Vladimir Starkov Vladimir Starkov - 2 years ago 194
Javascript Question

Is there any one-line analog 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?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download