Unable To Expose A Component Library In React With Webpack And Babel
I'm creating a small component library for react. Something that can be required like var Components = require('components'). This will have individual components, much like react-
Solution 1:
You are exporting component in the object in the default export. Babel 6 produces the following CommonJS module for you. See REPL:
exports.default = {
ImageEditor: ImageEditor
};
Then you can use this component like this:
var ImageEditor = require('my-lib').default.ImageEditor
Your component is hidden under the default key. If you don't want it, use named exports instead.
export {ImageEditor};
For this, Babel produces the following code
exports.ImageEditor = ImageEditor;
Look, no extra default
key, and everything work as expected
Post a Comment for "Unable To Expose A Component Library In React With Webpack And Babel"