cisagov / crossfeed

External monitoring for organization assets
https://docs.crossfeed.cyber.dhs.gov
Creative Commons Zero v1.0 Universal
373 stars 54 forks source link

Implement Performant Node Package Manager (PNPM) as the Package Manager in Place of NPM #2476

Open Matthew-Grayson opened 9 months ago

Matthew-Grayson commented 9 months ago

💡 Summary

Motivation and context

Crossfeed is a monorepo that uses Node Package Manager (NPM). NPM manages Crossfeed dependencies using five separate package.json files.

  1. ./package.json
  2. backend/package.json
  3. docs/package.json
  4. frontend/package.json
  5. frontend/scripts/package.json

There is overlap between the package files meaning NPM installs some packages multiple times. Each instance of a package means an additional download from the Node registry, and an additional instance of the package stored in the project.

Why does this work belong in this project? Performant Node Package Manager (PNPM) is an alternative package manager that creates a global store for all node modules on a system. This means that the same dependency found in three separate directories will be downloaded only once and installed only once. Additionally, project-wide dependencies can be specified once in the parent directory, instead of needing to be specified in multiple package files.

This would be useful because...

Implementation notes

AWS Lambda does not support symlinks so we would need to specify node-linker=hoisted in the .npmrc file. .npmrc files support setting environment variables meaning we can implement symlinks for local development and a flat node-modules file for use in AWS. Source

Acceptance criteria

How do we know when this work is done?