Skip to content

Upgrade and prune dependencies, set package scopes, and make monorepo use NPM workspaces

Aidan requested to merge upgrade-deps-and-monorepo into master

There are three main goals with this MR

First, the main objective was to upgrade dependencies and prune unneeded ones, which was done using depcheck and then manually verifying that packages weren't being used before removing them, and then running npm audit fix and verifying that didn't break changes either.

While verifying these packages, I noticed that my IDE, which uses Microsoft's typescript language server, couldn't resolve any of the polycentric packages. To fix this, I set up the repo to use NPM's workspaces feature, which does similar logic to the symlink code in the makefile. It takes our local packages (called 'workspaces') and symlinks them to a root node_modules in the project directory, also installing common dependencies there. When resolving packages, Node looks in all recursive parent directories for a node_modules folder, meaning that we can just write "@polycentric/polycentric-core": "*" and it'll auto-resolve. To do this upon cloning, and install all dependencies for all packages, only a single npm install in the root of the workspace is needed. This will also make it easier to upgrade to monorepo tooling in the future like turborepo as it's built on workspaces.

While changing the monorepo structure and rewriting all local dependency references to use "*" instead of relative paths, I also worked on renaming the internal packages to use scoping so that we can't get dependency attacked. At the time of this PR, @polycentric is registered on NPM.

I also re-ran prettier for the codebase which should lead to some style changes in parts of the code I didn't touch.

Edited by Aidan

Merge request reports