realm-js icon indicating copy to clipboard operation
realm-js copied to clipboard

Migrating from Lerna to NPM workspaces

Open kraenhansen opened this issue 2 years ago • 3 comments

What, How & Why?

This closes (part of) #2869 by:

  • Adding workspaces to the root package.json
  • Removed "Start packager" step from the example/ios and integration-tests/environments/react-native/ios xcode projects, since they rely on "react-native" being installed in node_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 the scripts/check-environment.js.
  • Updated the engines.npm to ^8.5 get a fix making NPM workspace aware in sub-packages, to avoid creation of package-lock.json files if npm 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

kraenhansen avatar Feb 28 '22 09:02 kraenhansen

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:

  1. npm i --workspaces
  2. cd packages/realm-react/example
  3. 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...

tomduncalf avatar Feb 28 '22 11:02 tomduncalf

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.

kraenhansen avatar Feb 28 '22 14:02 kraenhansen

This is awaiting merge and release of https://github.com/vercel/turborepo/pull/1145.

kraenhansen avatar Apr 28 '22 14:04 kraenhansen

Closing this as I choose to do this for the bindgen branch instead.

kraenhansen avatar Mar 29 '23 17:03 kraenhansen