I'd like to the following but with a single line, if possible:
import Module from './Module/Module;
export Module;
I tried the following but it doesn't seem to work:
export Module from './Module/Module;
I'd like to the following but with a single line, if possible:
import Module from './Module/Module;
export Module;
I tried the following but it doesn't seem to work:
export Module from './Module/Module;
is the standard ES6 way, as long as you don't need
Module
to also be available inside the module doing the exporting.is a proposed ESnext way to do it, but that only works if you've enabled it in Babel for now.
So, here is the answer!
in my case i needed to bundle all of my react components in to library. worked fine as well as packing it as a library in webpack.
I don't know why but just this works for me :
index.jsx:
I import the exports like this :
So, I've found this to work quite well for the immediate export functionality of having an
index.js
at the root of thecomponents
directory for easy referencing:You need to use
module.exports
.Please note you can also re-export everything from a module: