🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

prelim

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prelim

Pre-build Unused Code Eliminator for JavaScript

latest
Source
npmnpm
Version
0.3.2
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

prelim: A Pre-build Unused Code Eliminator for JavaScript

Prelim is an unused code removal (dead code elimination) tool for javascript.

Unlike other tools in this space, such as babel-minify or terserjs, prelim is focused on the "pre-build" use case: it's meant to be used outside of a build process to find and remove no-longer-used code so that humans can better read and understand their code.

You can run prelim directly on your source folder, like:

npx prelim src/

You can also use prelim in conjunction with other tools, such as a codemod or find-replace to remove a no-longer-used feature flag.

You can also use prelim as a babel plugin if you would like (although at the moment prelim provides more benefit when run outside of a build process, it can produce some savings that terserjs may not be able to identify as unused).

Usage

Installation:

npm install --save-dev prelim

Useage: as a cli:

npx prelim src/directory/

Or as a babel plugin:

module.exports = {
    /* ... */
    plugins: [
        // `loose:` enables not-strictly safe optimizations, and is recommended
        // for code that does not have getters/proxies with side-effects.
        // The default is `false` (equivalent to `--strict` in the cli)
        ['prelim', { loose: true }],
    ],
};

Supported optimizations

Prelim supports a few different types of optimizations:

Unused variable deletion

Prelim can find and delete unused variables whose initializations appear to be free of side effects.

Unused property deletion

Prelim can find and delete unused properties in object literal variables whose values appear to be free of side effects.

Unreachable conditional branches

Prelim can find and replace if statements and conditional operator expressions where only one branch is taken because the condition always evaluates to a truthy or falsy value.

Boolean expression simplification

Prelim can simplify if-conditions and other boolean expressions where parts of the expression always evaluate to truthy or falsy values.

Bugs

Please report bugs or issues you run into with github issues.

Contributing

Please see CONTRIBUTING.md for background for contributing.

License

Prelim is MIT licensed.

Keywords

unused

FAQs

Package last updated on 15 Feb 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts