hurrymaplelad / teact

Build React element trees by composing functions
MIT License
26 stars 6 forks source link

React as a peer dependency #8

Closed JavascriptIsMagic closed 7 years ago

JavascriptIsMagic commented 7 years ago

So I was trying to use Teact in a new project and keep React up to date. Currently at the time of this writing teact on npm is teact@1.1.2 and has a dependency of react@^0.14.2 and I'm using react@latest creating a structure like:

├── react@15.4.1
└─┬ teact@1.1.2
  └── react@0.14.8

Unfortunately common bundlers today will include both versions of react in the bundle, and Teact completely explodes because of it.

Is there any reason why react must be a dependency rather then a peerDependency so you can choose which version of react to use in your project even if Teact is behind a few versions on npm?

brycefisher commented 7 years ago

My apologies @JavascriptIsMagic for the version mismatch. Publishing the updated version of teact to npm should resolve the immediate problem.

I'm open to the peer dependency solution as well.

brycefisher commented 7 years ago

@JavascriptIsMagic I've published the latest version on master to npm.

@hurrymaplelad any opinions on this PR?

hurrymaplelad commented 7 years ago

In the situaton described above, a peer dep on reat@0.14 would have made Teact error at install time. I suppose that's failing faster and with a better error message.

At the time this was written, peer deps appeared to be falling out of favor due their propensity to create dependency nightmares, so I used a good ol regular dep. it looks like peer deps are still around in npm3, just nerfed a little.

If we go with peer deps, we'll need to include React as a devDependency as well to make sure it's installed for tests and such. @JavascriptIsMagic you up for adding the dev dependency?

:+1:

JavascriptIsMagic commented 7 years ago

Added react as a devDependency.

I was fiddling around with it quite a lot in both npm and yarn and neither had a great solution on the package manager side. I was able to find a webpack based work around by aliasing react to always resolve exactly the version I wanted, but it's still nice to have this throw a warning or something when the version gets a little behind.

hurrymaplelad commented 7 years ago

Published as v1.3.0. Thanks!