Skip to content

Instantly share code, notes, and snippets.

@montasim
Created July 6, 2024 14:24
Show Gist options
  • Save montasim/fabbd94a39ef802784c71e2843967f2d to your computer and use it in GitHub Desktop.
Save montasim/fabbd94a39ef802784c71e2843967f2d to your computer and use it in GitHub Desktop.
Using the .yarnclean file effectively helps maintain a cleaner, more efficient codebase and can be a crucial part of optimizing JavaScript projects that use Yarn as a package manager.
# test directories
__tests__
test
tests
powered-test
# asset directories
docs
doc
website
images
assets
# examples
example
examples
# code coverage directories
coverage
.nyc_output
# build scripts
Makefile
Gulpfile.js
Gruntfile.js
# configs
appveyor.yml
circle.yml
codeship-services.yml
codeship-steps.yml
wercker.yml
.tern-project
.gitattributes
.editorconfig
.*ignore
.eslintrc
.jshintrc
.flowconfig
.documentup.json
.yarn-metadata.json
.travis.yml
# misc
*.md
@montasim
Copy link
Author

montasim commented Jul 6, 2024

File Overview

The .yarnclean file is designed to help streamline projects by removing extraneous files from your node_modules directory, which can significantly reduce deployment sizes and improve deployment times. It's particularly useful in production environments where you want to minimize resource usage and speed up operations.

Descriptions of Common Entries

Test directories: These entries specify directories commonly used for tests, such as tests, test, tests, and powered-test. Since test files are not usually required in production, removing them can save space.

Asset directories: Directories like docs, doc, website, images, and assets are often not needed in production unless they are directly used by the application at runtime.

Examples: Directories named example or examples often contain sample code demonstrating how to use the library or module. These are typically not needed in production.

Code coverage directories: Directories such as coverage and .nyc_output which store code coverage data and are used for development and testing purposes.

Build scripts: Files like Makefile, Gulpfile.js, and Gruntfile.js are used for setting up or configuring build processes and are generally not required in production.

Configs: Various configuration files for continuous integration services and project configurations like appveyor.yml, circle.yml, codeship-services.yml, .gitattributes, and .editorconfig. These configurations are primarily for development use.

Miscellaneous files: Wildcard patterns like *.md to clean up all markdown files, which are often used for documentation.

Purpose and Benefits

Optimize storage: Reducing the footprint of node_modules can significantly decrease the amount of disk space used, especially in large projects with many dependencies.

Improve performance: Fewer files in node_modules can lead to faster installation times, quicker transfers across network in CI/CD pipelines, and reduced complexity in file handling during deployments.

Enhance security: By removing unnecessary files (especially build scripts and configurations), you reduce the surface area for potential security vulnerabilities.

Streamline deployments: Cleaner node_modules directories mean that packaging and deploying applications can be more efficient, with fewer files to process and manage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment