Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ilteoood/nmt
node_modules trimmer
https://github.com/ilteoood/nmt
Last synced: 2 months ago
JSON representation
node_modules trimmer
- Host: GitHub
- URL: https://github.com/ilteoood/nmt
- Owner: ilteoood
- Created: 2024-08-10T15:38:46.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-10-29T19:22:02.000Z (2 months ago)
- Last Synced: 2024-10-29T21:30:04.356Z (2 months ago)
- Language: Rust
- Size: 254 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# nmt (node_modules trimmer)
nmt is a CLI utility that trims `node_modules` folder size by removing unnecessary files and folders.
## Why nmt?
When you're building a container or a lambda, the size of your application matters. A smaller artifact size means faster deployments, faster loading times and less storage used.
`node_modules` is one of the biggest contributors to the size of your application. By removing unnecessary files and folders, you can shrink the size of your application and make it more efficient.
## Features
* Remove unnecessary files and folders from `node_modules` (like: type definitions, tests, etc);
* Minify JavaScript files;
* Remove all CJS or ESM files.## Usage
`nmt` provides 2 binaries: `cli` and `docker`.
### CLI
`cli`: is the binary that removes unnecessary files and folders from `node_modules`.
```bash
Usage: cli [OPTIONS]Options:
-p, --project-root-location
Path to the project root
[env: PROJECT_ROOT_LOCATION=]
[default: .]-e, --entry-point-location
Path to the application's entry point
[env: ENTRY_POINT_LOCATION=]
[default: dist/index.js]-n, --node-modules-location
Path to the `node_modules` directory
[env: NODE_MODULES_LOCATION=]
[default: node_modules]-H, --home-location
Path to the home directory
[env: HOME_LOCATION=]
[default: ~]-d, --dry-run
Whether to perform a dry run
[env: DRY_RUN=]-m, --minify
Whether to minify JS files
[env: MINIFY=]-k, --keep
A list of files to ignore
[env: KEEP=]-S, --strategy
[env: STRATEGY=]
[default: Static]-h, --help
Print help (see a summary with '-h')-V, --version
Print version
```### Docker
`docker`: is the binary that builds a shrinked version of the desired Docker image.
```bash
Usage: docker [OPTIONS]Options:
-p, --project-root-location
Path to the project root
[env: PROJECT_ROOT_LOCATION=]
[default: .]-e, --entry-point-location
Path to the application's entry point
[env: ENTRY_POINT_LOCATION=]
[default: dist/index.js]-n, --node-modules-location
Path to the `node_modules` directory
[env: NODE_MODULES_LOCATION=]
[default: node_modules]-H, --home-location
Path to the home directory
[env: HOME_LOCATION=]
[default: ~]-d, --dry-run
Whether to perform a dry run
[env: DRY_RUN=]-m, --minify
Whether to minify JS files
[env: MINIFY=]-k, --keep
A list of files to ignore
[env: KEEP=]-S, --strategy
[env: STRATEGY=]
[default: Static]-s, --source-image
The source image
[env: SOURCE_IMAGE=]
[default: hello-world]-D, --destination-image
The destination image
[env: DESTINATION_IMAGE=]
[default: ]-h, --help
Print help (see a summary with '-h')-V, --version
Print version
```## Benchmarks
| image name | size before | size after | commands |
| ------------------ | ----------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------- |
| nodered/node-red | 569.82 MB | 453.79 MB | --source-image nodered/node-red --entry-point-location "node_modules/node-red/red.js" --keep "node_modules/oauth2orize/lib/**/*.*" --keep "**/*node-red/**/*.*" --keep "**/ajv/lib/refs/*.*" |
| nodered/node-red | 569.82 MB | 447.7 MB | --source-image nodered/node-red --entry-point-location "node_modules/node-red/red.js" --keep "node_modules/oauth2orize/lib/**/*.*" --keep "**/*node-red/**/*.*" --keep "**/ajv/lib/refs/*.*" --minify |
| ilteoood/xdcc-mule | 176.68 MB | 141.91 MB | --source-image ilteoood/xdcc-mule --entry-point-location "./index.js" --keep "**/node_sqlite3.node"
| ilteoood/xdcc-mule | 176.68 MB | 139.3 MB | --source-image ilteoood/xdcc-mule --entry-point-location "./index.js" --keep "**/node_sqlite3.node" --minify
| ghost | 595.73 MB | 402.22 MB | --source-image ghost --entry-point-location "index.js" --keep "**/node_sqlite3.node" --keep "**/bookshelf-relations/**/*.*" --keep "**/@tryghost/**/*.*" --keep "**/gscan/**/*.*" --keep "**/core/**/*.*"
| ghost | 595.73 MB | 378.48 MB | --source-image ghost --project-root-location /var/lib/ghost/current --entry-point-location "index.js" --keep "**/node_sqlite3.node" --keep "**/bookshelf-relations/**/*.*" --keep "**/@tryghost/**/*.*" --keep "**/gscan/**/*.*" --keep "**/core/**/*.*" --minify
| ghcr.io/umami-software/umami:postgresql-latest | 357.66 MB | 352.59 MB | --source-image ghcr.io/umami-software/umami:postgresql-latest --entry-point-location "server.js" --keep "**/npm-run-all/**/*.js" --entry-point-location "scripts/check-db.js" --entry-point-location "scripts/update-tracker.js" --keep "**/*prisma*/**/*.*" --keep "**/styled-jsx/**/*.js" --keep "**/*next*/**/*.js" --keep "node_modules/@umami/redis-client/dist/index.js"
| ghcr.io/umami-software/umami:postgresql-latest | 357.66 MB | 346.16 MB | --source-image ghcr.io/umami-software/umami:postgresql-latest --entry-point-location "server.js" --keep "**/npm-run-all/**/*.js" --entry-point-location "scripts/check-db.js" --entry-point-location "scripts/update-tracker.js" --keep "**/*prisma*/**/*.*" --keep "**/styled-jsx/**/*.js" --keep "**/*next*/**/*.js" --keep "node_modules/@umami/redis-client/dist/index.js" --minify