I have a number of React components that I use in multiple Webpack projects, and I want to share them via NPM. So naturally I:
- put those components into a (private) GitHub repo
- Added that repo to a main project's
package.json
- So that I could develop on the component library simultaneously, I used
npm link
to symlink it into my main project.
However, Webpack can't resolve react
from my library component files, because there's no node_modules
in the library project folder or any of its parents.
I've seen 3rd party React components that were built as a bundle with react
in the externals
of the Webpack config, but I don't want to build a separate bundle or do anything complicated, I just want to require the raw source for my library components. Does anyone know how to do that?