I use react to build my library of components. I need to have an index.js to import all components in one place.
Something like this:
MyComponents/
Button.js
Label.js
index.js
Inside the index.js I tried to do next:
// this export nothing
export {default} from './Button';
// this tells me about syntax error
export default from './Button';
I found only this solution that works
import Button from './Button';
export default Button;
But I found that some React Component libraries uses syntax that I mentioned above (export default from './Button') - and it works somehow. Looks like they use some babel-plugin-transform-* to do this.
Please find me to find how to transform my two lines of import export to one line of export ... from .... Thank you.
P.S. In the end I need to do this: import Button from './MyComponents';
export {default as Button} from './Button'.export default from './Button'works for me. Compiles and displays correctly. I use following Babel presets:"es2015", "stage-0", "react". Can you show me your Babel/Webpack configuration? See a screenshot herestage-0orstage-1because this is an experimental features. It may be a reason.