MCPcopy Index your code
hub / github.com/babel/minify

github.com/babel/minify @6.9.5 sqlite

repository ↗ · DeepWiki ↗ · release 6.9.5 ↗
1,378 symbols 2,662 edges 857 files 32 documented · 2%
README

babel-minify (beta)

An ES6+ aware minifier based on the Babel toolchain.

NPM Version Travis Status CircleCI Status AppveyorCI Status Code Coverage Slack Status NPM Downloads

  • babel-minify is consumable via API, CLI, or Babel preset. Try it online - babeljs.io/repl

Historical note: babel-minify was renamed from babili.

Table of Contents

Experimental

babel-minify is an experimental project that attempts to use Babel's toolchain (for compilation) to do something in a similar vein, minification. It's currently in 0.x, so we don't recommend using it in production.

Checkout our CONTRIBUTING.md if you want to help out!

Requirements

  • node >= 6
  • babel >= 6.20.0

Why

Current tools don't support targeting the latest version of ECMAScript. (yet) - BabelMinify can because it is just a set of Babel plugins, and Babel already understands new syntax with our parser Babylon. - When it's possible to only target browsers that support newer ES features, code sizes can be smaller because you don't have to transpile and then minify.

Check out our blog post for more info!

// Example ES2015 Code
class Mangler {
  constructor(program) {
    this.program = program;
  }
}
new Mangler(); // without this it would just output nothing since Mangler isn't used

Before

// ES2015+ code -> Babel -> BabelMinify/Uglify -> Minified ES5 Code
var a=function a(b){_classCallCheck(this,a),this.program=b};new a;

After

// ES2015+ code -> BabelMinify -> Minified ES2015+ Code
class a{constructor(b){this.program=b}}new a;

CLI

Package Version Dependencies
babel-minify npm Dependency Status

Install

npm install babel-minify --save-dev

Usage

minify src -d lib

Babel preset

Package Version Dependencies
babel-preset-minify npm Dependency Status

Install

npm install babel-preset-minify --save-dev

Usage

note: minify is still in beta, so we don't recommend using it for production code but rather the production environment.

When testing, it's recommended to run minifiers for production so less code is sent to end-users vs. in development where it can be an issue for readability when debugging. Check out the env docs for more help.

Options specific to a certain environment are merged into and overwrite non-env specific options.

.babelrc:

{
  "presets": ["es2015"],
  "env": {
    "production": {
      "presets": ["minify"]
    }
  }
}

Then you'll need to set the env variable which could be something like BABEL_ENV=production npm run build

Individual Plugins

The minify repo is comprised of many npm packages. It is a lerna monorepo similar to babel itself.

The npm package babel-preset-minify is at the path packages/babel-preset-minify

Package Version Dependencies
babel-plugin-minify-constant-folding npm Dependency Status
babel-plugin-minify-dead-code-elimination npm Dependency Status
babel-plugin-minify-flip-comparisons npm Dependency Status
babel-plugin-minify-guarded-expressions npm Dependency Status
babel-plugin-minify-infinity npm Dependency Status
babel-plugin-minify-mangle-names npm Dependency Status
babel-plugin-minify-replace npm Dependency Status
babel-plugin-minify-simplify npm Dependency Status
babel-plugin-minify-type-constructors npm Dependency Status
babel-plugin-transform-member-expression-literals npm Dependency Status
babel-plugin-transform-merge-sibling-variables npm Dependency Status
babel-plugin-transform-minify-booleans npm Dependency Status
babel-plugin-transform-property-literals npm Dependency Status
babel-plugin-transform-simplify-comparison-operators npm Dependency Status
babel-plugin-transform-undefined-to-void npm Dependency Status

Usage

Normally you wouldn't be consuming the plugins directly since the preset is available.

Add to your .babelrc's plugins array.

{
  "plugins": ["babel-plugin-transform-undefined-to-void"]
}

Other

Package Version Dependencies
babel-plugin-transform-inline-environment-variables npm Dependency Status
babel-plugin-transform-node-env-inline npm Dependency Status
babel-plugin-transform-remove-console [![npm](https://img.shields.io/npm/v/babel-plugin-trans

Core symbols most depended-on inside this repo

log
called by 130
smoke/smoke-test.js
push
called by 78
scripts/plugin-timing.js
readbits
called by 39
scripts/pyflate.py
len
called by 25
scripts/plugin-contribution.js
has
called by 20
packages/babel-plugin-minify-mangle-names/src/counted-set.js
add
called by 17
packages/babel-plugin-minify-mangle-names/src/counted-set.js
match
called by 17
packages/babel-plugin-minify-simplify/src/pattern-match.js
keys
called by 16
packages/babel-plugin-minify-mangle-names/src/counted-set.js

Shape

Function 1,031
Method 178
Class 169

Languages

TypeScript96%
Python4%

Modules by API surface

scripts/pyflate.py52 symbols
packages/babel-plugin-minify-dead-code-elimination/src/index.js41 symbols
scripts/benchmark.js32 symbols
packages/babel-plugin-minify-mangle-names/src/index.js22 symbols
packages/babel-plugin-minify-simplify/src/index.js20 symbols
packages/babel-plugin-minify-builtins/src/index.js18 symbols
smoke/smoke-test.js17 symbols
packages/babel-plugin-minify-simplify/__tests__/fixtures/common-conditional-expression-patterns/expected.js16 symbols
packages/babel-plugin-minify-simplify/__tests__/fixtures/common-conditional-expression-patterns/actual.js16 symbols
packages/babel-plugin-minify-mangle-names/src/scope-tracker.js15 symbols
packages/babel-plugin-minify-constant-folding/src/replacements.js14 symbols
packages/babel-minify/src/fs.js14 symbols

Dependencies from manifests, versioned

@babel/core7.17.0 · 1×
@babel/plugin-transform-block-scoping7.16.7 · 1×
@babel/preset-env7.17.10 · 1×
babel-helper-evaluate-path0.5.0 · 1×
babel-helper-flip-expressions0.4.3 · 1×
babel-helper-is-nodes-equiv0.0.1 · 1×
babel-helper-is-void-00.4.3 · 1×
babel-helper-mark-eval-scopes0.4.3 · 1×
babel-helper-remove-or-void0.4.3 · 1×
babel-helper-to-multiple-sequence-expressions0.5.0 · 1×
babel-jest24.9.0 · 1×
babel-plugin-minify-builtins0.5.0 · 1×

For agents

$ claude mcp add minify \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact