realm-js
realm-js copied to clipboard
Migrating from Lerna to NPM workspaces
What, How & Why?
This closes (part of) #2869 by:
- Adding
workspaces
to the rootpackage.json
- Removed "Start packager" step from the
example/ios
andintegration-tests/environments/react-native/ios
xcode projects, since they rely on "react-native" being installed innode_modules
and it gets hoisted to the root package when using NPM workspaces. - Removed all
package-lock.json
files, except for the root and added a check to ensure they aren't created, in thescripts/check-environment.js
. - Updated the
engines.npm
to^8.5
get a fix making NPM workspace aware in sub-packages, to avoid creation ofpackage-lock.json
files ifnpm install
is ran in a sub-package. - Updated the
engines.node
to>=14
because it was outdated.
☑️ ToDos
- [x] 📝 Changelog entry
- [x] 📝
Compatibility
label is updated or copied from previous entry - [x] 🚦 Tests (tested running the tests manually locally)
- [x] 📱 Check the React Native/other sample apps work if necessary
- [x] 📝 Public documentation PR created or is not necessary
- [x] 💥
Breaking
label has been applied or is not necessary
I think this looks great, nice to remove complexity, good work!
So with npm workspaces, there's no longer the concept of "bootstrapping" an individual subpackage, you always just run npm i --workspaces
from the root?
I tried running packages/realm-react/example
by:
-
npm i --workspaces
-
cd packages/realm-react/example
-
npx pod-install
And I get:
[!] No podspec found for `React-logger` in `../../node_modules/react-native/ReactCommon/logger`
Couldn't install Pods. Updating the Pods project and trying again...
Command `pod install` failed.
└─ Cause: No podspec found for `React-logger` in `../../node_modules/react-native/ReactCommon/logger`
Not sure what is wrong here, I can't see an obvious hard coded path that is causing it...
So with npm workspaces, there's no longer the concept of "bootstrapping" an individual subpackage, you always just run
npm i --workspaces
from the root?
I had to revert this, it turns out the --workspaces
is already default on these (install, update, etc.) commands.
As the docs say:
Commands that operate on the node_modules tree (install, update, etc.) will link workspaces into the node_modules folder.
This is awaiting merge and release of https://github.com/vercel/turborepo/pull/1145.
Closing this as I choose to do this for the bindgen
branch instead.