Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRAFT] Experimental NPM workspaces (move away from lerna in v2) #421

Closed
wants to merge 34 commits into from

Conversation

kirrg001
Copy link
Contributor

@kirrg001 kirrg001 commented Nov 19, 2021

NPM workspaces are so simple ❤️

These are my first findings (they might be not 100% correct, but will be corrected if needed):

  • feels like NPM is very smart under the hood and just recognizes that you are in a workspace context.
  • single lock file in the root folder - so cool!
  • default npm commands! (such as npm i -> will just install all dependencies in root + workspaces)
  • out of the box functionality such as npm uninstall mocha --workspaces (this has not worked with lerna, it was a hard)
  • the lerna bug I was running into is no longer a problem because the whole lock structure is different! Lerna copies the package.json, removes local package references and generates the lock file. With NPM we only have one lock file. No one is manipulating it. Still NPM is doing symlinks to local packages. I am not 100% sure (with our use cases) that we might run into problems.
  • no more need to run hacky package lock scripts for audit
  • high hopes that all the lerna frustration goes away

Downside: Does not work well with lerna, because it's just too different. But you can still use lerna commands such as lerna version or lerna publish as far as I can see. Which is the most important fact.

This needs more brain and testing, but the first impression is really good!

  • NPM workspaces works with Node >= 10
  • fix tests
  • create v2 branch and change PR base
  • move all dev dependencies to root
  • add docs for us!
  • cleanup lock cache ci
  • enable skipped tests
  • push knex downgrade to v2 branch directly
  • lerna version --no-git-tag-version --no-push test it
  • lerna publish test it
  • update contributiing docs!
  • add command to switch from v1 to v2 (in v2)
  • add command to switch from v2 to v1 (in v1)
  • ci cache with collector-v2!

NPM workspaces limitations

@kirrg001 kirrg001 changed the base branch from main to v2 November 22, 2021 10:20
@kirrg001 kirrg001 force-pushed the exp/workspaces branch 3 times, most recently from 0392051 to ee87667 Compare November 22, 2021 13:28
@kirrg001 kirrg001 changed the title [DRAFT] Experimental NPM workspaces [DRAFT] Experimental NPM workspaces (move away from lerna in v2) Nov 22, 2021
@kirrg001 kirrg001 force-pushed the exp/workspaces branch 4 times, most recently from 8560488 to 62fd318 Compare November 23, 2021 08:44
@kirrg001
Copy link
Contributor Author

I'd right now not continue with playing with this. I'd suggest to touch this area again when NPM workspaces has less problems (see PR description).

On top of the two "blockers" some tests where failing in shared-metrics package, because the way NPM workspaces installs dependencies doesn't make the package happy. We rely a lot on the fact that dependencies are physically available in shared-metrics/node_modules, but NPM installs everything in the root (as best as it can). But for this package we'd want to "nohoist" dependencies (see).

I am still convinced that the switch will be great. Happy to switch over as soon as we can. But for know I'd stick with lerna.

@kirrg001 kirrg001 closed this Nov 26, 2021
@kirrg001 kirrg001 deleted the exp/workspaces branch December 11, 2023 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant