0.3.8 ā€¢ Published 2 years ago

@snpm-io/cli v0.3.8

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

SNPM (WIP)

SNPM is an "alternative" for NPM, but it's not meant to replace NPM/Yarn/PNPM

DISCLAIMER šŸš§

This project was made to learn more about Package Managers, for now you should only use it to play with it.

CLI

The SNPM CLI is used to install packages from the package.json of a project.

Its advantages are that it is faster than NPM and saves more space.

Instalation

npm i @snpm-io/cli -g

Commands

  • snpm install [pkg (optional), flags] Installs packages
  • snpm run <script> <params> Run script from package.json
  • snpm benchmark Tests SNPM against NPM and PNPM
  • snpm clear Remove .snpm-cache folder . snpm ls <pkg> Show versions installed by SNPM

Todo

  • Make it work in some JS Frameworks (Follow progress here)
  • Fix monorepos integration (WIP, degradated performance in some repos)

Why is it faster?

SNPM uses the same installation system as PNPM, fetch dependency, download dependency. Without waiting for the rest of the dependencies.

To resolve the dependencies, a dependency tree is generated as in NPM version 2, each dependency (or subdependency) has its own node_modules.

Now you are probably wondering how that makes the space more efficient than in NPM.

Each dependency is a hard link to a common store inside .snpm-cache, so all your projects use shared dependencies.

It works?

Short answer, probably no, but in some cases it works. (For now)

I've selected some quickstart templates to test SNPM, and I'm working on make it work in all of them.

If you want to test a template, you can use Next or Vite, I've already tested them and it should work.

(If you want to test a template and it doesn't work, please open an issue)

Benchmarks

PNPM Official benchmark (alotta-files)

ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
ā”‚ (index) ā”‚                    name                    ā”‚      time       ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚    0    ā”‚ 'Bun install (with cache / with lockfile)' ā”‚ '0.70 seconds'  ā”‚
ā”‚    1    ā”‚  'Bun install (with cache / no lockfile)'  ā”‚ '1.17 seconds'  ā”‚
ā”‚    2    ā”‚        'SNPM install (with cache)'         ā”‚ '4.94 seconds'  ā”‚
ā”‚    3    ā”‚   'Bun install (no cache / no lockfile)'   ā”‚ '9.90 seconds'  ā”‚
ā”‚    4    ā”‚        'PNPM install (with cache)'         ā”‚ '10.16 seconds' ā”‚
ā”‚    5    ā”‚ 'NPM install (with cache / with lockfile)' ā”‚ '27.29 seconds' ā”‚
ā”‚    6    ā”‚  'NPM install (with cache / no lockfile)'  ā”‚ '35.34 seconds' ā”‚
ā”‚    7    ā”‚        'YARN install (with cache)'         ā”‚ '43.62 seconds' ā”‚
ā”‚    8    ā”‚         'SNPM install (no cache)'          ā”‚ '1.02 minutes'  ā”‚
ā”‚    9    ā”‚         'PNPM install (no cache)'          ā”‚ '1.24 minutes'  ā”‚
ā”‚   10    ā”‚   'YARN install (no cache, no lockfile)'   ā”‚ '1.68 minutes'  ā”‚
ā”‚   11    ā”‚    'YARN install (with cache, no lock)'    ā”‚ '2.13 minutes'  ā”‚
ā”‚   12    ā”‚   'NPM install (no cache / no lockfile)'   ā”‚ '2.36 minutes'  ā”‚
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜

Vite React - TS

This is an example benchmark of a Vite project using npm create vite@latest my-react-app -- --template react-ts

Check results in Pull Requests comments

Nextjs - TS

This example is generated using npx create-next-app --use-npm --ts

WARNING: It works now, but some errors may appear.

ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
ā”‚ (index) ā”‚                    name                    ā”‚      time       ā”‚ group ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚    0    ā”‚ 'Bun install (with cache / with lockfile)' ā”‚ '0.23 seconds'  ā”‚   3   ā”‚
ā”‚    1    ā”‚   'Bun install (no cache / no lockfile)'   ā”‚ '3.37 seconds'  ā”‚   1   ā”‚
ā”‚    2    ā”‚        'PNPM install (with cache)'         ā”‚ '3.47 seconds'  ā”‚   3   ā”‚
ā”‚    3    ā”‚  'Bun install (with cache / no lockfile)'  ā”‚ '3.79 seconds'  ā”‚   2   ā”‚
ā”‚    4    ā”‚        'SNPM install (with cache)'         ā”‚ '5.04 seconds'  ā”‚   3   ā”‚
ā”‚    5    ā”‚        'YARN install (with cache)'         ā”‚ '5.93 seconds'  ā”‚   3   ā”‚
ā”‚    6    ā”‚ 'NPM install (with cache / with lockfile)' ā”‚ '6.61 seconds'  ā”‚   3   ā”‚
ā”‚    7    ā”‚  'NPM install (with cache / no lockfile)'  ā”‚ '8.51 seconds'  ā”‚   2   ā”‚
ā”‚    8    ā”‚         'PNPM install (no cache)'          ā”‚ '15.87 seconds' ā”‚   1   ā”‚
ā”‚    9    ā”‚    'YARN install (with cache, no lock)'    ā”‚ '16.07 seconds' ā”‚   2   ā”‚
ā”‚   10    ā”‚         'SNPM install (no cache)'          ā”‚ '19.05 seconds' ā”‚   1   ā”‚
ā”‚   11    ā”‚   'NPM install (no cache / no lockfile)'   ā”‚ '22.20 seconds' ā”‚   1   ā”‚
ā”‚   12    ā”‚   'YARN install (no cache, no lockfile)'   ā”‚ '32.87 seconds' ā”‚   1   ā”‚
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜

Create React App - Craco

WARNING: Currently CRA doesn't work with symlinked dependencies.

Pending...

The commands with no-cache executes npm cache clean -f to delete NPM Cache files (SNPM uses them too npm/pacote) and also deletes the store folder for SNPM.