DimiMikadze / create-react-library

React NPM library starter kit based on Facebook's create react app
MIT License
602 stars 60 forks source link

Fixes #57: allow for internal bundle dependencies without requiring consuming application to maintain the same dependencies #58

Closed reinrl closed 4 years ago

reinrl commented 5 years ago

I created a few different sample projects, using this project as a starting point - and I always seem to run into errors whenever attempting to bundle other libraries within mine (e.g., I want be dependent a form library, but don't want to force that dependency on a consuming application by using a devDependency/peerDependency combination).

As I had noted in issue #53, using libraries which I want to force the consuming application to specify a dependency on is relatively trivial (add to devDependency/peerDependency in my library, and add to the "externals" configuration within your webpack.config file(s).

In this particular case, I couldn't find a way to simply bundle another library without having to go that route - until I realized that I needed to add to the webpack output config (a libraryTarget attribute had already been added, but I needed to also specify library and umdNamedDefine attributes before this all worked for me). Now, I can simply add internal dependencies to my package.json's dependency array, and my consuming application is none the wiser.

DimiMikadze commented 4 years ago

https://github.com/DimiMikadze/create-react-library/pull/63