brunolemos/react-native-web-monorepo

Different versions of react and react-native across packages

dpux opened this issue · 1 comments

dpux commented

Not sure how dependency versions should be handled in a monorepo. Are there any suggestions around which package.json to add a new library, and whether it should be duplicated across multiple files? There are 4 files:

package.json (root)
components/package.json
mobile/package.json
web/package.json

Here are a few examples that look inconsistent:

root package.json "react-native": "0.61.3"
mobile/package.json "react-native": "0.61.3"

Can we not move react-native to root?

mobile/package.json "react": "16.11.0"
web/package.json "react": "16.9.0"

Which react version are we supposed to use? Why is it not declared for root and components as well?

web/package.json "typescript": "3.6.4"
root package.json "typescript": "3.6.4"

Why is typescript not declared in components and mobile?

As a general rule what sort of dependencies should be declared in root and components package.json?

The rule of thumb is: add the dependency on every package that uses it. If components use react, add the react dependency. If the root package.json has a script using tsc, add the typescript dev dependency.

The only exception for this is the react-native at the root package.json which is a temporary workaround for a metro bug. Not sure if it's still necessary or if we can already remove it.

All versions should be the same between the packages. If one is using react 16.11.0 the other should too, to avoid having multiple versions of the lib, which causes issues.

I've pushed a commit improving this.