realm-js
realm-js copied to clipboard
Migrating from Lerna to NPM workspaces
What, How & Why?
This closes (part of) #2869 by:
- Adding
workspacesto the rootpackage.json - Removed "Start packager" step from the
example/iosandintegration-tests/environments/react-native/iosxcode projects, since they rely on "react-native" being installed innode_modulesand it gets hoisted to the root package when using NPM workspaces. - Removed all
package-lock.jsonfiles, except for the root and added a check to ensure they aren't created, in thescripts/check-environment.js. - Updated the
engines.npmto^8.5get a fix making NPM workspace aware in sub-packages, to avoid creation ofpackage-lock.jsonfiles ifnpm installis ran in a sub-package. - Updated the
engines.nodeto>=14because it was outdated.
☑️ ToDos
- [x] 📝 Changelog entry
- [x] 📝
Compatibilitylabel 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] 💥
Breakinglabel 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 --workspacescd packages/realm-react/examplenpx 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 --workspacesfrom 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.