🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

babel-plugin-minprops

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-minprops

Normally, a JavaScript minifier will not minify object properties, because they may be used elsewhere, in files other than the one in which they are defined. Minify allows you to write descriptive property names and safely minify them for production buil

2.0.1
latest
npm
Version published
Weekly downloads
233
-10.38%
Maintainers
1
Weekly downloads
 
Created
Source

minprops

Normally, a JavaScript minifier will not minify object properties, because they may be used elsewhere, in files other than the one in which they are defined. Minify allows you to write descriptive property names and safely minify them for production builds.

Example

Without minprops:

foo.js

class Foo {
  callTheFunctionWithTheArgsThatWerePassed(fn, ...args) {
    return fn(...args);
  }
}

module.exports = Foo;

index.js

const Foo = require('./foo');

Foo.callTheFunctionWithTheArgsThatWerePassed((num1, num2) => num1 + num2, 1, 2);

⭆⭆⭆ MINIFY! ⇒⇒⇒

foo.min.js

class a {
  callTheFunctionWithTheArgsThatWerePassed(b, ...c) {
    return b(...c);
  }
}

module.exports = a;

index.min.js

const a = require('./foo');

a.callTheFunctionWithTheArgsThatWerePassed((b, c) => b + c, 1, 2);

With minprops:

Use $__ to notate properties that are private to the package and can be safely renamed.

foo.js

class Foo {
  $__callTheFunctionWithTheArgsThatWerePassed(fn, ...args) {
    return fn(...args);
  }
}

module.exports = Foo;

index.js

const Foo = require('./foo');

Foo.$__callTheFunctionWithTheArgsThatWerePassed((num1, num2) => num1 + num2, 1, 2);

⭆⭆⭆ MINIFY! ⇒⇒⇒

foo.min.js

class a {
  a(b, ...c) {
    return b(...c);
  }
}

module.exports = a;

index.min.js

const a = require('./foo');

a.a((b, c) => b + c, 1, 2);

Options

Options can be specified in a minprops property in your package.json

{
  ...
  "minprops": {
    "exclude": [
      "id"
    ],
    "matchPrefix": "$__"
  }
  ...
}
  • exclude: List an array of properties to not minify to. Use this if your package has properties that are two characters or less.
  • matchPrefix: Use a custom prefix. Defaults to $__.

FAQs

Package last updated on 20 May 2017

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