I am creating a React component and want to publish it.
I've put in the package.json:
"peerDependencies": {
"react": "^15.6.1",
"react-dom": "^15.6.1"
},
And expect that when building my module with webpack, my component would not yell this:
Module not found: Error: Can't resolve 'react'
How can I compile a production component without including React?
I checked some famous ones :
And they list react only in peerDependecies (and in devDependecies, for testing and development purposes I guess)
If I add react to my devDeps and run webpack -p it compiles successfully but then I have react in my component bundle.
Here my simple webpack config
What am I missing?
UPDATE I added "external" option in webpack config (the gist is updated), with this is compiles correctly, it does not include React in the bundle, but when I import it in project with React to use it it gives me:
Cannot read property 'Component' of undefined
soon as it finds React.Component of my component...